Ankit Sinha · Backend EngineerCase Study 02 · KonnectIssue No. 01 · 27 SEP 2026

Ankit Sinha



Selected Work · Microservices

Konnect

Real-time chat across six services. A real-time chat platform across six microservices behind Traefik, with a Socket.IO gateway and an event-driven backbone on RabbitMQ and Kafka feeding an AI moderation pipeline.

NEXT.JS · NODE.JS · EXPRESS · MONGODB · REDIS · RABBITMQ · KAFKA · PYTHON · DOCKER

Filed September 2025 · github.com/AnkitSinha0 ↗

# general6 services · live

  1. riaanyone up for the 9pm game?delivered
  2. devcount me in, bringing snacksdelivered
  3. anon_42██████ ██ ████held · pattern
  4. rialol you're so bad at thisflag · no action
Fig. 2 — A single rough message is flagged but not acted on; a pattern is held for review. Illustration of the moderation pipeline.

Overview

Konnect is a real-time chat platform split across six microservices: a Next.js frontend, a Socket.IO WebSocket gateway, and backend services behind a Traefik reverse proxy that routes by host rule.

Services communicate through events rather than calling each other, and every chat message passes through an AI moderation pipeline before it can harm anyone.

The Problem

Chat is fan-out heavy and latency-sensitive, and a single slow dependency can stall every conversation if services call each other synchronously.

Moderation has the opposite failure mode: judging each message alone produces false positives that punish ordinary banter.

Architecture · Full BlueprintPlate II

Konnect — Details & Assemblies

Six services · Sheet K-02 · Rev 0
Fig. 1 — Gateway
SOCKET.IO

Persistent duplex channel; one connection per client.

Fig. 2 — Proxy
TRAEFIK

Routes by host rule to six upstream services.

Fig. 3 — Topic
3 PARTITIONS

Ordered within a partition; consumers read by offset.

Fig. 4 — Window
SLIDING · REDIS

Judges a pattern of messages, never one alone.

Fig. 5 — Dual Token
ACCESSREFRESHRS256 SIGNATURE

Private key signs; every service verifies with the public half.

Fig. 6 — Handshake
AUTH + STATECODEEXCHANGE

State token held in Redis; CSRF cannot forge the return.

Fig. 7 — Moderation
FLAGREVIEW

Suppresses false positives before a human ever sees them.

Fig. 8 — Service Plan
6 SERVICES

Each owns its data; none reaches into another’s store.

Drawn by A. SinhaScale N.T.S.Sept 2025Sheet K-02

Key Features

WebSocket gateway
A persistent duplex Socket.IO channel, one connection per client.
Dual-token auth
JWT RS256 access and refresh tokens: a private key signs, every service verifies with the public half.
OTP & OAuth
Email OTP verification plus Google and GitHub OAuth 2.0 with CSRF-protected state.
Event backbone
RabbitMQ and Apache Kafka decouple services; chat events route through topic-based consumers.
AI moderation
RoBERTa and Toxic-BERT classify messages behind a Flask inference server.
Sliding-window judgement
Redis aggregates flags over a sliding window, so the system judges a pattern of messages, never one alone.

Technical Decisions

01Events over RPC
Services own their data and publish what happened; none reaches into another's store.
02RS256 over HS256
With six services verifying tokens, asymmetric keys mean only the auth service can mint them.
03Kafka for ordered streams
Ordered within a partition, consumers read by offset — the moderation pipeline can replay history.
04Aggregate before acting
A sliding window in Redis suppresses one-off false positives before a human ever sees them.

Reliability

  • A slow consumer no longer blocks the chat path; messages queue instead of timing out.
  • Traefik isolates routing from services, so a service can restart without clients reconnecting elsewhere.

Lessons

Event-driven design moves complexity rather than removing it: ordering, idempotency and replay become explicit design questions.

Moderation accuracy came less from the model than from the aggregation around it.