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-edge MUST 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 Squid cache_peers selected by path — media requests (/v0/b/<bucket>/o/...) to the Firebase Storage Emulator, everything else to nginx-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 a refresh_pattern override (override-expire ignore-no-store ignore-private) specifically because the Firebase Storage Emulator does not reliably emit its own Cache-Control. API responses carry no such override: whether cdn-edge caches a given API response MUST depend entirely on the Cache-Control header the owning microservice’s own response sets — every live /admin/api/v1/* route sends no-store today, so nothing is cached, and a future route that sends a cacheable directive starts being cached with zero cdn-edge-side config change.
  • FR-02 (Internal Gateway Enforcement): nginx-api-router MUST sit behind cdn-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 as shop-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 location block ahead of its generic prefix location (regex locations take precedence over prefix matches in Nginx), with proxy_buffering off so events flush immediately rather than batching in Nginx’s proxy buffer — implemented today for order-service’s checkout-saga stream (^/order/(api/v1/order/[^/]+/stream)$) and shipment-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 through nginx-api-router — gRPC is not a gateway-proxied transport in this topology.
  • FR-07 (Pre-Auth Routes): A route that must run before an Authorization header exists (phone-OTP login/signup send/verify) MUST use a dedicated /_app_check_verify internal location that checks only App Check, not the full /_auth_verify bearer-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 standard auth_request bearer-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-ID on every outbound request and MUST NOT inject X-Tenant-ID — tenant scope is carried inside the Firebase JWT and resolved server-side by Nginx’s /_auth_verify subrequest, per the platform’s security standards.

Data stores

  • FR-12 (Relational Store): Services requiring relational storage (payment-service, pii-service/pci-service, provider-auth-service where applicable) MUST connect to the single shared postgres container on port 5432.
  • FR-13 (Document Store): Services requiring document storage MUST connect to the local mongo container, which runs the mongodb/mongodb-atlas-local:8.0.3 image rather than a vanilla mongo image — this is a deliberate choice, not a mislabel, so that search-service can 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-application uploads), and content-processor staging inputs MUST be stored in the Firebase Storage Emulator (port 9199), 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-function MUST 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 the temporal frontend (gRPC, port 7233), reusing the shared postgres container rather than provisioning a dedicated Temporal database.
  • FR-18 (Workflow Visibility): temporal-ui (port 8233, container port 8080) MUST be reachable for inspecting in-flight and historical checkout-saga workflow executions during local development.

External provider integration

  • FR-19 (Payment Provider): payment-service MUST receive Razorpay webhook deliveries on its own HTTP surface (POST /payment/webhook/razorpay) independent of the gRPC port it otherwise serves on, and ui-application MUST invoke Razorpay’s client-side checkout modal directly (a client-to-provider connection outside the gateway).
  • FR-20 (Shipment Provider Auth Minting): shipment-service MUST obtain Shiprocket OAuth2 tokens from provider-auth-service rather than authenticating with Shiprocket directly — provider-auth-service is 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 (port 8096, container port 8080) as a stand-in for apiv2.shiprocket.in, with no depends_on ordering 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-collector over gRPC OTLP (port 4317); Firebase Functions MUST export over HTTP OTLP (port 4318, 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-collector MUST forward traces to Tempo (port 3200) and expose metrics for Prometheus (port 9090) to scrape; both MUST be queryable through Grafana (port 3000).
  • FR-24 (Container-Level Resource Metrics): Container CPU/memory/network/restart-count metrics MUST be collected via a single cadvisor instance 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.sock by Vector, transformed, and shipped to Loki (port 3100) 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_id end 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 -d from development/, and torn down with a single docker 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-service and inventory-service both claim host port 8083 — 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, and user-secure-engine MUST 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-Control Semantics): cdn-edge MUST NOT reuse a response across clients unless the origin explicitly marked it shared-cacheable (Cache-Control: public); it MUST NOT add ignore-no-store/ignore-private to the API refresh_pattern for any reason, since that would cache JWT-gated, tenant-scoped responses across tenants. Two API-level Cache-Control middleware patterns exist today, and they are not equivalent: tenant-admin routes (inventory-service, tenant-service, search-service, product-catalog, shop-service) set no-store and are never cached anywhere; a subset of client-facing read routes (search-service, product-catalog) set private, max-age=30, stale-while-revalidate=10, which is browser-cache scope only — private explicitly forbids reuse by a shared cache like cdn-edge, so these routes are not yet CDN-cached today despite being marked cacheable. Genuine cdn-edge-level API caching requires a future route to send Cache-Control: public, max-age=N instead, which FR-01a’s pass-through design already supports with no cdn-edge config 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-service docker-compose gRPC port-mapping discrepancy ("50053:50051" vs. the service’s actual 50053 listen port) — a config bug, not a topology requirement, and out of scope for this document.