C4 Level 3 -- Event Store API
The central hub. All services communicate through events here.

Clean Architecture Layers
Controllers (Frameworks & Drivers)
| Endpoint Group |
Endpoints |
| Events |
POST /events, GET /events, GET /events/{id}, PATCH /events/{id} |
| Proposals |
POST /propose/receipt, /propose/invoice, /propose/expense |
| Review |
POST /events/{id}/approve, /events/{id}/reject |
| Checks |
GET /check/missing-receipts, /check/overdue-invoices, /check/costs |
Use Cases
| Use Case |
Responsibility |
| ProposeUseCase |
Receives proposals → scores confidence via Domain → routes to auto-approve or reviewer → dispatches to executors via Adapters |
| ReviewUseCase |
Processes approve/reject → stores decision → triggers execution via AccountingGateway or CostGateway |
Domain (Entities) — No I/O
| Component |
Responsibility |
| ConfidenceScorer |
Score proposals vs patterns. >0.9 = auto-approve |
| PolicyValidator |
Company policy validation |
Adapters (Interface Adapters)
| Adapter |
Implements |
External System |
| EventStoreAdapter |
IEventStore |
PostgreSQL events table (append-only) |
| PatternStoreAdapter |
IPatternStore |
PostgreSQL patterns table |
| AccountingGateway |
IAccountingGateway |
HTTP → Accounting API |
| CostGateway |
ICostGateway |
HTTP → Cost API |
Dependency Direction
Controllers → Use Cases → Domain
↓ (via interfaces)
Adapters → External Systems
Use Cases define interfaces (IEventStore, IPatternStore). Adapters implement them. Domain knows nothing about the outside world.