SR-009 — Local Development Environment Topology System Requirements
By Engineering Team•September 29, 2026•7 min read
Metadata
| Field | Value |
|---|---|
| Project Name | Local Development Environment Topology |
| Document ID | SR-009 |
| Author | Engineering Team |
| Status | Draft |
This document derives functional and non-functional requirements directly from the platform’s real local-development wiring — development/docker-compose.yml, development/nginx.conf, and the diagram below — rather than from a business requirement, since this topic covers infrastructure/deployment mechanics with no dedicated BRD. It is scoped to the full system topology every component shown in the local-development diagram participates in, not narrowly to Docker Compose stack-control commands (those stay documented in development/CLAUDE.md and .claude/rules/07-deployment-and-local-infra.md, which this document does not duplicate).
1. Functional Requirements (FR)
Gateway & ingress
- FR-01 (Single Public Entry Point): All external traffic — API and media — MUST enter through
cdn-edge(Squid), the only container publishing a host port (8000) for application traffic. - FR-01a (Central Cache, Single Domain):
cdn-edgeMUST also act as the platform’s one shared cache for both traffic classes rather than each class (API, media/storage) needing its own domain or cache layer. It routes to two distinct upstream origins via Squidcache_peers selected by path — media requests (/v0/b/<bucket>/o/...) to the Firebase Storage Emulator, everything else tonginx-api-router— so a single public domain/port (8000) fronts both, instead of separate API and asset/CDN domains. Media objects (.jpg/.jpeg/.png/.gif/.webp) MUST be force-cached for up to 30 days via arefresh_patternoverride (override-expire ignore-no-store ignore-private) specifically because the Firebase Storage Emulator does not reliably emit its ownCache-Control. API responses carry no such override: whethercdn-edgecaches a given API response MUST depend entirely on theCache-Controlheader the owning microservice’s own response sets — every live/admin/api/v1/*route sendsno-storetoday, so nothing is cached, and a future route that sends a cacheable directive starts being cached with zerocdn-edge-side config change. - FR-02 (Internal Gateway Enforcement):
nginx-api-routerMUST sit behindcdn-edge, publish no host port, and enforce authentication (auth_request /_auth_verify) and Firebase App Check on every proxied route, including health checks — there is no auth-bypassed route anywhere in this configuration. - FR-03 (REST Path-Prefix Routing): Nginx MUST route REST traffic to its owning microservice by path prefix —
/product/,/shop/,/order/,/user-preference/,/tenant/,/content-processor/,/inventory/,/search/,/media/,/user-secure/— each proxied to that service’s container on its internal port. - FR-04 (GraphQL Routing):
ui-application’s storefront GraphQL queries MUST route through the same/shop/prefix asshop-service’s REST surface — GraphQL is not given a separate gateway path. - FR-05 (SSE Routing): A Server-Sent-Events stream endpoint MUST be matched by a regex
locationblock ahead of its generic prefixlocation(regex locations take precedence over prefix matches in Nginx), withproxy_buffering offso events flush immediately rather than batching in Nginx’s proxy buffer — implemented today fororder-service’s checkout-saga stream (^/order/(api/v1/order/[^/]+/stream)$) andshipment-service’s live tracking stream (^/shipment/(api/v1/order/[^/]+/stream)$). - FR-06 (gRPC Bypasses the Gateway): Internal gRPC calls between microservices (e.g.
order-service→pii-service/inventory-service/payment-service/shipment-service,shop-service→product-catalog/inventory-service/search-service) MUST be made container-to-container over Docker Compose’s internal DNS, never routed throughnginx-api-router— gRPC is not a gateway-proxied transport in this topology. - FR-07 (Pre-Auth Routes): A route that must run before an
Authorizationheader exists (phone-OTP login/signup send/verify) MUST use a dedicated/_app_check_verifyinternal location that checks only App Check, not the full/_auth_verifybearer-token check. - FR-08 (Unauthenticated Webhook Routes): A third-party webhook receiver (Razorpay’s
/payment/webhook/razorpay, Shiprocket’s/shipment/webhook/shiprocket) MUST be reachable without the standardauth_requestbearer-token check, since the caller is an external provider, not an authenticated platform user.
Client applications
- FR-09 (Mobile Client Auth):
ui-application(Flutter) MUST authenticate against the Firebase Auth Emulator and activate Firebase App Check (debug provider in local dev) before making any gateway request. - FR-10 (Admin Client Dev Server):
ui-admin-application(React) MUST run its local Vite dev server, reachable by the developer’s browser directly, and route its own API calls through the same gateway path prefixes as any other client. - FR-11 (Client Trace Injection): Both client apps MUST inject
traceparent/X-Correlation-IDon every outbound request and MUST NOT injectX-Tenant-ID— tenant scope is carried inside the Firebase JWT and resolved server-side by Nginx’s/_auth_verifysubrequest, per the platform’s security standards.
Data stores
- FR-12 (Relational Store): Services requiring relational storage (
payment-service,pii-service/pci-service,provider-auth-servicewhere applicable) MUST connect to the single sharedpostgrescontainer on port5432. - FR-13 (Document Store): Services requiring document storage MUST connect to the local
mongocontainer, which runs themongodb/mongodb-atlas-local:8.0.3image rather than a vanillamongoimage — this is a deliberate choice, not a mislabel, so thatsearch-servicecan exercise a real Atlas Search index locally (see ADR-00007) without a live connection to MongoDB Atlas Cloud. - FR-14 (Object/Blob Storage): Document uploads (
document-service’s masked audit JSON), tenant-catalog assets (ui-admin-applicationuploads), and content-processor staging inputs MUST be stored in the Firebase Storage Emulator (port9199), addressed by bucket rather than by a real GCS project.
Async / event backbone
- FR-15 (Pub/Sub Transport): Every asynchronous event in this topology (audit-trail publish, catalog sync, recent-view events, migration record dispatch) MUST flow through the Firebase Pub/Sub Emulator (port
8085) — no service in local development connects to a real GCP Pub/Sub project. - FR-16 (Storage-Triggered Functions):
firebase-functionMUST react to GCS storage-write events on the staging bucket and publish a corresponding Pub/Sub message to drive the content-processor pipeline, rather than being invoked by a direct HTTP call.
Workflow orchestration
- FR-17 (Saga Orchestration):
order-service’s checkout saga (order → payment → shipment, with compensating rollbacks) MUST run on thetemporalfrontend (gRPC, port7233), reusing the sharedpostgrescontainer rather than provisioning a dedicated Temporal database. - FR-18 (Workflow Visibility):
temporal-ui(port8233, container port8080) MUST be reachable for inspecting in-flight and historical checkout-saga workflow executions during local development.
External provider integration
- FR-19 (Payment Provider):
payment-serviceMUST receive Razorpay webhook deliveries on its own HTTP surface (POST /payment/webhook/razorpay) independent of the gRPC port it otherwise serves on, andui-applicationMUST invoke Razorpay’s client-side checkout modal directly (a client-to-provider connection outside the gateway). - FR-20 (Shipment Provider Auth Minting):
shipment-serviceMUST obtain Shiprocket OAuth2 tokens fromprovider-auth-servicerather than authenticating with Shiprocket directly —provider-auth-serviceis the sole token minter/cache for third-party provider credentials, shared (not tenant-scoped) across every tenant. - FR-21 (Provider Mocking): In local development, Shiprocket-bound calls MUST be able to target
mock-service(port8096, container port8080) as a stand-in forapiv2.shiprocket.in, with nodepends_onordering requirement and no persisted state beyond process lifetime.
Observability stack
- FR-22 (Trace/Metric Export): Every Go/Rust microservice MUST export traces and metrics to
otel-collectorover gRPC OTLP (port4317); Firebase Functions MUST export over HTTP OTLP (port4318, internal to the Docker network only) rather than gRPC OTLP, per the platform’s observability & tracing standards. - FR-23 (Trace/Metric/Log Storage & Visualization):
otel-collectorMUST forward traces to Tempo (port3200) and expose metrics for Prometheus (port9090) to scrape; both MUST be queryable through Grafana (port3000). - FR-24 (Container-Level Resource Metrics): Container CPU/memory/network/restart-count metrics MUST be collected via a single
cadvisorinstance scraping/var/run/docker.sock, requiring no per-service Dockerfile or code change, per the platform’s performance & metrics standards. - FR-25 (Log Pipeline): Container stdout/stderr logs MUST be picked up via
/var/run/docker.sockby Vector, transformed, and shipped to Loki (port3100) for Grafana visualization — a separate pipeline from the trace/metric path, sharing only the Docker socket as a common source.
2. Non-Functional Requirements (NFR)
- NFR-01 (Multi-Tenancy Propagation): Every transport in this topology — REST, GraphQL, SSE, gRPC, Pub/Sub — MUST propagate
tenant_idend to end, consistent with the platform’s layered architecture standards; no hop in this topology is exempt. - NFR-02 (Single-Command Stack Lifecycle): The entire topology MUST be reproducible with a single
docker compose -p ecommerce-shoppee up -dfromdevelopment/, and torn down with a singledocker compose -p ecommerce-shoppee down, per the deployment & local infrastructure standard. - NFR-03 (Fail-Fast Configuration): A service in this topology MUST refuse to start on missing required configuration (a missing
*_TOPIC_ID,FIREBASE_PROJECT_ID, a required DB connection var) rather than failing on first request, per the deployment & local infrastructure standard’s fail-fast principle. - NFR-04 (Port Uniqueness, With a Documented Exception): Every service’s published host port MUST be unique, with one standing, documented exception carried forward from the Port Matrix itself:
tenant-serviceandinventory-serviceboth claim host port8083— see the deployment & local infrastructure standard for this pre-existing, flagged-not-fixed mismatch. This document does not introduce or resolve that collision; it is out of scope here. - NFR-05 (Metric Cardinality Guardrail): No metric emitted by any component in this topology may carry
tenant_id,correlation_id, or any other unbounded per-request value as a label — route/method templates only, per the platform’s performance & metrics standards. - NFR-06 (App Check Debug-Token Consistency): The App Check debug token used by
ui-application,ui-admin-application, anduser-secure-engineMUST match across all three in local development, or App Check verification fails closed (401) for every gateway-protected route. - NFR-07 (No Production Credentials in Local Config): No component in this topology may be configured with a real production credential, key, or token — local development targets emulators (Firebase Auth/Storage/Pub-Sub) and local containers (Postgres, MongoDB Atlas Local, Temporal) exclusively, per the platform’s security standards.
- NFR-08 (CDN Cache Scope Must Match
Cache-ControlSemantics):cdn-edgeMUST NOT reuse a response across clients unless the origin explicitly marked it shared-cacheable (Cache-Control: public); it MUST NOT addignore-no-store/ignore-privateto the APIrefresh_patternfor any reason, since that would cache JWT-gated, tenant-scoped responses across tenants. Two API-levelCache-Controlmiddleware patterns exist today, and they are not equivalent: tenant-admin routes (inventory-service,tenant-service,search-service,product-catalog,shop-service) setno-storeand are never cached anywhere; a subset of client-facing read routes (search-service,product-catalog) setprivate, max-age=30, stale-while-revalidate=10, which is browser-cache scope only —privateexplicitly forbids reuse by a shared cache likecdn-edge, so these routes are not yet CDN-cached today despite being marked cacheable. Genuinecdn-edge-level API caching requires a future route to sendCache-Control: public, max-age=Ninstead, which FR-01a’s pass-through design already supports with nocdn-edgeconfig change.
3. Out of Scope
- Target cloud (GCP) topology for any of the above — this document describes local development as actually wired, not the production deployment target.
- Per-service required-environment-variable lists — those stay in each service’s own
CLAUDE.md/.env.example, per the deployment & local infrastructure standard. - The
search-servicedocker-compose gRPC port-mapping discrepancy ("50053:50051"vs. the service’s actual50053listen port) — a config bug, not a topology requirement, and out of scope for this document.