Modular monolith

Architecture

One deployable, explicit modules, replaceable adapters. Realtime and the worker are the only processes you extract when traffic earns them.

backend/
backend/
  schemas/entities.ts          # Users, Vehicles, Trips, Locations, Payments
  modules/{geo,dispatch,trips,fleet,payments,communications,trust,safety}/
  shared/{authz,cache,events,idempotency,rate-limit,region,golive}/
  realtime/socket-server.ts    # Socket.io + Redis adapter
  workers/index.ts             # match tick + AMQP
app/api/v1/                    # HTTP
prisma/                        # Postgres + PostGIS

HTTP handlers do not contain business rules. They parse, authorize, rate-limit, then call a module. The investor demo calls those modules directly so a meeting cannot get stuck on cookies.

ModuleOwnsExtract when
geoH3, presence, ETAPing volume needs its own process
dispatchHungarian + surgeMatch latency SLO requires an isolated worker
tripsFSMKeep with the API
paymentsLedger + StripeAudit/compliance team wants a hard boundary
fleetUnlock, inspection, insurance quoteIoT vendor integration
goliveMode, tax gates, backups, headersNever extract — it is policy