Architecture
How the pieces fit together
A clear data flow and a defense-in-depth security model — designed for many accounts across many VPS.
Windows VPS (MT4/MT5 + Agent) ──facts──▶ Hub (FastAPI · decides) ──▶ Experience (UI)
PostgreSQL ◀ store ▶ Backup · SSE ▶ realtime · nginx ▶ TLS
PostgreSQL ◀ store ▶ Backup · SSE ▶ realtime · nginx ▶ TLS
| Layer | Responsibility |
|---|---|
| Ingestion | Agents POST facts to the Hub; ephemeral tunnels or direct IP:8040. |
| Decision | Role/pairing, auto-freeze, risk/health, strategy stack (P1–P10). |
| Persistence | PostgreSQL 16 primary · SQLite fallback · one access layer (store). |
| Delivery | REST + Server-Sent Events (RBAC-filtered) · nginx reverse proxy + TLS. |
| Operations | Audit · Observability · Metrics · Backup · DR · HA. |
Security model
Defense in depth
🔑
Auth
Remote requests need a token (Bearer / query / 30-day httponly cookie); loopback is admin. Public: health & ingest only.
👥
RBAC
admin vs viewer enforced at the API; UI hides admin controls for viewers. Backend always wins on mismatch.
🛡
Edge
nginx adds security headers (X-Frame, nosniff, Referrer-Policy, CSP) and TLS (Let's Encrypt, HSTS, HTTP/2).