Skip to main content

FinanFut Watchtower

Plataforma interna de monitoritzacio d'errors per a l'ecosistema FinanFut.

La v1 esta enfocada en capturar excepcions, agrupar-les per fingerprint, crear issues, mantenir historic d'events, enviar alertes des d'un worker i oferir un SDK Python intern.

Estat Actual

Aquest primer tall implementa:

  • Scaffold de backend FastAPI.
  • Configuracio amb Pydantic Settings.
  • SQLAlchemy 2.x, Alembic i models inicials.
  • GET /healthz i GET /readyz.
  • POST /api/v1/events amb HMAC.
  • POST /api/v1/events/batch amb HMAC.
  • Project keys amb secret rotables i public key estable.
  • Fingerprint inicial determinista.
  • Scrubbing recursiu de claus sensibles.
  • UI React interna per overview, llista d'issues, detall i accions d'estat.
  • Retencio d'events antics conservant issues agrupades.
  • Outbox d'alertes amb worker, Slack webhook, email via Microsoft Graph i retry amb backoff.
  • Login amb sessio cookie HttpOnly i MFA TOTP configurable per usuari admin.
  • SDK Python amb captura manual, FastAPI middleware, logging handler i decorador de jobs.
  • Frontend React intern a frontend/; en produccio es compila dins el Docker de l'API.
  • Dockerfile, Docker Compose, Render config, GitHub Actions CI/CD, Makefile i tests.

Primer Setup

cp .env.example .env
make install
docker compose up -d postgres
make migrate
.venv/bin/watchtower-admin create-user \
  --email admin@finanfut.local \
  --password change-me \
  --name "Local Admin" \
  --alert-email admin@finanfut.local
docker compose up -d app worker frontend

PostgreSQL local de Watchtower es publica a localhost:55432 per evitar col·lisions amb altres serveis locals.

Amb Docker Compose:

  • API: http://localhost:8000
  • Frontend React: http://localhost:5173
  • PostgreSQL: localhost:55432

L'API queda a:

Healthcheck:

curl http://localhost:8000/healthz

Tests

make test

Lint i format:

make lint
make format

Worker

make worker

El worker processa notification_outbox, envia alertes pels canals configurats i reintenta fallades amb backoff.

Per reload automatic en entorns locals que ho suportin:

make dev-reload

Frontend React

docker compose up frontend

Vite queda a http://localhost:5173 i proxyeja /api, /healthz i /readyz al backend local. Per treballar fora de Docker tambe pots fer cd frontend && npm install && npm run dev.

En produccio, el Dockerfile compila frontend/ i FastAPI serveix el build React des del mateix domini que l'API.

Exemple D'Ingesta

Genera una request signada amb Python:

python - <<'PY'
import hashlib, hmac, json, time

secret = "sk_dev_watchtower_change_me"
payload = {
    "event_id": "example-event-1",
    "service": "billing-api",
    "environment": "production",
    "release": "billing@local",
    "level": "error",
    "event": "stripe_webhook_processing_failed",
    "message": "Failed to process Stripe webhook",
    "exception_type": "StripeSignatureVerificationError",
}
body = json.dumps(payload, separators=(",", ":"), sort_keys=True).encode()
timestamp = str(int(time.time()))
signature = hmac.new(secret.encode(), timestamp.encode() + b"." + body, hashlib.sha256).hexdigest()
print(body.decode())
print(timestamp)
print(signature)
PY

Despres envia el body amb els headers:

curl -X POST http://localhost:8000/api/v1/events \
  -H "Content-Type: application/json" \
  -H "X-Watchtower-Project-Key: pk_dev_watchtower" \
  -H "X-Watchtower-Timestamp: <timestamp>" \
  -H "X-Watchtower-Signature: <signature>" \
  --data '<json-body>'

Variables Principals

Veure .env.example per la llista completa.

  • DATABASE_URL
  • WATCHTOWER_SECRET_KEY
  • WATCHTOWER_ADMIN_TOKEN
  • WATCHTOWER_SESSION_COOKIE_NAME
  • WATCHTOWER_SESSION_MAX_AGE_SECONDS
  • WATCHTOWER_SESSION_COOKIE_SECURE
  • WATCHTOWER_TRUSTED_DEVICE_COOKIE_NAME
  • WATCHTOWER_TRUSTED_DEVICE_MAX_AGE_DAYS
  • WATCHTOWER_INGEST_PROJECT_KEY
  • WATCHTOWER_INGEST_SECRET_KEY
  • WATCHTOWER_MAX_PAYLOAD_BYTES
  • WATCHTOWER_RATE_LIMIT_EVENTS_PER_MINUTE
  • WATCHTOWER_EVENT_RETENTION_DAYS
  • WATCHTOWER_SLACK_WEBHOOK_URL
  • AZURE_TENANT_ID
  • AZURE_CLIENT_ID
  • AZURE_CLIENT_SECRET
  • SMTP_USER
  • SMTP_DEFAULT_FROM
  • WATCHTOWER_ALERT_EMAIL_TO (legacy fallback; policy recipients are preferred)
  • WATCHTOWER_SDK_ENDPOINT
  • WATCHTOWER_SDK_PROJECT_KEY
  • WATCHTOWER_SDK_SECRET_KEY
  • WATCHTOWER_SDK_SERVICE

Documentacio

  • docs/architecture.md
  • docs/api-ingestion.md
  • docs/admin-operations.md
  • docs/admin-cli.md
  • docs/alerting.md
  • docs/sdk-python.md
  • docs/integrating-python-apps.md
  • docs/deploy-render.md
  • docs/security-privacy.md
  • docs/roadmap.md
  • docs/future-loki-grafana.md

Properes Tasques

  • Primer deploy real a Render amb els secrets configurats i smoke post-deploy.

Metadata

Release files for finanfut-watchtower 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for finanfut-watchtower 0.1.0
File Size Uploaded Provenance
finanfut_watchtower-0.1.0.tar.gz 90.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for finanfut-watchtower 0.1.0
File Interpreter ABI Platform
finanfut_watchtower-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 188.3 kB

Release files / finanfut_watchtower-0.1.0.tar.gz

Download URL finanfut_watchtower-0.1.0.tar.gz
Size 90.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2ddf69fdb11efe90c8dea4a8cc7ab7e36d316f7189415e2432178f5691707d9b
BLAKE2b-256 checksum
How to use checksums
4e674aa1e2fc119c6f18df511ffcc5361e2cab03de4c3a98be59f9994c602a84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / finanfut_watchtower-0.1.0-py3-none-any.whl

Download URL finanfut_watchtower-0.1.0-py3-none-any.whl
Size 98.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78ae4be39d2000177f80f9e6f79ab7dc10b6ea3adb75e5cbe6010ed2b2dbd7c6
BLAKE2b-256 checksum
How to use checksums
92d65d541bf873d0965aee1a926ced7d9f39e8870e7c59acc450b45ca7031a88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for finanfut-watchtower 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page