A per-user Server-Sent-Events notification stream with proxy-safe heartbeats, Last-Event-ID reconnection replay, and multi-instance Redis fan-out.
Nobody has started this yet — be first.
No published tickets in this project yet.
About this project
A per-user notification stream over Server-Sent Events instead of WebSockets, built around three things that make it production-shaped rather than a toy while True: yield: proxy-safe heartbeats (a : heartbeat\n\n comment line on a fixed interval, so idle-connection timeouts on load balancers and reverse proxies between browser and app never fire), Last-Event-ID reconnection replay (every event carries a monotonic id; on reconnect the server replays everything the client missed from a short-retention Redis Stream before resuming live delivery), and multi-instance fan-out (notifications publish to a per-user Redis pub/sub channel, so whichever app instance currently holds that user's live connection forwards it, working behind a load balancer fronting N instances/workers).
Two Redis primitives back one user's feed, both keyed by : a Stream () as the durable backlog, ed by and read by reconnection replay via ; and a pub/sub channel () for live fan-out, ed alongside the same write. subscribes to the channel reading the backlog specifically to close the race window between the two -- anything published in that gap lands on both paths, and one id comparison drops the resulting duplicate instead of re-sending it.
Clone it
$git clone https://github.com/nishant1821/FastAPIDevTraining.gitHow to run it locally, step by step.
user_idsse:stream:{user_id}XADDPOST /notificationsXRANGEsse:channel:{user_id}PUBLISHevent_stream()Fifteen practice tickets sit against this codebase, ordered easy to hard. Nine are real injected bugs: an inverted health check that reports "ok" during a Redis outage, a missing SSE blank-line terminator, an off-by-one that silently drops the first character of every bearer-token user id, a >= that lets an exact Last-Event-ID match through as a duplicate, a pub/sub message key that drifted out of sync with the field name the live-delivery code reads it back under, a leaked Redis connection on a subscribe failure, and others. Six are small missing features: per-event-type metrics, a multi-user broadcast endpoint, a per-user connection cap, and a capstone that wires graceful shutdown through every open stream. Each ticket has its own dedicated, currently-failing pytest test -- and one bug (a spurious heartbeat emitted on every fresh connection) is severe enough to also break four tests in the project's own tests/ suite until it's fixed, a documented, deliberate lesson in how one bug that happens to run first in a request path can mask others sitting right behind it.