Internal error tracking platform for the FinanFut ecosystem.
Project description
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 /healthziGET /readyz.POST /api/v1/eventsamb HMAC.POST /api/v1/events/batchamb 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
HttpOnlyi 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_URLWATCHTOWER_SECRET_KEYWATCHTOWER_ADMIN_TOKENWATCHTOWER_SESSION_COOKIE_NAMEWATCHTOWER_SESSION_MAX_AGE_SECONDSWATCHTOWER_SESSION_COOKIE_SECUREWATCHTOWER_TRUSTED_DEVICE_COOKIE_NAMEWATCHTOWER_TRUSTED_DEVICE_MAX_AGE_DAYSWATCHTOWER_INGEST_PROJECT_KEYWATCHTOWER_INGEST_SECRET_KEYWATCHTOWER_MAX_PAYLOAD_BYTESWATCHTOWER_RATE_LIMIT_EVENTS_PER_MINUTEWATCHTOWER_EVENT_RETENTION_DAYSWATCHTOWER_SLACK_WEBHOOK_URLAZURE_TENANT_IDAZURE_CLIENT_IDAZURE_CLIENT_SECRETSMTP_USERSMTP_DEFAULT_FROMWATCHTOWER_ALERT_EMAIL_TO(legacy fallback; policy recipients are preferred)WATCHTOWER_SDK_ENDPOINTWATCHTOWER_SDK_PROJECT_KEYWATCHTOWER_SDK_SECRET_KEYWATCHTOWER_SDK_SERVICE
Documentacio
docs/architecture.mddocs/api-ingestion.mddocs/admin-operations.mddocs/admin-cli.mddocs/alerting.mddocs/sdk-python.mddocs/integrating-python-apps.mddocs/deploy-render.mddocs/security-privacy.mddocs/roadmap.mddocs/future-loki-grafana.md
Properes Tasques
- Primer deploy real a Render amb els secrets configurats i smoke post-deploy.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file finanfut_watchtower-0.1.0.tar.gz.
File metadata
- Download URL: finanfut_watchtower-0.1.0.tar.gz
- Upload date:
- Size: 90.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ddf69fdb11efe90c8dea4a8cc7ab7e36d316f7189415e2432178f5691707d9b
|
|
| MD5 |
f8721c3fc69e1b7c59532c7b1f359a9b
|
|
| BLAKE2b-256 |
4e674aa1e2fc119c6f18df511ffcc5361e2cab03de4c3a98be59f9994c602a84
|
File details
Details for the file finanfut_watchtower-0.1.0-py3-none-any.whl.
File metadata
- Download URL: finanfut_watchtower-0.1.0-py3-none-any.whl
- Upload date:
- Size: 98.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78ae4be39d2000177f80f9e6f79ab7dc10b6ea3adb75e5cbe6010ed2b2dbd7c6
|
|
| MD5 |
05c6f7c4ffdd9dde0e0f35f1fcaf3b0a
|
|
| BLAKE2b-256 |
92d65d541bf873d0965aee1a926ced7d9f39e8870e7c59acc450b45ca7031a88
|