Rebuild a retailer's inventory and reservation service as an event-sourced Go system: commands over gRPC and a REST facade, events on NATS JetStream appended with an expected sequence, PostgreSQL read models built exactly once by a projector with a watermark, rebuilds from sequence one, a dead-letter stream, a projection-driven expiry process, event upcasting with a breaking-change gate, one trace per command across two processes, and a k6 flash sale that measures what the guarantee costs. Seven containers run on your Docker host.
Backend Engineer. Advanced.
Halden Supply's inventory service is a table with a quantity column, and every complaint in the brief is a consequence of that one design: two channels read the same row and both write it back a moment apart, so a flash sale oversells; a reservation is a row nobody remembers to delete; three reports compute stock three ways and the table cannot say which is right; the only history is whatever the application logged. You will replace the row with a history and derive everythin
Every complaint in the brief is a question about state: who changed it, whether two changes collided, which copy is right, what an old record means to new code. The service answers them with one decision: the truth is the ordered history of events, and everything else, the stock level a customer sees, the open reservations the expiry worker reads, the report finance runs, is derived from it and can be derived again. This lesson shows the whole service first and then each path
The brief's first complaint is that flash sales oversell. With a quantity column the rule "never promise what you do not have" lives in whatever code happens to update the column, and two updates a moment apart each see enough stock. This lesson puts the rule in one place, the stock item aggregate, and makes its state a result of its history rather than a row somebody updates.
Head office's oversell is a race: two channels load the same stock, both decide there is enough, both write. An aggregate alone does not fix that; two instances of the aggregate loaded a moment apart make the same decision. The fix is where the event is appended. This lesson builds the event store on NATS JetStream: one stream, one subject per item, an append that names the sequence it expects, and two layers that recognise a command sent twice.
Channels will call this service thousands of times a minute from code written by other teams. They need a contract they can generate a client from, status codes they can act on without parsing messages, a way to retry safely, and a bound on how long a call can take. This lesson builds the command API over gRPC, with a REST facade for tools and browsers, and the interceptors that give every call an id, a deadline, a span, a metric and a log line.
The brief's third complaint is that three reports disagree. Each was computed by different code from the same table at different moments, and none could be checked. In this service every report is a projection of the same events, maintained by one process in one transaction per event, and a query reads a table that says which sequence last changed it. This lesson builds the projector and the query side.
Two things go wrong with projections in production: the code that builds them has a bug and the tables are wrong, or an event arrives that the code cannot apply and everything behind it waits. The first has a clean answer when the truth is the stream: derive the tables again. The second needs a policy: how many times to try, and where a bad event goes so the rest can continue. This lesson builds both.
The brief's second complaint is that reservations nobody confirmed hold stock for days. A row with a deadline column needs something to act on the deadline, and in the old service nothing did. This lesson adds that something: a worker that reads due reservations from a projection and releases them, built so that a restart, a lagging projection or a second copy of the worker cannot release a reservation twice.
The brief's fourth complaint is that a field added to an event broke the marketplace consumer for an afternoon. Events are stored for ever and read by code written later; the shape of a stored event and the shape new code expects drift apart unless something holds them together. This lesson does two things: it converts old events to the current shape on read, and it refuses contract changes that would make old events unreadable before they are merged.
The brief's last complaint is that "what happened to SKU 4471 yesterday?" takes a database export. The history read model answers that now, but operators ask a different question at three in the morning: why is this reservation slow, and is the projection behind? This lesson follows one command's trace across two processes, reads the service's metrics, and then loads the service with a flash sale to measure what the guarantee against overselling costs.
This runbook is the lab in order. Every step names where it runs, the working directory and the result you should see; the practical guide's six milestones link into these sections. Every command is a make target run from source/, and every target wraps one Docker command, so make help lists them all and the Makefile shows what each one does.
An event-sourced service fails in ways a CRUD service does not: conflicts that are correct behaviour, retries that create duplicates when a client drops an id, read models that are behind rather than wrong, a projector that stops on one bad event, a rebuild that disagrees with what it replaces. The evidence is better too: the history says what happened, the watermark says how far the projection got, the counters say which outcome each command had. This lesson teaches how to r
Interviewers who ask about event sourcing are rarely testing whether you know the words. They are testing whether you can say why a design was chosen, what it costs, and what observation would make you change it. The twenty-four questions in this project are built from its actual decisions, each with a model answer that names a file, a metric or a make target and a follow-up that changes a constraint.
The lab created containers, a network, two volumes, two project images, six pulled images, a generated .env and an evidence/ directory. This page removes them in order and then checks that nothing is left.
Finish with seven containers up, the gRPC health check serving, the INVENTORY stream created and empty, and the read-model tables present and empty.
Finish with fifteen seeded items, one reservation confirmed and one released, one duplicate command recognised, one refusal, one race with its conflicts resolved, and read models that match the stream.
Finish with the read models rebuilt from sequence one into a fresh schema that equals the live one, the rebuild's duration and event count noted, and one message in the dead-letter stream while the projector keeps working.
Finish with three short reservations released exactly once across a worker restart, a version 1 event readable through the current code, and the breaking-change gate refusing the planted change while accepting the real contract.
Finish with one trace followed from the interceptor through the append into the projector, the service's metrics read, two drill summaries in which confirmed units never exceed stock, and the rebuild and load durations compared at the larger history.
Finish with no container, network, volume or image of the project on your machine and no generated file under source/.
Learning Access: INR 199 plus 18% GST. Source Pack: INR 399 plus 18% GST. 90 days of online access. No auto-renewal.
The lab runs on your own machine: local CPU, memory and disk, the pinned Go builder image and the pinned NATS, PostgreSQL, Jaeger, Prometheus, k6 and buf images, about 3.5 GB in all. The warehouses, channels, reservations and the flash sale are synthetic and produced by the pack's own tools; no cloud account, real data or paid service is used. Remove the Compose project, its volumes and images and the generated settings with the cleanup procedure when you finish. This is a learning reference, not a hosted service.
Vectametric Project Source Licence (2026-09-27): lawfully obtained source may be copied, modified and deployed for personal learning and interview preparation, including personal portfolio demonstrations with attribution. These permissions continue after online access expires. Do not resell or redistribute the Source Pack or its original source files, unchanged or modified. Commercial or client production use requires separate written permission. Third-party components retain their own licences. See LICENSE.txt and the Project Source Licence section of the site Terms for the full rules.
You can read the project material without deploying it. Running a cloud build requires the accounts, permissions and tools listed in that project's prerequisites. Deployment runs in your environment, not in a hosted Vectametric lab.
Yes. Learning Access includes the online source-file browser and explanations. The Source Pack adds the downloadable reference repository where available. The project's licence governs use of the source.
No. Cloud and CI usage are separate. Read the project's cost notice, set a budget and stop deadline, and follow its destruction and leftover-resource checks.
The project curriculum lists the available scenarios and interview topics. These focus on understanding the architecture and explaining decisions; they are not a promise of particular interview questions or a job.
The project page and checkout show the online access period for your selected plan. Access does not auto-renew. Downloaded source remains subject to its licence; future releases are not automatically included.
Review the Terms and No-Refund Policy before confirming access. All sales are final; Vectametric does not offer refunds.
Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy