Back to home

Project 05 of 06

Nebula Chat

Production-grade real-time chat application

TypeScriptNode.jsExpressSocket.IOTypeORMPostgreSQLRedisReactZustandTailwind CSSDockerZod
schema tables
8
schema tables
minute access tokens
15
minute access tokens
deployed services
5
deployed services
auth flows
2
auth flows

Architecture

4 stages
nebula-chatsignal flow
React UIExpress + Socket.IOTypeORMPostgreSQL & Redis
Readout

Production-grade real-time chat application

Overview

1 min read

Nebula Chat is a full-stack, production-deployed chat platform combining passwordless OTP login, Google OAuth 2.0, one-to-one and group messaging, typing indicators, online presence, and unread badges, built end-to-end under a strict clean architecture. Authentication supports two flows: passwordless OTP email login, and Google OAuth 2.0 with server-side audience validation.

Both issue short-lived JWT access tokens (15 minutes, held in memory only) paired with httpOnly 7-day refresh cookies, with full token rotation on every refresh. Real-time messaging runs on a Socket.IO engine delivering typing indicators, online presence, unread badge counts, and read receipts, all synced across multi-device sessions through a JWT-authenticated singleton SocketManager.

The data layer is a 3NF-normalized PostgreSQL schema across eight tables, with composite primary keys on junction tables, soft-delete participant tracking via a leftAt column, and Redis pub/sub for scalable event broadcasting across server instances. The backend enforces a strict three-layer clean architecture end-to-end: controllers route only, services own all business logic, and repositories handle all data access, with Zod schemas validating every API boundary and typed HttpException subclasses caught by a single global error middleware.

The platform runs as a live production stack: React and Vite on Vercel, Express and Socket.IO on Render, Neon serverless PostgreSQL, Upstash serverless Redis, and Resend for transactional email, with a Docker Compose setup mirroring the same topology for local development.

Highlights

5 items

  1. 01Dual auth flows: passwordless OTP email login and Google OAuth 2.0 with server-side audience validation, JWT access tokens (15 min, in-memory) paired with httpOnly 7-day refresh cookies and full token rotation on every refresh
  2. 02Socket.IO real-time engine with typing indicators, online presence, unread badge counts, and read receipts, all synced across multi-device sessions via a JWT-authenticated singleton SocketManager
  3. 033NF-normalized PostgreSQL schema across 8 tables with composite PKs on junction tables, soft-delete participant tracking (leftAt), and Redis pub/sub for scalable event broadcasting
  4. 04Three-layer clean architecture enforced end-to-end: controllers route only, services own all business logic, repositories handle all data access, with Zod schemas validating every API boundary and typed HttpException subclasses caught by a single global error middleware
  5. 05Deployed stack: React and Vite on Vercel, Express and Socket.IO on Render, Neon serverless PostgreSQL, Upstash serverless Redis, and Resend for transactional email, with Docker Compose for local parity