Threadroute - Live Conversation Routing for a Contact Centre
A working model of a contact centre backend on live data: seven Go services read the public Bluesky stream through Kafka, turn replies into customer conversations, and route them to operators by language, load and dedicated teams. A React console shows it all in real time.
Overview
Threadroute is a pet project that answers one question: how do you route a large number of live conversations to a limited number of operators, and keep the whole thing correct when parts of it restart?
A real contact centre has no public data, so the project uses the public Bluesky post stream instead. An account that gets replies from many different people is treated as a "company". Each person who replies to it is a "customer", and their replies form one conversation. The system routes these conversations to operators the way a contact centre routes chats.
The operators are simulated, so the queues, the waiting times and the missed targets describe the simulator and its settings, not real people.
What It Does
Key Features
- Reads 65 to 140 events per second from Bluesky and opens about 300,000 conversations a day
- Puts each conversation into a queue by language and offers it to an operator with that language and a free slot; the operator has 20 seconds to accept
- Keeps a conversation with its previous operator when the customer writes again
- Gives a busy company a dedicated team from the shared pool, sized by its load, and takes the team back after 15 minutes of low load
- Measures two service targets for every conversation: 60 seconds to assignment and 120 seconds to the first reply; a miss raises the priority
- Runs 200 simulated operators with shifts, realistic handling times and a small share of missed offers
- Lets a person take a seat as an operator and work next to the simulated ones

How It Works
The pipeline is a chain of small services. Each one reads a Kafka topic, does one job, and writes the next topic.
The Pipeline
- ingest: reads the Bluesky Jetstream through the official SDK with failover between two hosts, and stores its position only after Kafka has confirmed the batch, so a restart repeats a few seconds and never skips
- normalize: turns source events into a channel-neutral model, removes duplicates, and writes its output and its offsets in one Kafka transaction
- conv: decides which accounts are busy enough to serve, and keeps open conversations in Redis with their messages, sessions and close deadlines
- router: keeps queues, assignments and service targets in PostgreSQL, and picks an operator in one transaction with FOR UPDATE SKIP LOCKED
- sim: plays the operators against the same HTTP API that the console uses for people
- gateway: builds its view only from Kafka topics and pushes changes to browsers over WebSocket, at most every 250 ms
Every state change of the router goes into an outbox table in the same transaction and is published in order, so a crash between the database and Kafka does not lose an event or send it twice. Message text never enters the routing topics. The gateway reads it from Redis only for a screen that is allowed to show it.

The Console
The console is a React app with three screens: a public page with totals, an operator desk, and a supervisor view with queues, teams, operators and every open conversation. The browser gets the current state when it connects and then only the rows that changed.

A supervisor can change the routing settings while the system runs: the load that forms a team, team sizes, the share of operators that teams may hold, and the numbers of the simulator. The settings live in PostgreSQL with a version and a change log.
In the video the share of operators in teams goes from 50% to 20%. The router picked the change up at its next team check, 9.6 seconds later: it released 18 of 23 teams, and the operators in teams went from 86 to 34. The teams of the busiest accounts stayed.
Numbers From a Live Run
The whole stand ran for more than two days on one AWS server with 2 CPU cores and 8 GB of memory.
Measured
- About 300,000 conversations a day from around 3,000 accounts, with a clear daily cycle
- 0 broken invariants in more than 1,200 checks, one per minute: one live assignment per conversation, operator load within capacity, no conversation held by an offline operator
- Normal delay from Bluesky to Kafka: 0.15 seconds, with short peaks of 10 to 20 seconds in the busiest hours
- At the evening peak 20,000 new conversations an hour arrive, and 200 operators resolve about 6,000, so the queue grows to 8,000 to 9,000 and falls back by morning
- The tight resource is PostgreSQL at about 90% of one core during the peak; most Go services use 15 to 60 MB of memory, the gateway up to 110 MB
Tests
The Go services have unit tests and integration tests that run against real Kafka, Redis and PostgreSQL in Testcontainers. The console has 471 unit tests and 56 end-to-end tests in Playwright. The 14 architecture decisions are written down in the repository, each with the options that were not chosen.
Privacy
The posts are public, but they belong to their authors. The public page shows totals only. The demo level of the console hides post text and replaces account IDs with pseudonyms that change every day. Text is visible only at the full level, for signed-in users on the owner's list. When an author deletes a post, the text is removed from Redis and from the screens that show it. Nothing is ever posted back to Bluesky.
Lessons Learned
- Real data finds what a generator does not - the daily cycle, the language skew (English is about 90% of the queue) and the bursts showed where the queue grows and which service is the bottleneck.
- Run it live and check the invariants all the time - live runs found defects that the unit tests had missed, for example operators that changed their language after a restart of the simulator.
- Decide before you code - each architecture decision was written as a short record with options first. Changing a decision later was cheap, because the reasons were on paper.
- A limit needs a rule for the moment it is lowered - a cap that only stops growth showed no effect for more than an hour at high load, so a lowered cap now asks for one trim.