1. Deployment status
| Environment | Status | Notes |
|---|---|---|
| Local Docker (single host) | POC contract | Compose project breezrx. The web app is published on host 127.0.0.1:3100 → container 3000. The API is internal on 4000. PostgreSQL 16 is on the named volume pg-data. The parent session validates with a real docker compose up |
| AWS dev / stage / prod | Does not exist | No AWS account, VPC, cluster, database, DNS name or BAA exists for BreezRx. Every cloud section below is Proposed |
On the reference workstation, host port 3000 is already used by an unrelated service (an Open WebUI container). The Compose file therefore publishes 127.0.0.1:3100:3000. Inside the container, Next.js still listens on 3000. Leave the other service alone, and do not "fix" the conflict by stopping it.
2. Run the POC locally
Prerequisites
- Docker Engine 24+ with the Compose v2 plugin (
docker compose version). Docker Desktop works too. - Host port 3100 free on loopback. Check with
ss -ltn 'sport = :3100'on Linux orlsof -iTCP:3100 -sTCP:LISTENon macOS. - About 2 GB of free disk for images and build cache. Network access to the npm registry for the first build.
- No
.envfile and no secrets are needed. Do not add any.
Start
# from the repository root (where compose.yaml lives)
docker compose up --build -d
# confirm both services are running and the API is healthy
docker compose ps
# health through the web proxy (the API itself is not published)
curl -fsS http://localhost:3100/api/health
# expected: {"status":"ok","demo":true}
# open the storefront
xdg-open http://localhost:3100 # Linux; use "open" on macOS
The project name breezrx is set in the Compose file, so -p is not needed. If your Compose version ignores the top-level name:, run docker compose -p breezrx … consistently.
Demo walkthrough (smoke test)
- Open
http://localhost:3100. Add an over-the-counter product as Autoship, open the bag and choose Sign in to checkout. Create an account (use an@example.testaddress). - At checkout, add a shipping address, then a card (
4242 4242 4242 4242, any future expiry, any CVC) and Place order. The order and the autoship appear under Account; the address and card are saved for one-tap checkout next time. - Choose an Rx product, complete the doctor evaluation, then check out. The card is authorized and the order shows Awaiting doctor review. In /ops, approve the evaluation: a prescription is issued, the payment is captured and the order is confirmed. Advance it through packed → shipped → delivered.
- In /ops → Autoship, use Renew now to create a renewal order charged to the saved card. Card
4000 0000 0000 0341attaches but declines on charge, so the subscription becomes past due. - Run
docker compose restart, then reload. Everything is still there, served from the Postgres volumebreezrx_pg-data.
API checks from the host (optional)
curl -fsS http://localhost:3100/api/catalog | head -c 400; echo
curl -fsS -X POST http://localhost:3100/api/graphql \
-H 'content-type: application/json' \
-d '{"query":"{ products { id name priceCents prescriptionRequired } }"}'
# Expect a connection error when trying to reach the API directly (it is not published):
curl -sS --max-time 3 http://localhost:4000/api/health || echo "API not exposed on host (expected)"
Note: another program on your machine could be listening on 4000. That would not be BreezRx. Check with docker compose port api 4000, which prints nothing when the API is not published.
3. Compose topology (expected)
| Service | Build | Ports | Environment | Storage |
|---|---|---|---|---|
web | apps/web/Dockerfile (Next.js standalone, runs apps/web/server.js as user node) | 127.0.0.1:${WEB_PORT:-3100}:3000 (host loopback only; depends_on: api service_healthy) | Compose: API_INTERNAL_URL=http://api:4000. Image: HOSTNAME=0.0.0.0, PORT=3000 | none |
api | apps/api/Dockerfile (multi-stage, runs as node user) | expose: 4000 only, no ports: | NODE_ENV=production, DEMO_MODE=true (required; the API refuses to start without it), HOST=0.0.0.0, PORT=4000, DATABASE_URL=postgres://…@db:5432/breezrx, SCHEDULER_INTERVAL_MS=30000 | Named volume demo-data mounted at /data |
Shape of the root compose file (abridged; compose.yaml is canonical)
name: breezrx
services:
db:
image: postgres:16-alpine
environment: { POSTGRES_USER: breezrx, POSTGRES_DB: breezrx, POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-breezrx_local_dev} }
volumes: [pg-data:/var/lib/postgresql/data]
ports: ["127.0.0.1:${PG_PORT:-5544}:5432"] # loopback only, for psql inspection
healthcheck: pg_isready
api:
build: { context: ., dockerfile: apps/api/Dockerfile }
environment:
NODE_ENV: production
DEMO_MODE: "true"
DATABASE_URL: postgres://breezrx:…@db:5432/breezrx
SCHEDULER_INTERVAL_MS: "30000"
depends_on: { db: { condition: service_healthy } }
expose: ["4000"] # internal network only
web:
build: { context: ., dockerfile: apps/web/Dockerfile }
environment: { API_INTERNAL_URL: http://api:4000 }
ports: ["127.0.0.1:${WEB_PORT:-3100}:3000"]
depends_on: { api: { condition: service_healthy } }
volumes:
pg-data: {}The API image ships a HEALTHCHECK that calls /api/health inside the container. That lets depends_on: service_healthy hold the web app back until migrations have run and the catalog is seeded. The db row: postgres:16-alpine, loopback 5544, volume pg-data.
4. Local operations
| Task | Command |
|---|---|
| Follow logs | docker compose logs -f api web |
| Stop (keep data) | docker compose stop or docker compose down |
| Restart | docker compose restart |
| Rebuild after code or lockfile change | docker compose up --build -d |
| Find the data volume | docker volume ls --filter name=breezrx (normally breezrx_pg-data) |
| Reset demo data (deletes all demo orders) | docker compose down -v && docker compose up --build -d. Migrations re-run and only the catalog is re-seeded. To remove just e2e accounts: docker compose exec -T db psql -U breezrx -d breezrx < scripts/purge-test-accounts.sql |
| Back up the database | docker compose exec -T db pg_dump -U breezrx -Fc breezrx > breezrx.dump. Do not commit the dump |
| Restore the database | docker compose exec -T db pg_restore -U breezrx -d breezrx --clean --if-exists < breezrx.dump |
| Inspect with psql | docker compose exec db psql -U breezrx -d breezrx |
| Remove everything | docker compose down -v --rmi local |
Customer accounts are real, but the /ops console is open to any signed-in user and the payment gateway is a mock. Do not change the publish address to 0.0.0.0, put it behind a public tunnel, or deploy the image to a shared host. Never enter real names, health information, documents or payment details.
5. Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Bind for 127.0.0.1:3100 failed: port is already allocated | Another process uses 3100 | Find it (ss -ltnp 'sport = :3100'). Stop that process if it is yours, or pick another loopback port: WEB_PORT=3200 docker compose up -d. Do not touch port 3000's owner |
| API container restarts with "Refusing to start … DEMO_MODE=true" | Environment missing | Make sure the Compose file sets DEMO_MODE: "true" |
Web returns 500 or 502 on /api/* | API unhealthy or wrong API_INTERNAL_URL | docker compose ps; docker compose logs api; the URL must be http://api:4000 |
API logs ECONNREFUSED db:5432 | Postgres still starting or unhealthy | docker compose ps db; docker compose logs db. The API waits for service_healthy and retries |
password authentication failed | POSTGRES_PASSWORD changed after the volume was initialized | Use the original password, or reset with down -v (deletes data) |
npm ci fails during build | Lockfile out of sync | Run npm install at the root on the host, then rebuild |
| Old UI after changes | Cached image | docker compose build --no-cache web |
6. Cloud prerequisites Proposed
None of these exist yet. They are ordered by dependency and must be finished before any real PHI exists.
| # | Prerequisite | Owner | Evidence |
|---|---|---|---|
| P1 | Legal entity, licensed pharmacy/operator model and launch states chosen | CEO + counsel | Decision record (TD risk R-02) |
| P2 | AWS Organization with separate accounts: management, security/audit, log-archive, shared-services (ECR, CI), dev, stage, prod | Platform | Account list; SCPs applied |
| P3 | AWS BAA accepted (AWS Artifact) for every account that may hold PHI. Each service used for PHI checked against the current HIPAA-eligible list | Compliance | Artifact acceptance record; eligibility memo |
| P4 | IAM Identity Center + corporate IdP SSO; no IAM users; phishing-resistant MFA; break-glass procedure | Security | Access review export |
| P5 | Baseline guardrails: CloudTrail (org trail to log-archive with Object Lock), AWS Config, GuardDuty, Security Hub, IAM Access Analyzer, budgets and alerts | Security | Security Hub score; trail integrity validation on |
| P6 | Region choice: primary US region plus a DR region (for example us-east-1 / us-west-2). Open decision | Architecture | ADR |
| P7 | Domain, Route 53 hosted zone, ACM certificates | Platform | DNS delegation verified |
| P8 | IaC state backend (S3 + locking) per account; CI role with GitHub OIDC federation (no static keys) | Platform | plan runs in CI |
| P9 | Vendor BAAs for observability, email and other services that touch PHI (see the integration register) | Compliance | Register status |
| P10 | HIPAA security risk analysis and contingency plan drafted | Compliance + Security | Signed documents |
7. Target AWS architecture Proposed
| Layer | Service | Configuration intent |
|---|---|---|
| Edge | CloudFront + AWS WAF + Shield Standard | Managed rule groups, rate rules, bot control on auth routes, TLS 1.2+ policy; no caching of authenticated responses |
| Ingress | ALB via AWS Load Balancer Controller | Private origin (CloudFront-only access with a header or VPC origin); separate internal ALB for ops, behind zero-trust access |
| Compute | Amazon EKS (managed control plane) | Managed node groups or Karpenter across 3 AZs; Bottlerocket or AL2023 nodes; IRSA/Pod Identity; namespaces per context; Pod Security "restricted" |
| Database | Aurora PostgreSQL | Multi-AZ, encrypted with a CMK, IAM auth or Secrets Manager rotation, PITR, Performance Insights, deletion protection; RDS Proxy for connection pooling |
| Cache / sessions | ElastiCache (Redis OSS or Valkey engine) | In-transit and at-rest encryption, AUTH/RBAC, Multi-AZ; holds sessions, rate limits and idempotency locks. Treated as disposable |
| Objects | S3 | Buckets: quarantine, phi-vault (SSE-KMS, versioning, Block Public Access), audit-worm (Object Lock compliance mode), artifacts |
| Async | SQS (+ DLQ) and Temporal or Step Functions | Outbox relay → SQS; saga engine choice open (INT-PL-06) |
| Keys / secrets | KMS, Secrets Manager | CMK per data class; rotation enabled; External Secrets Operator |
| Observability | CloudWatch / OpenTelemetry collector | Redaction processors; no PHI; SLO dashboards and alerting |
8. EKS complexity & staged extraction
EKS is the selected production target. It brings real operational load: cluster upgrades about three times a year, add-on lifecycle, node patching, network policy, admission control and GitOps tooling. For a small team, the first production stage should run few, coarse workloads. Split them only when ownership, scaling or compliance isolation justifies it. Amazon ECS on Fargate stays a documented fallback (ADR) if the team cannot staff Kubernetes operations.
| Stage | Workloads | Exit criteria |
|---|---|---|
| A. Lift the POC shape | web Deployment, api Deployment (modular monolith on PostgreSQL), migration Job | Staging runs with synthetic data; SLO dashboards; restore drill passes; pentest scheduled |
| B. Async backbone | + outbox-relay, workers (SQS consumers), saga engine | Chaos test: no lost or duplicate side effects; DLQ alarms |
| C. Extract by need | payments → pharmacy → clinical as separate services with their own DB schemas and roles | Each extraction ships behind a feature flag with a dual-run comparison and its own SLO |
| D. Multi-region DR | Aurora Global Database or cross-region snapshots; warm standby cluster | Regional failover game day meets RTO |
Cluster baseline add-ons
- AWS Load Balancer Controller, ExternalDNS, External Secrets Operator, metrics-server, cluster autoscaling (Karpenter)
- Argo CD (GitOps) + Argo Rollouts (canary) Open decision: or Flux
- Policy: Kyverno or Gatekeeper rules for signed images only, no privileged pods, required resource limits, no
latesttags - NetworkPolicies, default-deny per namespace (VPC CNI network policy support)
- OpenTelemetry collector DaemonSet with PHI redaction
9. Infrastructure as code & CI/CD Proposed
- Tool: Terraform or OpenTofu Open decision (CDK is acceptable if the team prefers TypeScript). Planned layout under
infra/(not created yet):modules/(network, eks, aurora, redis, s3-vault, kms, observability) andenvs/{dev,stage,prod}. - State: S3 backend per account, KMS-encrypted, with locking. No local state.
- Pipeline: PR → fmt/validate → policy scan (Checkov or tfsec) →
planposted to the PR → manual approval →applythrough an OIDC-assumed role. Prod applies need two approvers. - Images: build once; generate an SBOM; vulnerability scan (block on critical); sign with cosign; push to ECR with immutable tags (git SHA); promote the same digest dev→stage→prod.
- Drift: a nightly
planalerts on drift. Console changes in prod are blocked by SCP except through break-glass.
10. Network & security Proposed
| Subnet tier | Contents | Ingress allowed from |
|---|---|---|
| Public (3 AZ) | ALB, NAT gateways | CloudFront (managed prefix list) on 443 |
| Private app (3 AZ) | EKS nodes and pods | ALB security group on app ports only |
| Isolated data (3 AZ) | Aurora, ElastiCache | App pod security groups (SG-for-pods) on 5432 / 6379 only; no route to the internet |
- VPC endpoints for S3, ECR, KMS, Secrets Manager, STS, SQS and CloudWatch Logs, so PHI-adjacent traffic stays off the public internet. Endpoint policies restrict access to our own accounts.
- Egress to partners goes through NAT with an allow-list (DNS firewall or a proxy). Partner webhooks arrive on a dedicated ingress path with WAF rules.
- VPC Flow Logs go to the log-archive account. GuardDuty EKS and runtime protection are on.
- Admin access is through SSM Session Manager or EKS access entries with SSO. No bastion with SSH keys.
11. Secrets management Proposed
- Path scheme
aws-sm://breezrx/{env}/{domain}/{name}. These are placeholders, matching the integration register. - External Secrets Operator syncs secrets to namespaced Kubernetes Secrets. EKS secrets are envelope-encrypted with KMS. Pods read only their own secrets (IRSA policy scoped by path).
- Database credentials rotate automatically (Secrets Manager rotation), or the app uses IAM database auth.
- No secrets in images, Helm values, git or CI logs. Secret scanning blocks pushes.
- The POC needs no secrets;
DEMO_MODEis configuration, not a secret.
12. Data & schema migrations
Local PostgreSQL → Aurora PostgreSQL
- Same engine, same migrations.
apps/api/migrations/*.sqlrun unchanged against Aurora. Demo rows are taggedprovider='mock_gateway'/livemode=false, so they can be excluded or purged, and themock_gatewayschema can be dropped at go-live. - The schema already uses CHECK constraints,
timestamptz,uuidkeys and integer cents (TD §0.2). Splitting it into per-context schemas (TD §6.2) and choosing a production migration runner (for example node-pg-migrate or Flyway) are still open. Open decision - Seed scripts run only in dev and stage. Production catalog data comes from the catalog admin process.
Production migration policy
- Expand/contract: add nullable columns and tables first; backfill in batches; switch reads; enforce constraints (
NOT VALIDthenVALIDATE); drop old columns in a later release. - Migrations run as a pre-deploy Kubernetes Job with a lock. The application never migrates on boot in production.
- Indexes are created
CONCURRENTLY. Long locks are not allowed: CI checkslock_timeoutandstatement_timeout. - Every release keeps code N and N-1 compatible with the schema, so rollback needs no down-migration.
- A manual snapshot is taken before high-risk migrations, and the restore procedure is rehearsed in stage.
13. Backups & restore Proposed
| Data | Mechanism | Retention (target) | Restore test |
|---|---|---|---|
| Aurora | Automated backups + PITR; AWS Backup plan with Vault Lock; cross-region and cross-account copies | PITR 35 days; monthly snapshots per records-retention decision | Quarterly restore to an isolated account; checksum row counts; app smoke test |
| S3 PHI vault | Versioning, cross-region replication, Object Lock where policy requires | Per the records-retention schedule (legal) | Quarterly object restore sample |
| Audit WORM | Object Lock compliance mode in the log-archive account | ≥ 6 years (confirm with counsel and state rules) | Annual integrity verification (hash chain) |
| Redis | None needed (cache, sessions, locks) | — | Failover test: users may need to sign in again |
| IaC / config | Git + state versioning | Indefinite | Rebuild stage from scratch once per year |
Targets for RPO, RTO and SLOs are defined in the technical design §19. They are labeled targets, not achieved results.
14. Incidents & rollback Proposed
Severity
- SEV1: checkout or clinical/pharmacy work down; suspected PHI exposure
- SEV2: degraded SLO; one partner down
- SEV3: minor or cosmetic
Application rollback
- Argo Rollouts: canary 5% → 25% → 100% with metric analysis; automatic abort on SLO burn
- Manual: revert the GitOps commit to the previous image digest
- Kill switches via feature flags (catalog SKU, checkout, refills)
Data rollback
- Prefer a forward fix. Down-migrations are not used
- Corruption: PITR to a new cluster, then a controlled cutover
- Never roll back over dispensed or captured records without pharmacist and finance reconciliation
Security / privacy incident path
- Contain: revoke credentials and isolate workloads. Preserve evidence in the log-archive account.
- Bring in the privacy officer and counsel immediately to run a HIPAA breach risk assessment (four-factor). Notification duties and deadlines are decided by counsel; the HIPAA outer limit for individual notice is 60 days from discovery, and state laws may be stricter.
- Notify partners under the BAA terms. Record the timeline in the incident system.
- Hold a blameless post-incident review within 5 business days and track corrective actions.
POC rollback
Check out the previous commit and run docker compose up --build -d. If the schema changed incompatibly, reset with docker compose down -v. The data is synthetic.
15. Future-session checklist
Every local session
docker compose up --build -d, thendocker compose psshows both services healthycurl -fsS http://localhost:3100/api/healthreturns{"status":"ok","demo":true}- The API is not reachable from the host on 4000 (
docker compose port api 4000is empty) - Smoke test from §2 passes, including the 409 on advancing an order that is awaiting review
- Data persists across
docker compose restart - Run
npm test(workspaces) before demoing changes - After editing a report in
docs/, copy it again:cp docs/{technical-design,production-integrations,cloud-deployment}.html apps/web/public/reports/
Before starting cloud work
- P1–P10 in §6 have recorded decisions and owners
- The integration register has no PHI-handling vendor without a BAA
- ADRs exist for the IaC tool, saga engine, region pair, migration tool and GitOps tool
infra/skeleton with remote state;planruns in CI with OIDC- Stage A in dev with synthetic data only. No real PHI until the MVP gate in TD §21 passes
- Update this document's status table. Never mark an environment as deployed without a URL, an owner and a passing health check
Shopping assistant inference
The inline concierge uses a configurable private OpenAI-compatible endpoint, separate from the commerce API. Existing vLLM Docker recipes are managed by the sibling GPU Workload Manager; BreezRx has no Docker socket and never changes GPU workloads automatically.
Set ASSISTANT_BASE_URL (including /v1) and the exact ASSISTANT_MODEL served by /v1/models. Model-specific JSON mode, output limits and chat-template kwargs are configurable. See the repository README for the complete environment contract.
For a future VPC, keep GPU inference in a private GPU service/container pool reachable only from the API security group. Use internal DNS, authenticated TLS, managed secrets, pinned images/weights, reviewed licenses and a separate scaling policy. Do not expose the GPU manager or inference API publicly. Host-gateway is only a local-development technique, not a cloud topology.
Implemented per API replica: four simultaneous inference requests by default, a six-second total deadline, 64 KiB response ceiling, and a circuit breaker with a 30-second cooldown after two failures. Timeout, overload, invalid response and connection failure preserve the deterministic shopping wizard. These are local safeguards, not a global traffic limit: add shared admission controls, inference queue/latency metrics, alerts and load tests before cloud launch. No cloud deployment or capacity SLO is claimed.
Packs persist in PostgreSQL; their items use the existing independently claimed renewal scheduler and individual prescription checks. Chat transcripts are intentionally ephemeral. Before real-data use, complete privacy/retention design and review the configured inference provider's logging.