Skip to main content

C4 Level 3 — Components

Zooming inside a single container from Containers. Every bounded context in the fleet has the same internal shape, so this page describes one structure rather than eight. wes-work-planning supplies the concrete names.

This is where hexagonal architecture (ports and adapters) becomes visible, and where the platform's single most important structural rule lives: the domain depends on nothing.

The hexagon​

Read the arrows carefully: every dependency points inward or is an implementation of an inner interface. outbound/postgres does not sit "below" the use cases in a layered sense — it implements a port the application layer declared, which is what allows the same use case to run against Postgres in production and an in-memory adapter in a unit test.

The dependency rule, and why it is not just convention​

LayerMay depend on
internal/domain/**Nothing. Only other domain packages.
internal/application/**domain + application
internal/adapters/inbound/**application + domain — never an outbound adapter
internal/adapters/outbound/**application + domain — never an inbound adapter
cmd/**everything — it is the composition root, and nothing under internal/ may import it

This is enforced by an arch-go fitness test (internal/architecture/architecture_test.go) that runs as its own arch-test job in CI, on every pull request, in every context. A violation fails the build. It is a test, not a style guide.

The practical effect is a hard rule you can rely on when reading any service in this fleet: there are no chi, pgx, kafka-go or SQL types anywhere under internal/domain/, and no JSON struct tags either — because a JSON tag would mean the domain model had started serving a transport concern.

The four inbound adapters, and why there are four​

Every context exposes the same four driving surfaces over the same use cases. They are genuinely different contracts, not four spellings of one:

AdapterContractConsumerWrites?
inbound/httpREST, specified in apis/openapi.yaml, Spectral-linted in CIOther contexts, the console, humansYes
inbound/kafkaThe upstream context's published language, specified in apis/asyncapi.yamlThis context reacting to others' eventsYes
inbound/mcpMCP tools over Streamable HTTPwarehouse-ops-agent and AI clientsBy authority level (Agentic Standard v2): L1 tools read and change nothing, and are the default; an L2 tool returns a proposal and changes nothing; an L3 tool writes behind a human approval, and only where an ADR in the owning context grants it
inbound/a2aA2A skills as JSON-RPC over HTTP; the Agent Card at /.well-known/agent-card.jsonAI agents delegating a goal through the Agent RouterOnly behind an L3 skill with a human approval

The MCP surface is deliberately curated and intent-level ("get the backlog telemetry"), never a generic query interface over the database. It runs as its own cmd/mcp binary so that agent traffic cannot destabilise the OLTP process, and it is additive: it was added to every context without changing a single existing REST or Kafka contract. The first MCP servers were read-only by charter; Agentic Standard v2 replaced that fleet-wide charter with a declared authority level per tool (the _meta["com.warehouse/authority"] key: L1 reads by default, a write L3 or above behind an ADR in the owning context), and each context's own ADR still decides what its server offers, held by a read-only fitness test per repository.

The A2A adapter (cmd/a2a, port 8093) has the same shape one step further out, and it is delegation only: a client hands the context's agent a goal-shaped skill, the agent answers from its own state through its own use cases, and facts still travel as CloudEvents on Kafka; a skill never proxies another context's data. Every skill declares its level as an authority:L1 to authority:L4 tag. REST, MCP and A2A stay unauthenticated by the fleet decision: the in-cluster boundary is the access control, REST reaches Kong at /api/<ctx>, and MCP and A2A reach the Agent Router at /api/mcp/<ctx> and /api/a2a/<ctx> (warehouse-infra ADR 0014 and 0015).

The outbound ports, and the substitution they enable​

The port interfaces are small and declared by the application layer in its own vocabulary:

type WorkUnitRepo interface { /* FindById, Save … */ }
type EventPublisher interface { /* Publish(ctx, event) */ }
type UnitOfWork interface { /* Execute(ctx, fn) */ }
type Clock interface { /* Now() time.Time */ }

Because Clock is a port, a test can assert a lease expiry without sleeping. Because EventPublisher is a port, a unit test substitutes a fake and the running service publishes through the transactional outbox. Because the repositories are ports, a unit test runs a use case over in-memory adapters. The running services need Postgres and Kafka: on develop, on 2026-10-21, no non-test cmd/ file of any context except order-management imports an adapters/outbound/memory package, and order-management still falls back to in-memory adapters when DATABASE_URL is unset (cmd/order/adapters.go:71; gap 52 on the gaps tracker).

The transactional outbox, in component terms​

The most consequential outbound adapter is the outbox, present in outbound/postgres in five of the eight contexts with a Kafka publisher (wes-work-planning, fulfillment-execution, workforce-management, process-path-management, labor-performance — the five that carry an outbox migration on origin/develop):

The reason this matters is not theoretical. process-path-management's Postgres store and its Kafka topic were once found diverged in both directions at once, while its REST listing looked perfectly healthy — the exact failure mode the outbox closes. Note also the ordering subtlety visible in the real ReleaseNextWork use case: the aggregate Save deliberately precedes Publish inside the same scope, because the integration publisher enriches the event by reading the work unit back, and under the outbox that read must see this transaction's own row.

facility-layout is the one context still genuinely open: it has a Postgres EventPublisher that appends to an events table which nothing drains, and publishes live through a direct Kafka adapter instead. order-management and inventory-storage have documented the absent outbox as an accepted, scoped gap rather than implementing it. See the Context Map for the per-context table.

Where the analytical read side sits​

The analytics code is a separate region of the same repository, with its own dependency rule:

internal/analytics/report/ read-model types + ports — depends on NOTHING
internal/adapters/inbound/kafka/analytics_consumer.go
internal/adapters/inbound/http/reports_handler.go
internal/adapters/outbound/analyticsstore/

internal/analytics/report depends on nothing, and — critically — the OLTP layers must not import it, and it must not import them. That, too, is asserted by the arch-go test rather than left to reviewer discipline. The two sides meet only through Kafka.

Next: the Domain Model class diagrams show what actually lives inside domain/**.