Architecture¶
The platform is a set of containers orchestrated by Docker Compose. One nginx gateway is the only entry point for browsers and test tools; behind it, a backend owns users, the catalog, carts and orders, while smaller services own warehouse fulfilment, card payments, notifications (user webhooks and commerce emails), courier deliveries (with a tracking micro-frontend) and the LLM API. Every application service except the frontend is a Rust binary.
flowchart TB
U([Browser or test tool]) --> G[gateway]
G --> F[frontend]
G --> B[backend]
G --> W[warehouse-service]
G --> P[payment-service]
G --> N[notification-service]
G --> DS[delivery-service]
G -->|four Ollama paths| L[llm-service]
G --> D[docs wiki]
subgraph PG["PostgreSQL: database testdb"]
PUB[(schema public)]
WH[(schema warehouse)]
PAY[(schema payment)]
NOT[(schema notification)]
DEL[(schema delivery)]
end
B --> PUB
B -->|stock commands| W
W -->|role warehouse| WH
P -->|role payment| PAY
N -->|role notification| NOT
DS -->|role delivery| DEL
L -->|internal API| B
B --> MQ[ActiveMQ] --> C[email consumer] --> M[Mailpit]
N --> MQ
warehouse-service and payment-service also call the backend's internal API
(order data, fulfilment, payment results), llm-service reads users, prompts and
products through it, and warehouse-, payment-, notification- and
delivery-service read the backend's commerce events from the event feed;
apart from the
stock commands to warehouse-service, the backend never calls them. See Service integration below
and Service-to-service trust.
Every request carries an X-Request-Id and a W3C traceparent from the
gateway through the services, the event feed and the outboxes; see
Tracing a request.
Not shown: the edge nginx in front of the gateway on the server, and the LLM (ollama-mock or Docker Model Runner)
behind llm-service (see LLM integration). There is no metrics stack;
production is watched by a host watchdog and Waitcher (see
Monitoring). Ports and images for every
container are in Services and ports.
Service integration¶
Every service-to-service arrow points to the backend. Commands the services
need answered at once (read an order, mirror a fulfilment step, report a
payment result) are synchronous calls to /internal/v1. Changes the backend
makes on its own (a cancellation, a card refund to give back) are recorded as
domain events in the same transaction and pulled by the services from
GET /internal/v1/events every five seconds.
flowchart TB
W[warehouse-service]
P[payment-service]
N[notification-service]
DS[delivery-service]
subgraph B[backend]
direction LR
I["internal API<br/>/internal/v1"] -->|"same transaction"| F[("event feed<br/>domain_events")]
end
W -->|"orders, fulfilment, refunds,<br/>notifications, stock levels"| I
B -->|"stock commands (sync):<br/>reserve, confirm, adjust"| W
P -->|"order data,<br/>signed payment results"| I
W -.->|"polls order.cancelled"| F
P -.->|"polls card-refund.requested"| F
N -.->|"polls webhook types,<br/>notification.requested"| F
DS -.->|"polls order.paid, shipment.shipped,<br/>order.cancelled, shipment.delivered"| F
Solid arrows are calls made when needed, dotted arrows are polls every 5 s (events become visible once their transaction commits, so expect up to 5 s end to end). The reasons, and why this is not an ActiveMQ topic, are in the architecture decisions; the feed contract is in Event feed.
Design principles¶
- One public origin. The SPA, every API and the OpenAPI documents are served from the same host, so browsers never need CORS through the gateway.
- The backend issues identity. It signs RS256 access tokens; the other services verify them with the backend's public key set (JWKS) and hold no signing secret. See Authentication.
- Services own their data. warehouse-, payment-, notification- and delivery-service share the PostgreSQL server but each uses its own schema and its own database role, which cannot read the backend's tables. See Data and databases.
- Dependencies point to the backend. warehouse-, payment-, notification-, delivery- and llm-service depend on the backend; the backend calls only warehouse-service (stock commands) and learns nothing from the others except through calls they make. See ADR 1.
- Service calls are authenticated and idempotent.
/internal/v1calls carry a per-callerX-Service-Token; payment results are HMAC-signed; every write that can be retried carries arequestId. See Service-to-service trust. - Outboxes and a feed, not dual writes. Emails, notifications, payment results and webhooks are written to an outbox in the same transaction as the business change and delivered afterwards with retries; domain events (card refunds and cancellations among them) are written to the event feed in the same transaction and pulled by the services.
- Small footprint. The application services are Rust binaries using a few MiB each, so both sites fit a 1-vCPU, ~4 GiB VPS with most of its memory free.
Pages in this section¶
- Services and ports — every container, its port and its job.
- Compose profiles — lightweight, full, server and the overrides.
- Gateway routing — which path goes to which service.
- Authentication — JWT, refresh tokens, MFA and roles.
- Service-to-service trust — service tokens, signatures, outboxes.
- Data and databases — schemas, roles, migrations and tables.
- Architecture decisions — why the services integrate through a pull feed, why the backend keeps fulfilment state, why outboxes are per service, and why one PostgreSQL server.