Real-Time Baggage Tracking with Spring Boot, Kafka Streams and GraphQL

Rebuild a fictional airline's baggage tracking as an event-driven system on your own computer: Spring Boot services that take handheld scans into Kafka, a Kafka Streams tracker that stays correct when scans arrive late, out of order or twice and warns about missed connections in time, an idempotent PostgreSQL read model, and a GraphQL API with batching, pagination, subscriptions and per-caller authorization. Avro schemas evolve under a registry's rules, a simulator with an independent oracle checks every bag, and failure drills kill brokers and instances and replay history after a rules fix.

Backend Engineer. Advanced.

What you will build and explain

  • Design topics, keys and partitions so every event of one entity is processed in order by one instance, and configure producers and replication so an acknowledged event survives a broker failure and is written once.
  • Build a Kafka Streams topology with the Processor API, state stores, a GlobalKTable, repartitioning and aggregation, and keep it correct under late, out-of-order and duplicate events with state derived from history and deadlines on stream time.
  • Explain what exactly-once processing covers and where idempotence takes over, serve state with interactive queries routed to the owning instance, and keep answering through a failover.
  • Evolve Avro schemas under a BACKWARD compatibility rule, and fix a logic bug by reprocessing retained events into a corrected state and read model.
  • Build an idempotent read model with offset-versioned upserts, retries and a dead-letter topic, and a GraphQL API with DataLoader batching, keyset pagination, subscriptions, field-level authorization and query limits.
  • Test and operate the system with topology tests, Testcontainers, a whole-day simulation judged by an independent oracle, consumer lag, end-to-end latency, traces through Kafka headers and failure drills.

Before you begin

  • Reading and changing Java classes (records, interfaces, generics, lambdas, Optional, exceptions) and the basics of Spring Boot (a REST controller, dependency injection, application.yaml); Kafka, Kafka Streams, Avro, Spring for GraphQL and Testcontainers are taught from the beginning
  • Using a terminal and Docker Compose (starting containers, reading logs), HTTP and JSON with curl, and SQL including joins and INSERT ... ON CONFLICT
  • A Linux, macOS or Windows (WSL 2) computer with Docker and Docker Compose, 6 CPUs and 10 GB of memory for Docker, about 15 GB of free disk, openssl and a web browser; no Java or Maven installation is needed

Who this is for

For backend engineers who read and change Java and have built a Spring Boot service with a SQL database, and want to design and operate event-driven systems: Kafka topics and replication, a Kafka Streams processor that stays correct under late and duplicate events, an idempotent read model and a GraphQL API with subscriptions.

Curriculum

