Event sourcing and CQRS for course planning at TAFE NSW
Why we chose event sourcing and CQRS for TAFE NSW's state-wide course planning and costing platform: commands, events, read models, audit, replay and versioning, explained.
Between 2005 and 2015 we worked inside TAFE NSW. The biggest system from that time was a greenfield platform for planning and costing courses across the state, used by 300,000+ students and staff. It integrated with SAP finance and HR through a TIBCO enterprise service bus and signed people in through TAFE NSW Active Directory.
Underneath it sat two patterns we chose deliberately: event sourcing and CQRS (command query responsibility segregation). This post explains why we chose them and how they work, with course planning and finance as the example.
The problem: collaborative plans, money and a full history
Planning a course is not one person filling in one form. Head teachers, faculty directors and finance staff shape the same plan over weeks: units, teaching hours, delivery modes, enrolment targets, staffing and costs. The plan feeds budgets, and budgets get audited.
That gave us three requirements that pulled against a conventional "one table per thing, update in place" design:
- Collaboration. Many people change the same plan, and they need to see who changed what.
- A complete audit history. Finance needs to know not just what a plan says now, but how it got there and what it said on the day the budget was signed off.
- Fast reports. Summaries across faculties and institutes had to render extremely fast, even though they draw on a great many plans.
An update-in-place database throws history away on every save. You can bolt an audit table on afterwards, but then you have two sources of truth that can disagree. We wanted the history to be the data.
Architecture
We used domain-driven design for the core domain, so planners, finance and developers shared one unambiguous language. Then we split writing from reading.
planner / finance UI
| commands (intent) queries
v ^
command handlers -> course plan aggregate |
| validates, emits events |
v |
event store (append-only) --> projections --> read models (denormalised)
| cost summaries, faculty reports, plan views
+--> integration events --> service bus --> SAP finance and HR - Write side: commands go to aggregates, which check the business rules and record what happened as events.
- Event store: an append-only log of every event, in order, for every plan.
- Read side: projections turn events into read models shaped for each screen and report.
- Integration: events of interest are translated and published to the service bus for other Department systems.
The engineering, pattern by pattern
The pattern names are standard. The examples below are a simplified sketch of how they apply to course planning, not the production code.
Commands carry intent
A command is a request to change something, named for what the user means: AddUnitToPlan, ChangeDeliveryHours, SetEnrolmentTarget, SubmitPlanForApproval. It can be rejected. "Save course" tells you nothing. "Change delivery hours for this unit from 40 to 32" tells you exactly what the planner intended, and that intent is what finance wants to see later.
Aggregates guard the rules
An aggregate is the consistency boundary: here, one course plan. It loads its own history, checks a command against the rules, and either refuses it or emits events:
handle(ChangeDeliveryHours cmd):
plan = load_events(cmd.plan_id) |> replay # current state from history
require plan.status == Draft # approved plans are locked
require cmd.hours > 0
emit DeliveryHoursChanged(
plan_id, unit_id, from = plan.hours(unit_id), to = cmd.hours,
by = cmd.user, at = now, reason = cmd.reason)
append(plan_id, events, expected_version = plan.version) The expected_version is optimistic concurrency. If someone else changed the plan since it was loaded, the append fails and the user sees the newer plan instead of silently overwriting it. In a collaborative tool, that one check removes a whole class of lost-update bugs.
Events are facts
Events are named in the past tense and never change once written: UnitAddedToPlan, DeliveryHoursChanged, PlanSubmitted, PlanApproved. Each carries who, when and, where it matters, why.
Corrections are new events, not edits. That's how accountants have always worked: you don't rub out a ledger line, you post a reversal. Described that way, an event store makes sense to finance people quickly.
Projections and read models make reads fast
The write side is optimised for correctness, not for reports. So each report gets its own read model, a denormalised table built by a projection that listens to events and updates the totals:
- a plan view with everything the planning screen needs in one row set
- cost per course, per faculty and per institute, already summed
- hours and enrolment targets against budget
A report then becomes a simple read of a table that already has the answer. That's how CQRS met the "render extremely fast" requirement. The price is eventual consistency: a read model can lag a write by a moment.
Audit comes for free
Because state is derived from events, the audit history isn't a feature someone has to remember to maintain. "Who changed the hours on this unit, when, and from what?" is a query over events. "What did this plan look like on the day the budget was approved?" is a replay that stops at that date.
Replay and versioning
Replay is the quiet advantage. Need a new report next year? Write a new projection and replay every event from the beginning, and it's complete for all of history, not just from the day it shipped. Found a bug in a projection? Fix it, drop the read model and rebuild it.
History is permanent, so event schemas need care:
- Add, don't change. New optional fields are safe; renaming or reusing a field is not.
- Version event types, and upcast old versions to the current shape as they are read, so projection code handles one shape.
- Make projections idempotent and record their position in the log, so a restart or a rebuild never double-counts.
Integrating with finance systems
SAP and the other Department systems didn't need our internal events. They needed a small set of stable messages. We translated domain events into integration events at the boundary and published those to the service bus, which kept our model free to evolve without breaking the systems around it.
Where AI fits
There was no AI in this platform, and we won't pretend otherwise. But the pattern ages well into AI work. An event log is a clean, time-ordered record of decisions, which is exactly what forecasting and anomaly detection want as input. And when AI agents act on business systems today, we want the same properties: every action expressed as an explicit command, checked by rules, recorded as an event with who and why, and reversible by a later event, not an edit. Our MCP post covers the safety side of letting assistants act.
Leadership: running the build and growing people
We designed the solution architecture and wrote all of the architecture code ourselves: the event sourcing, the eventual consistency between the write and read sides, and the CQRS framework. We also led and managed the development. We also managed and mentored the Unisys team that worked on it. Event sourcing and CQRS were new to most of the developers, so a lot of the job was teaching:
- Shared language first. We worked through the planning domain with the people who do the planning, and the words they used became the names of commands, events and read models.
- Pairing on the first slices. The first commands, events and projections were built together, so the pattern was learned in real code, not in a slide deck.
- Making the trade-offs explicit. Eventual consistency, schema versioning and the cost of a second data model were discussed openly, so the team could defend them in reviews.
- Representing the work outward. We also represented TAFE NSW institutes on enterprise architecture to the Department, which kept the integration design aligned with the systems around it.
The same period produced a staff-development system we re-architected from VBScript and ASP into C# and ASP.NET. It received a state-wide TAFE NSW quality award, and every TAFE NSW institute adopted it. We opened up the code so institute developers could develop, debug and extend it themselves. Both projects taught the same thing: software lasts longer when the people around it understand it and can change it.
When not to use it
Event sourcing isn't free. It adds moving parts, needs care with schemas, and asks developers to think differently. For a simple form-and-list app with no audit needs, a normal database is better. We reach for it when history, collaboration and auditable money meet, as they did here.
Why it still matters
Government and enterprise clients still need systems where every change is on the record and reports are fast, and they still need teams who can look after those systems once we step back. That's the work behind our web and SaaS platforms and technical leadership. The TAFE NSW case study has the wider story.