Explore projects
Javaintermediatebackend
Event Sourcing Order Service
Order service with event sourcing: each state change is an immutable event; the state is reconstructed from the event stream.
5 steps
Project steps
- 01
Event store
Events table (id, aggregate_id, type, payload JSONB, version, created_at).
- 02
Aggregate Order
Order class with apply(event) that transitions the state: CREATED → CONFIRMED → SHIPPED → DELIVERED.
- 03
Command handlers
CreateOrder, ConfirmOrder, ShipOrder validate and emit events.
- 04
Projection
Read model orders_view reconstructed by replaying the event stream.
- 05
Snapshots
Every 50 events, save a snapshot to speed up replay.
Recommended resources
Ready to build this?
Fork the repo on GitHub and start building. A mentor will review your code when you open a PR.
5 steps
Tech stack
JavaSpring BootPostgreSQLJOOQJackson