--- id: DEPLOYMENT-SPIKE version: 1.0.0 status: Reviewed — Stage 7 design baseline; runtime validation pending last_cr: none --- # Deployment View — Stage 7 Architecture Spike ## 1. Logical Topology ```mermaid flowchart LR User[Browser] --> CDN[Static React delivery] CDN --> Edge[TLS ingress / rate limiting] Edge --> API1[FastAPI API instance] Edge --> API2[FastAPI API instance] API1 --> PG[(PostgreSQL primary + HA recovery target)] API2 --> PG API1 --> Valkey[(Valkey HA cache / Streams)] Worker[FastAPI worker process] --> PG Worker --> Valkey API1 --> IdP[Keycloak OIDC] API2 --> IdP Worker --> Msg[Messaging adapter / deterministic sandbox] API1 --> Obj[Private object storage] Ops[Metrics, traces, redacted logs] --- API1 Ops --- API2 Ops --- Worker Backup[Encrypted backup / PITR] --> PG ``` This is a logical candidate, not a provider selection or deployment manifest. Runtime target (cloud, region, managed/self-hosted services, ingress, secrets manager, object store and failover automation) is unselected. ## 2. Deployment Responsibilities - React static assets are served through TLS-protected edge delivery. The browser obtains identity through Keycloak OIDC/PKCE and sends bearer tokens to the API. - API replicas are stateless. Request tenant context is never stored in process-global state; PostgreSQL context is transaction-local. - PostgreSQL stores business records, append-only audit, idempotency records, and outbox. Backup/PITR and restore exercises must prove NFR-011 (RPO ≤15 minutes, RTO ≤4 hours, encrypted daily backups retained 35 days, quarterly restore exercise). - A worker consumes durable outbox work; Valkey speeds delivery but is not the only copy of work. The worker uses the same code and tenant security middleware as the API. - Keycloak, object storage and notification providers are external trust boundaries. `sandbox/identity_mock.py`, `sandbox/notification_mock.py` and other configured mocks support reproducible offline tests. - Secrets are injected from an environment-specific secret store, not committed. Logs/telemetry exclude secrets and unnecessary personal or trading data; tenant/correlation labels are included only where authorized. ## 3. Deployment Proof Required Before Baseline Demonstrate API/worker horizontal scaling without tenant context leakage; PostgreSQL failover and restore against NFR-011; stream unavailability with durable retry; private-file authorization and erasure behavior; and capacity at the NFR-012 envelope. These checks are pending; no cloud, cluster, instance, pool, or replica sizing is claimed as validated.