Skip to content
All work

Case study

Streaming Ad Platform

An ad platform for a streaming service: it picks the ad for every ad break, counts every view exactly once, and bills what was delivered.

Role
Sole developer
Year
2026
Source
Public, MIT licence
events per second in the load test, none lost or counted twice
10,000
for a 90-day report over 9.9 million rows
0.5 s
to count a campaign's unique viewers for a day
12 KB
from a Redis outage to the alert email
97 s

01

Three parties, one ad break

Streaming services with an ad tier show short ads before, during and after episodes. The advertiser wants the ad seen by the right people for a set budget. The platform has to choose an ad for every break and keep each campaign on schedule. The viewer watches, and the player reports what happened.

I built the part in the middle, end to end: campaigns and teams, the ad decision, a real video player, event counting, analytics, billing and the operations around it. All brands, shows and traffic in the demo are fictional.

Stack

  • Node.js
  • TypeScript
  • React
  • PostgreSQL
  • Redis
  • Prisma
  • Docker
  • Grafana
  • Playwright

02

What I built

  • Ad decisions

    For each ad break the platform keeps the campaigns that match the dates, schedule, limits, country, device, slot, genre and audience. Guaranteed campaigns that are behind go first, and the rest is sold in a second-price auction. Any VAST 4.2 player can ask for an ad.

  • From upload to playback

    A manager uploads a video, FFmpeg converts it in the background, an admin approves it, and the demo streaming site plays it before, during and after an episode.

  • Analytics and reports

    Live charts, reach and frequency, drop-off, A/B tests that only name a winner at 95% confidence, and saved reports emailed as CSV and PDF.

  • Prepaid billing

    A ledger that is never edited, holds for running budgets, invoices numbered with no gaps, EU VAT with VIES checks, currencies at the European Central Bank's daily rate and optional Stripe Checkout.

  • AI assistant

    Optional and off by default. It answers questions such as why a campaign is behind, using read-only tools, and suggests changes that only apply once a person approves them. It runs on a free local model or a paid API.

  • Operations

    Structured logs, metrics, traces and alerts in Grafana, and daily backups that are restored into a scratch database to prove they work.

03

How an event is counted

  1. 1

    Player

    • Plays the ad
    • Reports each event with a unique ID
  2. 2

    API

    • A Redis script drops IDs already seen
    • Queues the rest in the same atomic step
  3. 3

    Worker

    • Adds events into hourly totals
    • Saves the totals and the queue entry's ID together
  4. 4

    Dashboard

    • One SQL query per view
    • Live charts and reports

A retry can't count twice, and a crash can't lose or repeat an event.

04

The hard parts

  1. 01

    Limits that hold when requests race

    Budgets, goals and frequency caps are reserved in the same atomic Redis step that picks the ad, not checked afterwards. A campaign can't pass its goal, however many requests arrive at once.

  2. 02

    Counting exactly once

    An entry stays on the queue until its totals are saved, and its ID is saved in the same transaction. The load test included a worker crash, and no event was lost or counted twice.

  3. 03

    Fast reports without a data warehouse

    Events are added into one row per campaign, hour, show, slot, country and device, so the table grows with variety, not with traffic. Unique viewers are counted in HyperLogLog sketches.

05

Screens

  • The demo streaming site playing an ad, with the events the player reports
    The demo streaming site playing an ad, with the events the player reports
  • The delivery check explains why a campaign is behind, with no AI
    The delivery check explains why a campaign is behind, with no AI
  • Platform health in Grafana, through a Redis outage and recovery
    Platform health in Grafana, through a Redis outage and recovery
  • The campaign form with its live forecast
    The campaign form with its live forecast

Next case study

CareerCraft

Want to talk about a project like this?

Get in touch

Navigate

About
Experience
Focus
Work
Contact

Case studies

Enterprise Management System
Streaming Ad Platform
CareerCraft

Actions

Toggle light / dark theme
Auf Deutsch wechseln
Copy email address
View resume
Download resume

Links

GitHub
LinkedIn
Xing
↵select↑↓navigateEscclose