Architecture: Local Development Environment Topology

By Engineering Team•September 29, 2026•7 min read

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

Ecommerce Shoppee local development topology — CDN/gateway split, client apps, REST/GraphQL/SSE/gRPC transport surfaces, data stores, async messaging, workflow orchestration, third-party providers, and the observability stack

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

  1. A request from ui-application or ui-admin-application first authenticates against the Firebase Auth Emulator and, for ui-application, activates App Check via the local debug provider (FR-09, FR-11).
  2. The request reaches cdn-edge (Squid) on 8000 — the platform’s only public entry point — and is forwarded to nginx-api-router (FR-01).
  3. nginx-api-router issues an auth_request subrequest to /_auth_verify (or /_app_check_verify for a pre-auth OTP route), which decodes the Firebase JWT and injects X-Tenant-ID/X-User-Id/X-Role upstream — these headers are never trusted if sent directly by a client (FR-02, FR-07; see the platform’s security standards).
  4. 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).
  5. A GraphQL query from ui-application for storefront sections routes through the same /shop/ prefix as shop-service’s REST surface — there is no separate GraphQL gateway path (FR-04).
  6. A long-lived SSE connection (checkout-saga status, live shipment tracking) is matched by a regex location block ahead of its service’s generic prefix, with proxy_buffering off so events flush to the client immediately rather than batching in Nginx (FR-05).
  7. 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).
  8. Persistence reads/writes land on the shared postgres container or the shared mongo container (running the Atlas-compatible local image), depending on which store the target service owns (FR-12, FR-13).
  9. 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).
  10. order-service’s checkout saga (order → payment → shipment, with compensating rollbacks) executes as a Temporal workflow against the temporal frontend, observable live in temporal-ui (FR-17, FR-18).
  11. A payment flows two ways: ui-application opens Razorpay’s checkout modal directly (client-to-provider, outside the gateway), and Razorpay’s own webhook delivers asynchronously to payment-service’s unauthenticated /payment/webhook/razorpay route. A shipment flows through provider-auth-service, which mints and caches the OAuth2 token shipment-service presents to Shiprocket (or, in local development, to mock-service standing in for it) (FR-19, FR-20, FR-21).
  12. Every Go/Rust service exports traces and metrics to otel-collector over 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-collector forwards traces to Tempo and exposes metrics for Prometheus to scrape; both are queried through Grafana (FR-22, FR-23). Independently, cadvisor and Vector both read /var/run/docker.sock — cadvisor for 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 send Cache-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-edge caches (or doesn’t) purely by respecting whatever Cache-Control the terminating microservice’s response sets. Two real middleware patterns exist today in router.go across several Go services — a no-store group on tenant-admin routes (inventory-service, tenant-service, search-service, product-catalog, shop-service) and a private, max-age=30, stale-while-revalidate=10 group on a subset of client-facing read routes (search-service, product-catalog). private is deliberately not cached by cdn-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 yet cdn-edge-level shared caching. A future route sending Cache-Control: public, max-age=N starts being cached by cdn-edge automatically, with no change to squid.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).