Architecture: Local Development Environment Topology
This document satisfies the requirements in SR-009. It has no ADR behind it — the local-development topology is infrastructure wiring, not a design decision between competing options — so this document is written directly from development/docker-compose.yml, development/nginx.conf, and the diagram below, rather than from a decision record.
Diagram

Components
| Component | Role |
|---|---|
cdn-edge (Squid, 8000) |
The one public entry point for all application traffic — API and media — and the platform’s single shared cache for both, via two path-routed cache_peers (FR-01, FR-01a). |
nginx-api-router (internal only) |
Enforces auth_request /_auth_verify and Firebase App Check on every route, then proxies by path prefix to the owning microservice (FR-02, FR-03). |
ui-application (Flutter) |
Mobile shopper client — authenticates against the Firebase Auth Emulator, drives Razorpay’s client-side checkout modal directly, calls shop-service over GraphQL for storefront sections (FR-04, FR-09). |
ui-admin-application (React, Vite dev server, 5173) |
Tenant admin console — calls REST endpoints through the same gateway prefixes, uploads assets to Firebase Storage Emulator (FR-10). |
Firebase Auth Emulator (9099) |
Issues and verifies the Firebase ID tokens both client apps authenticate with; Nginx’s /_auth_verify subrequest decodes the token server-side (FR-09, FR-11). |
| Microservices (REST/GraphQL/SSE) | The generic backend tier behind Nginx — every Go/Rust/Node service exposing an HTTP or streaming surface (FR-03 through FR-05). |
| Microservices (gRPC) | The same backend tier’s synchronous inter-service calls — bypasses Nginx entirely, container-to-container over Docker Compose DNS (FR-06). |
postgres (5432) |
Shared relational store for payment-service, pii-service/pci-service, and Temporal’s own persistence (FR-12, FR-17). |
mongo (mongodb/mongodb-atlas-local:8.0.3, 27017) |
Shared document store for every Mongo-backed service, running the Atlas-compatible local image specifically so search-service can serve a real Atlas Search index offline (FR-13). |
Firebase Storage Emulator (9199) |
Backs document-service’s masked audit JSON, ui-admin-application’s asset uploads, and content-processor’s staging bucket (FR-14). |
Firebase Pub/Sub Emulator (8085) |
The sole async transport for audit-trail events, catalog sync, recent-view events, and migration record dispatch (FR-15). |
firebase-function (Node.js) |
Triggered by GCS storage-write events on the staging bucket; publishes to Pub/Sub to drive the content-processor pipeline (FR-16). |
temporal (frontend, 7233) |
Hosts order-service’s checkout-saga workflow/activity execution, reusing the shared postgres container (FR-17). |
temporal-ui (8233 → container 8080) |
Inspects in-flight and historical checkout-saga workflow executions (FR-18). |
| Razorpay | External payment provider — webhook delivery into payment-service, client-side checkout modal in ui-application (FR-19). |
Shiprocket / mock-service (8096) |
External shipment provider, reached via provider-auth-service’s minted OAuth2 tokens; mock-service stands in for apiv2.shiprocket.in in local development (FR-20, FR-21). |
otel-collector (4317 gRPC OTLP / 4318 HTTP OTLP) |
Receives traces and metrics from every Go/Rust service (gRPC) and Firebase Functions (HTTP) (FR-22). |
Tempo (3200) / Prometheus (9090) / Grafana (3000) |
Trace storage, metric storage, and unified visualization (FR-23). |
cadvisor (8091) / Vector / Loki (3100) |
Container resource metrics and log pipeline, both sourced from /var/run/docker.sock (FR-24, FR-25). |
End-to-end flow
- A request from
ui-applicationorui-admin-applicationfirst authenticates against the Firebase Auth Emulator and, forui-application, activates App Check via the local debug provider (FR-09, FR-11). - The request reaches
cdn-edge(Squid) on8000— the platform’s only public entry point — and is forwarded tonginx-api-router(FR-01). nginx-api-routerissues anauth_requestsubrequest to/_auth_verify(or/_app_check_verifyfor a pre-auth OTP route), which decodes the Firebase JWT and injectsX-Tenant-ID/X-User-Id/X-Roleupstream — these headers are never trusted if sent directly by a client (FR-02, FR-07; see the platform’s security standards).- For REST traffic, Nginx matches the request’s path prefix (
/product/,/shop/,/order/,/user-preference/,/tenant/,/content-processor/,/inventory/,/search/,/media/,/user-secure/) and proxies to that service’s container (FR-03). - A GraphQL query from
ui-applicationfor storefront sections routes through the same/shop/prefix asshop-service’s REST surface — there is no separate GraphQL gateway path (FR-04). - A long-lived SSE connection (checkout-saga status, live shipment tracking) is matched by a regex
locationblock ahead of its service’s generic prefix, withproxy_buffering offso events flush to the client immediately rather than batching in Nginx (FR-05). - Once inside the backend tier, a service needing data from another service calls it directly over gRPC, container-to-container via Docker Compose’s internal DNS — this traffic never re-enters Nginx (FR-06).
- Persistence reads/writes land on the shared
postgrescontainer or the sharedmongocontainer (running the Atlas-compatible local image), depending on which store the target service owns (FR-12, FR-13). - An asynchronous event (audit-trail publish, catalog sync, migration record dispatch) is published to the Firebase Pub/Sub Emulator and picked up by the subscribing service; a GCS object write on the staging bucket separately triggers
firebase-function, which publishes its own Pub/Sub message to continue the content-processor pipeline (FR-15, FR-16). order-service’s checkout saga (order → payment → shipment, with compensating rollbacks) executes as a Temporal workflow against thetemporalfrontend, observable live intemporal-ui(FR-17, FR-18).- A payment flows two ways:
ui-applicationopens Razorpay’s checkout modal directly (client-to-provider, outside the gateway), and Razorpay’s own webhook delivers asynchronously topayment-service’s unauthenticated/payment/webhook/razorpayroute. A shipment flows throughprovider-auth-service, which mints and caches the OAuth2 tokenshipment-servicepresents to Shiprocket (or, in local development, tomock-servicestanding in for it) (FR-19, FR-20, FR-21). - Every Go/Rust service exports traces and metrics to
otel-collectorover gRPC OTLP; Firebase Functions export over HTTP OTLP instead, since gRPC OTLP is not exposed to the Docker network the same way for that runtime.otel-collectorforwards traces to Tempo and exposes metrics for Prometheus to scrape; both are queried through Grafana (FR-22, FR-23). Independently,cadvisorand Vector both read/var/run/docker.sock—cadvisorfor container resource metrics into Prometheus, Vector for container logs transformed and shipped into Loki — a separate pipeline from the trace/metric path that shares only the Docker socket as a common source (FR-24, FR-25). See Architecture: Observability Pipeline for the detailed internals of trace/log/metric propagation this summary does not repeat.
Data store note: why mongo runs the Atlas-compatible local image
The local mongo container is not a vanilla MongoDB image — it runs mongodb/mongodb-atlas-local:8.0.3, MongoDB’s own Docker image that emulates Atlas-specific capabilities, including Atlas Search, entirely offline. This is a deliberate choice tied directly to ADR-00007: search-service depends on a real Atlas Search index ($search aggregation stage, fuzzy/compound queries) rather than a plain find() filter, and the Atlas-compatible local image is what makes that index available to a developer’s machine without a live connection to MongoDB Atlas Cloud. Every other Mongo-backed service in this topology connects to the same container as an ordinary MongoDB deployment — the Atlas-local behavior is transparent to them.
Gateway topology note: why two layers, not one
cdn-edge (Squid) and nginx-api-router are deliberately separate containers rather than one combined gateway. cdn-edge is the only container in this topology that publishes a host port for application traffic (8000) — it is the CDN/edge layer, handling both API and media traffic as a single public surface. nginx-api-router sits entirely behind it, on the internal Docker network only, and owns every enforcement decision (auth, App Check, path routing) — a request never reaches a microservice without first clearing both layers. See the deployment & local infrastructure standard for the full gateway topology note and Port Matrix.
Gateway topology note: cdn-edge as central cache, not just a router
cdn-edge doubles as the platform’s one shared cache, so caching never needs a domain of its own separate from the API/media domain it already fronts (FR-01a). It holds two Squid cache_peers, selected by an ACL on the request path rather than by a second host port or a second public domain:
- Media (
^/v0/b/[^/]+/o/) → the Firebase Storage Emulator. Image objects are force-cached up to 30 days (refresh_pattern -i \.(jpg|jpeg|png|gif|webp)$ 10080 80% 43200 override-expire ignore-no-store ignore-private) because the emulator itself doesn’t reliably sendCache-Control— this override is justified only by that specific origin’s unreliability, and is not a pattern extended to API traffic. - Everything else (API) →
nginx-api-router. No override exists here:cdn-edgecaches (or doesn’t) purely by respecting whateverCache-Controlthe terminating microservice’s response sets. Two real middleware patterns exist today inrouter.goacross several Go services — ano-storegroup on tenant-admin routes (inventory-service,tenant-service,search-service,product-catalog,shop-service) and aprivate, max-age=30, stale-while-revalidate=10group on a subset of client-facing read routes (search-service,product-catalog).privateis deliberately not cached bycdn-edge— it means only the requesting client’s own browser may cache the response, so today’s cacheable-marked routes are browser-cache scope only, not yetcdn-edge-level shared caching. A future route sendingCache-Control: public, max-age=Nstarts being cached bycdn-edgeautomatically, with no change tosquid.conf(NFR-08).
One long-lived-connection carve-out exists on the API side: order-service’s and shipment-service’s SSE streams are excluded from Squid’s own store-before-serve admission path (cache deny sse_stream_paths) so a frame is relayed the instant the origin flushes it, mirroring nginx.conf’s proxy_buffering off for the same two routes — this is about Squid’s internal buffering mechanics, not about Cache-Control semantics (the origin already sends no-cache on these routes independently).