Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat App

A real-time multi-room chat application built with a Python WebSocket backend and a vanilla JS frontend. No frameworks, no dependencies beyond the websockets library.

dark theme python license

image image image

Features

  • Real-time messaging over WebSockets — no polling
  • Multi-room support — join any named room, isolated from others
  • Typing indicators with debounce so they don't spam
  • Dark / light theme toggle, persisted in localStorage
  • Connection status dot with live feedback and a reconnect button on drop
  • Character counter (500 char limit enforced on both client and server)
  • Rate limiting — max 5 messages per second per client, handled server-side
  • Particle canvas on the welcome screen with mouse repulsion
  • Browser history API — back/forward navigation works between screens

Stack

Layer Tech
Backend Python 3, asyncio, websockets
Frontend Vanilla JS, HTML, CSS (no frameworks)
Transport WebSocket (ws://)

Getting Started

Requirements: Python 3.10+

# Install the dependency
pip install websockets

# Start the server
python server.py

Then open index.html in your browser. That's it.

By default the server runs on ws://localhost:8765. To change it, edit WS_URL at the top of the <script> block in index.html, and HOST/PORT in server.py.


Architecture

Browser (index.html)
    │
    │  WebSocket (ws://localhost:8765)
    ▼
server.py
    ├── rooms{}          # dict of room_name → set of (websocket, username)
    ├── client_activity  # per-client deque of timestamps for rate limiting
    └── broadcast()      # fans out a message to all clients in a room

Each client sends a join message on connect with a username and room name. After that, the server routes chat and typing messages to everyone else in the same room. Disconnects are caught in a finally block so the room always gets a leave notification.


Project Structure

├── index.html    # entire frontend — UI, WebSocket logic, canvas animation
├── server.py     # async WebSocket server
└── favicon.svg

License

MIT

About

Real-time multi-room chat with a Python WebSocket server and vanilla JS frontend

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages