Case study: personal project, December 2026
Media asset tracker
A scaled-down version of the work behind a media platform: get a clip in, prove it is ready, send it out, and know when something is stuck. Two services with Kafka between them, and a runbook I test by breaking the system on purpose on every push.
- Automated tests on every push, run against a real PostgreSQL and Kafka
- 84
- Automated tests on every push, run against a real PostgreSQL and Kafka
- Alerts, each unit-tested and linked to its section of the on-call runbook
- 5
- Alerts, each unit-tested and linked to its section of the on-call runbook
- Outage drills in CI: Kafka down, then a destination down
- 2
- Outage drills in CI: Kafka down, then a destination down
- My role
- Solo: design, code, tests, CI and the runbook
- When
- December 2026, in six milestones
- Stack
- Java 21, Kotlin 2, Spring Boot 4, PostgreSQL 17, Kafka 4, Docker
01
What it does
The tracker follows sports highlight clips from the moment they arrive to the moment they publish. A Spring Boot API in Java stores each clip in PostgreSQL and moves it through a fixed set of states. It refuses moves that make no sense, like publishing a clip that never finished processing, and answers with a 409 that names the clip's status and the moves it allows.
Every status change goes out as a Kafka event. A second service, written in Kotlin, reads those events and sends each published clip to its destinations: web, mobile and social. All the clips are made-up sample data, and the sends are simulated.
| From | Can move to |
|---|---|
| received | processing, failed |
| processing | ready, failed |
| ready | published, failed |
| failed | received (a retry) |
| published | nothing, it is final |
A move to failed has to give a reason. Try the status rules on the home page.
02
Decisions that mattered
Each one came with a cost. Here is what I chose, and what I gave up for it.
Save the event with the change
Sending to Kafka inside the request would tie the API to Kafka: if Kafka is down, nobody can move a clip, and a change that rolls back could still send its event. So the status change, its history row and an outbox row are saved in one database transaction. A background relay sends unsent rows to Kafka, oldest first, and marks each one sent once Kafka acknowledges it.
The trade-off: delivery is at least once, so a consumer can see an event twice and has to skip it. The relay also stops at the first failed send, so a clip's events never arrive out of order. One stuck event holds the rest, which is why the outbox has its own health check and alert.
Keep the two services apart
The services never call each other and never share a database. Kafka is the only link, so either one can be down or redeployed without the other noticing. Every event is keyed by the clip's id, so all of a clip's events land on the same partition and arrive in order.
The trade-off: more moving parts, and no joining one service's data to the other's. Each service owns its schema through its own Flyway migrations.
Retry briefly, then set it aside
The Kotlin service skips any event it has already handled, so a duplicate never sends a clip twice. When a destination fails, it retries after 1, 2 and 4 seconds, and skips destinations that already have the clip. If one still fails, the event goes to a dead-letter topic with the error in its headers, and the service moves on. An event it cannot read goes there straight away.
The trade-off: a dead-lettered clip waits for a person. A replay script puts it back once the cause is fixed, and it is safe to run twice.
Build it for whoever is on call
Both services report liveness and readiness, publish Prometheus metrics and log one JSON object per line. Lines about a clip carry its id and its event id, so one command pulls out everything that happened to one clip. The outbox check turns DOWN when an event has waited more than two minutes to reach Kafka.
Five alerts cover a service going down, a stuck outbox, growing dead letters, failing deliveries and consumer lag. Each links to a runbook section that says what it means, what to check and how to fix it.
03
How I tested it
The tests talk to a real PostgreSQL and Kafka, not mocks. GitHub Actions runs four jobs on every push, and the last one only runs once the others pass. Then it breaks the running system on purpose and checks it recovers the way the runbook says.
The Java API
64 tests against a real PostgreSQL, with a real Kafka broker started by Testcontainers.
The Kotlin service
20 tests against its own Kafka and PostgreSQL, also started by Testcontainers.
Monitoring
Checks the Prometheus config and tests that each alert fires when it should and stays quiet when it should.
The whole stack
Builds both images, starts everything with the same Compose file a reviewer would run, moves a clip, reads its events off the topic and checks a published clip reached all three destinations.
Two outages, on every push
Each drill checks what an on-call engineer would see, through the same health checks, metrics and scripts the runbook uses.
- Drill 1: Kafka goes down
- The API must keep taking clips and status changes, the events must wait in the outbox, and the failed sends must show up in the metrics. Then Kafka comes back, and every event and delivery has to go through.
- Drill 2: a destination goes down
- The social destination fails on purpose. The clip must still reach web and mobile, social must end in the dead-letter topic and the counter must move. Then social is fixed, the runbook replay runs, and the clip has to reach every destination.
04
Check my work
The whole stack needs only Docker. The repository's README walks through the API, the events and the dead-letter replay, and the runbook covers every alert. From the command line:
# both services, both databases and Kafka docker compose up --build # with the stack running: take Kafka and a destination down ./scripts/game-day.sh