Learning topics (14)
  1. Check your starting skills and prepare your machine

    This project assumes you have built a small backend before and teaches the event-driven parts from the beginning. This page says exactly where that line is, so nothing later depends on knowledge you were never asked for, and it gets your machine ready.

  2. See how every scan counts once and every bag has one truth

    Skerry Air's old baggage tracker recomputed every bag's status from one table every five minutes. On the storm day it fell forty minutes behind, believed the last scan to arrive rather than the last thing to happen to a bag, double-counted a handheld's resent batch, and warned nobody about transfer bags until their connecting flights had gone. Meanwhile the passenger app's polling competed with the scanners for the same database.

  3. Key, partition and replicate events so none is lost or reordered

    The old tracker wrote scans into a database table and recomputed statuses from it on a timer. Two of its failures on the storm day came from that table. A table has no notion of the order things happened in, so the job believed whichever row it read last. And every reader, including the passenger app, competed with the scanners for it. This lesson replaces the table with a log, and shows the handful of decisions that make a log safe to build on: what to key events by, how man

  4. Let events change shape without breaking their readers

    Kafka stores bytes. It does not know that a scan has a bag tag or that a tag is ten digits, and it keeps records for days, long after the code that wrote them has changed. Two services that disagree about what the bytes mean fail at run time, often far from the change that caused it. This lesson gives every event a written contract, a schema, keeps every version of it in a schema registry, and lets the registry refuse a change that would break readers of records already writt

  5. Turn scans into state with a topology, state stores and standbys

    A scan on its own means little: "bag 0123456789 was loaded on SK204" only matters in light of the bag's routing, its earlier scans and the flight's cut-off. The tracker has to remember things between records, for millions of bags, without a database round trip per scan, and without losing that memory when an instance fails. Kafka Streams is a library, not a server, that does this inside an ordinary Java service. This lesson builds the tracker's topology piece by piece.

  6. Stay correct with late, out-of-order and duplicate scans, and silent deadlines

    On the storm day a handheld that had been offline for half an hour sent its batch, twice. Its scans arrived after scans that happened later, so the old tracker moved loaded bags back to "checked in" and counted unloads twice. And it warned nobody about transfer bags at risk, because it only ever looked at bags when a scan arrived, and the bags in trouble were exactly the ones whose next scan never came. This lesson makes the tracker correct whatever order scans arrive in, and

  7. Know what transactions guarantee and where idempotence takes over

    The tracker reads a scan, updates the bag's journey in its store, and writes the new state, perhaps an alert and some readiness deltas. Suppose the instance dies after writing the new state but before recording that it has read the scan. When the task restarts on another instance, it reads the scan again and writes the state again. The readiness deltas are added twice, and the counts are wrong for good. "At least once" is easy; this lesson is about the setting that turns the

  8. Answer from the state stores, also while an instance fails over

    A passenger opens the app and asks where their bag is. The freshest answer is in the tracker: its journeys store had the bag's new state a fraction of a second after the scan. The read model in PostgreSQL has it too, a little later. This lesson answers single-bag questions straight from the tracker's stores, with interactive queries, and shows what happens to those answers while an instance fails over, which is the part that is easy to get wrong.

  9. Project events into PostgreSQL idempotently, with dead letters and replays

    The tracker's stores answer "where is this bag" by key. They cannot answer "every bag on flight SK507, a page at a time" or "every open alert at the hub", which need secondary indexes and range queries. So the projector copies the tracker's output into PostgreSQL tables built for those questions: a read model. Copying sounds easy. The hard parts are the ones this lesson covers: a record may arrive twice or out of order, a record may be impossible to apply, the database may be

  10. Serve the right data with batching, pagination, subscriptions and limits

    Passengers want their bag. The hub's operations team wants a flight with its readiness and its bags, and the alerts at their station, each with the bag it concerns. With a REST API that is several endpoints and several round trips, or one endpoint per screen. With GraphQL the client asks for exactly the fields it needs in one request. That flexibility has a price this lesson pays explicitly: a careless resolver turns one request into hundreds of queries, a client can ask for

  11. Watch lag, end-to-end latency and one trace across three services

    On the storm day the old tracker was forty minutes behind and nobody knew until passengers complained. An event-driven system makes that easier to miss, not harder: each service can look healthy, answer its health check and log nothing alarming, while records pile up between them. This lesson sets up the three numbers that say whether the pipeline is healthy, and a trace that follows one scan through three services and two Kafka topics.

  12. Test from one rule to a whole day of bags with an independent oracle

    A streaming system resists ordinary testing. Its interesting behaviour depends on order, timing and failure: a scan arriving late, a deadline passing in silence, a broker dying mid-transaction. A test that sends one scan and checks one status passes while every one of those is broken. This lesson builds confidence in four layers, each catching what the one below cannot, and ends with the layer most projects skip: an independent judge of a whole day's outcome.

  13. Build the lab, run a day of bags, break it and prove it

    This runbook takes you from an empty machine to a running baggage-tracking system, through a simulated evening peak, a set of failure drills and two load tests, and back to an empty machine. Every step says where to run it, what it changes and how to tell that it worked. The cleanup page removes everything this runbook creates.

  14. Remove the lab and confirm nothing remains

    The lab lives entirely in Docker on your computer, plus two folders the runbook creates beside the source: secrets/ and reports/. Nothing was created in any cloud account. This page removes all of it and checks that nothing remains.

