Class diagrams
This page is a copy of docs/docs/ddd/class-diagram.md on develop, derived from that repository's code. Edit it there, then re-sync.
UML class diagrams of the domain as it is in internal/domain, and of the
hexagonal ports with the adapters that exist. Types are Go types; "interface" marks
a Go interface.
Domain types
Source: internal/domain/policy/policy.go, internal/domain/travel/travel.go,
internal/domain/recommend/recommend.go, internal/domain/stationtrip/{trip,values,events}.go.
Omits: the value types SiteID, StationID, HintID, TaskID, TaskType,
HintState, the Header embedded in every event, the error variables and the
functions recommend.Recommend and recommend.RectilinearFor (they have no
receiver). Policy.Settings() is both a field and an accessor in the code; the
diagram shows the accessor.
Hint states: StateActive, StateConsumed, StateExpired, StateSuperseded
(HintState, with Valid() and Terminal()).
Ports and adapters
Source: internal/application/ports/ports.go, clock.go, unit_of_work.go (the
OUT ports), internal/domain/travel/travel.go (the port declared in the domain),
internal/adapters/outbound/{postgres,memory}/ports_check.go (compile-time
assertions that each adapter implements the ports), cmd/api/adapters.go and
cmd/api/relay.go (the wiring), internal/adapters/kafka/cloudevents/cloudevents.go,
internal/adapters/outbound/kafka/{writer,relay_sink}.go,
internal/architecture/architecture_test.go (the layer rules). Clock and
IDGenerator are the remaining ports; the system adapter
(internal/adapters/outbound/system) implements Clock (Clock) and
IDGenerator (RandomIDs) for the shipped binary.
The eventsSink writes through the Inserter interface that
postgres.OutboxRepo satisfies; adapters never import each other, cmd/api does
the wiring.