A high-performance, real-time Twitch chat overlay for modern streaming.
Twitch Chat Visualizer is an enterprise-grade real-time chat overlay system designed for OBS, XSplit, and other broadcasting software. It listens to Twitch IRC channels and instantly renders chat messages, emotes, and user badges onto a highly customizable, transparent web overlay.
Originally built as a monolithic application, the project has been fully modernized into a scalable, type-safe monorepo. It resolves common pain points for streamers by ensuring ultra-low latency, eliminating memory leaks through intelligent connection pooling, and strictly sanitizing all inputs to prevent XSS vulnerabilities.
- Real-Time Rendering: Instantaneous chat delivery powered by WebSockets (Socket.IO).
- Customizable Overlay: Adjust fonts, background colors, and text colors dynamically via URL parameters.
- Resource Optimization: Centralized Twitch connection manager ensuring only one TMI client is spawned per channel, regardless of concurrent overlay viewers.
- Robust Security: Strict HTML sanitization to prevent XSS attacks from malicious chat messages.
- Emote & Badge Support: Native integration with Twitch, BTTV, and FFZ assets.
graph TD
subgraph "pnpm Monorepo"
Web[Frontend: React 19 + Vite]
API[Backend: NestJS + Fastify]
end
subgraph "External Services"
Redis[(Redis Cache)]
TwitchAPI[Twitch / BTTV / FFZ APIs]
TwitchChat[Twitch IRC / TMI]
end
Web <-->|WebSockets| API
API <-->|Fetch Assets| Redis
Redis <-->|Cache Miss| TwitchAPI
API <-->|Shared Singleton Connection| TwitchChat
This project leverages a modern, decoupled monorepo architecture using pnpm workspaces:
Frontend (apps/web)
- βοΈ React 19 & Vite - Lightning-fast UI rendering and build tooling.
- π» Zustand - Minimalist, flux-like state management.
- π¨ Tailwind CSS v4 - Utility-first styling engine.
Backend (apps/api)
- π¦ NestJS 11 (Fastify Adapter) - Progressive Node.js framework.
- π Socket.IO & tmi.js - Real-time bidirectional event-based communication and Twitch IRC integration.
- πΎ Redis - In-memory data structure store for caching API assets and socket adapters.
DevOps & Tooling
- π³ Docker & Docker Compose - Containerized local development and production deployments.
- ποΈ Pulumi - Infrastructure as Code (IaC) for AWS deployments.
- π§ͺ Vitest - Blazing fast unit test framework.
Ensure you have the following installed on your local machine:
- Node.js (v22 or higher)
- pnpm (v9+)
- Docker & Docker Compose
- A Twitch Developer App (for
TWITCH_CLIENT_IDandTWITCH_CLIENT_SECRET)
-
Clone the repository:
git clone https://github.com/your-username/twitch-chat-visualizer.git cd twitch-chat-visualizer -
Install dependencies:
pnpm install
-
Configure Environment Variables:
cp .env.example .env
Edit
.envand insert your Twitch Client ID and Secret. -
Start the Infrastructure (Redis):
pnpm services:up
To start both the frontend and backend simultaneously in watch mode:
pnpm dev- Frontend will be available at:
http://localhost:5173 - Backend API/Sockets will be available at:
http://localhost:3000
To compile the TypeScript code and build the React frontend:
pnpm buildTo run the entire stack using Docker in production mode:
docker compose up -dOnce the server is running, add a Browser Source in OBS Studio with the following URL structure:
http://localhost:5173/overlay/your_twitch_channel?namebackground=333333&namecolor=ffffff&messagebackground=ffffff&messagecolor=000000&fontsize=16
(Customize the query parameters to match your stream's branding)
twitch-chat-visualizer/
βββ apps/
β βββ api/ # NestJS Backend (WebSockets, Twitch TMI, Caching)
β βββ web/ # React 19 Frontend (Overlay UI, Zustand)
β βββ infra/ # Pulumi IaC configuration for AWS
βββ packages/
β βββ shared/ # Shared TypeScript interfaces & types
β βββ config-ts/ # Centralized TS & ESLint configurations
βββ docs/ # Additional documentation (API, Onboarding)
βββ .env.example # Environment variables template
βββ docker-compose.yaml # Local orchestration (Redis, API, Web)
βββ pnpm-workspace.yaml # Monorepo workspace configuration
βββ package.json # Root configuration and scripts
Based on current architectural goals, the following improvements are planned:
- Asset Caching: Implement aggressive Redis caching for Twitch, BTTV, and FFZ emotes to prevent external API rate limiting.
- E2E Testing: Introduce Playwright to establish robust end-to-end testing for the critical path of the OBS overlay rendering.
- Client-Side Routing: Migrate to TanStack Router on the frontend for fully type-safe, deterministic routing.
- Database Persistence: Integrate PostgreSQL via Drizzle ORM to persistently store and load user-specific overlay configurations.