Jamie Software Lab
Projects / Live Chat Room
Python Flask Socket.IO WebSockets

Live Chat Room

A real-time chat room powered by Socket.IO with automatic HTTP polling fallback. No account needed : pick a name, start talking. Messages broadcast instantly to everyone connected.

Status Active
Transport WebSocket + polling
History Last 200 messages
Auth None (anonymous)

Live Demo

Open this page in two tabs to see real-time sync.

What it solves

Clear outcomes, no marketing language.

  • Demonstrates bidirectional real-time communication : not just polling.
  • Socket.IO upgrades to WebSocket when available, degrades to HTTP long-polling when it can't.
  • In-memory message store means zero database overhead : the server restarts clean.

How it works

Real-time message flow, server to screen.

Client connects
Socket.IO client opens a WebSocket to the Flask backend. Falls back to HTTP polling if WS fails.
User sends message
Message emitted via socket (or POST /api/chat/send as fallback). Server validates and stores.
Server broadcasts
Socket.IO emits the message to all connected clients simultaneously. Polling clients fetch on interval.
UI updates
New messages appended to the chat window. Online user count and nicknames refresh every heartbeat.

Decisions

The tradeoffs that shape this system.

Socket.IO with polling fallback

Socket.IO negotiates the best transport automatically: WebSocket in modern browsers, HTTP long-polling behind restrictive proxies. The backend also exposes REST endpoints so any HTTP client can participate without a WS library.

In-memory, not persistent

Messages live in a Python list, capped at 200. No database, no cleanup jobs. A restart wipes history : acceptable for a demo, and it means zero ops burden.

Anonymous by design

No auth : just a nickname. Keeps the friction to zero for portfolio visitors. Heartbeat-based presence tracking auto-removes stale users after 30 seconds.

Next steps

Planned improvements, kept realistic.

  • Chat rooms / channels with separate namespaces.
  • Typing indicators and read receipts.
  • Persistent message history with SQLite (opt-in).
  • Rate limiting per-user to prevent spam.