Appearance
Todo CLI Application
The example/todo application is a fully functional, production-ready CQRS application.
It features an HTTP server powered by flux, and an interactive terminal UI (TUI) client built with Bubble Tea.
What it demonstrates
This application is designed to teach you how to build a real-world system using the standard flux project layout.
- Strict CQRS: The Write models (Aggregates) and Read models (Projections) are completely separated.
- HTTP API: How to expose the
flux.CommandBusandflux.QueryBusover REST endpoints. - Real-Time Projections: How to listen to the
flux.EventBusand update an SQLite or in-memory Read Model. - Server-Sent Events (SSE): How the server broadcasts Domain Events in real-time to connected clients.
- Interactive UI: A beautiful terminal client that reacts instantly to state changes.
Running the Example
This example requires you to run both a server and a client.
1. Start the Server:
bash
cd example/todo
go run ./cmd/server2. Start the Interactive CLI Client: Open a new terminal window:
bash
cd example/todo
go run ./cmd/todoSource Code Highlights
Take a deep dive into the example/todo/internal/todo package to see the architecture in action:
aggregates/: Look atlist.goto see how Todo lists manage their own state and emitTaskAddedorTaskCompletedevents.projections/: Look atstats/projector.goto see how the system builds a blazing-fast global Read Model (tracking total active vs archived tasks) by listening to events across all lists!api/: See how HTTP routes are bound directly to thecommandBusandqueryBus.