Practical build steps (11)
  1. Prepare your machine and build the lab

    Before anything runs, three things must be true: Docker has enough CPUs and memory for three Kafka brokers and the services, the lab's ports are free, and the lab has its own secrets. You check the first two, generate the secrets with one script, and build the single image every service runs from. The build compiles every module and runs every unit test inside a Maven container, so a broken change never becomes an image.

  2. Start the lab and take a first look

    One command starts three Kafka brokers, the schema registry, PostgreSQL, the four services and the monitoring tools, in the order their dependencies need: topics before schemas, schemas before services. You ask skerry for the state of every component and check that only seven loopback ports are published, the API, scan intake, Grafana, Prometheus, Jaeger, the registry and the first tracker, and nothing for Kafka or PostgreSQL.

  3. Run a service day and verify it

    The simulator plays an evening of flights through the hub: about 20,000 bags, their scans sent at the moment they happen through twenty handhelds, some late, some twice, some never. While it runs you watch the dashboard rise and fall with each bank of flights. When it ends, skerry verify judges every bag against an independent account of what should have happened.

  4. Ask the API

    With a day of bags processed, you ask the questions the API exists for: one bag from the tracker's state stores, a flight's bags a page at a time from the read model, and the same questions with a passenger token, which may see only its own booking. The answers say which source served them and whether it may be stale.

  5. Break a broker

    Kafka keeps three copies of every partition and accepts a write only when two have it. Here you test that promise: a broker is killed without warning in the middle of a busy simulation, and comes back ninety seconds later. The verification afterwards says whether a single scan was lost or counted twice.

  6. Stop a tracker instance

    The tracker keeps each bag's state on the instance that owns its partition, with a warm standby copy on the other. You kill one instance while a probe asks the API about the same bags four times a second, and read the probe's timeline: who answered while the group noticed, while the partitions moved, and after.

  7. Park poison records and change a schema

    Two drills about things that should never stop the pipeline. A record the projector can never apply must be set aside with its reason while the partition moves on. A schema change must be accepted only if readers of old records can still read them. You see both rules enforced.

  8. Fix the rules and reprocess

    The tracker first runs a version of its rules that ignores rebookings. Verification shows the damage: rebooked bags with the wrong routing and false misload alerts. You fix it the way a log-based design allows: reset the tracker to the start of its input, delete its derived state, deploy the corrected rules and let it rebuild every bag from the scans Kafka kept.

  9. Run the load tests

    Two k6 tests. The first pushes scan intake to a thousand scans a second and checks that every scan is accepted quickly. The second compares the two ways a passenger can follow their bag, polling and a subscription, on the same minutes of the same simulation: requests made, changes seen, and how long each change took to reach them.

  10. Run the tests

    The unit tests already ran inside every build. The integration tests need more: a real PostgreSQL, started in a container by Testcontainers, so the read model's SQL and the API's keyset pages are checked against the database that will run them.

  11. Remove the lab

    Everything the lab created lives in Docker and two folders beside the source. One script removes the containers, their volumes, the networks, the images and the generated secrets, and a few label checks confirm that nothing of the lab remains.

Access

Learning Access: INR 199 plus 18% GST. Source Pack: INR 399 plus 18% GST. 90 days of online access. No auto-renewal.

Cloud costs and boundaries

No cloud account, licence or spending is needed: Kafka, Apicurio Registry, PostgreSQL, the airline's Spring Boot services, Prometheus, Grafana, Jaeger, k6 and the simulator run as containers on your own computer, with synthetic data and generated credentials for a fictional airline. The first build downloads a few gigabytes of images and Maven dependencies, and the simulation and drills use most of the machine while they run. GitHub Actions is optional; it is free on public repositories and uses your account's included minutes on private ones. This is a learning lab, not a hosted environment, a certification or a production-readiness guarantee.

Licence and completion

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, such as Spring Boot, Apache Kafka, Apache Avro, Apicurio Registry, PostgreSQL, Flyway, picocli, Nimbus JOSE+JWT, Prometheus, Grafana, Jaeger, k6 and Testcontainers, retain their own licences. See LICENSE.txt and the Project Source Licence section of the site Terms for the full rules.

Questions about projects

Do I need a cloud account?

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.

Can I read the code with Learning Access?

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.

Are cloud charges included?

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.

Does the project include troubleshooting and interview preparation?

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.

How long can I use the project?

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.

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

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