Real-time WebSocket-based Chat Application
Chatty is a lightweight real-time chat platform built with Express and WebSocket (ws). It implements real-time bidirectional communication with minimal dependencies and provides an extensible architecture for future enterprise-grade collaboration tools.
- Real-time: Low-latency messaging with WebSocket
- Scalability: Modular structure for easy feature additions
- Simplicity: Minimal external framework dependencies
- Productivity: Fast prototyping and deployment
- Node.js 14.x or higher
- pnpm 6.x or higher
# Install pnpm if not already installed
npm install -g pnpm
# Install project dependencies
pnpm installpnpm startThe server runs on http://localhost:3001 by default. You can change the port using the PORT environment variable.
PORT=3000 pnpm startsimple-chat/
βββ server/
β βββ index.js # Express + WebSocket server
β βββ roomManager.js # Room management logic
β βββ messageModel.js # SQLite message persistence
β βββ messages.db # SQLite database file (auto-generated)
βββ public/
β βββ index.html # Client UI
β βββ styles.css # Stylesheets
β βββ app.js # Client logic
βββ .github/
β βββ ISSUE_TEMPLATE/ # Issue templates
βββ .agent/
β βββ rules/
β βββ code-style-guide.md
βββ LICENSE # MIT License
βββ package.json
Backend
- Express 5.2.1 - HTTP server
- ws 8.18.3 - WebSocket server
- better-sqlite3 11.10.0 - SQLite database for message persistence
- Node.js - Runtime environment
Frontend
- Vanilla JavaScript
- CSS3 - Modern styling (Grid, Flexbox, Animations)
- WebSocket API - Real-time communication
Development Tools
- pnpm - Fast and efficient package manager
-
Message Persistence β¨
- SQLite database integration
- Automatic message saving on send
- Message history retrieval on room join
- Pagination support (50 messages per load)
- Infinite scroll for loading older messages
- Offline message synchronization
- LocalStorage-based timestamp tracking
-
Multi-Room Chat System
- Create custom chat rooms
- Join and switch between rooms
- Room list with user counts
- General room auto-created on server start
- Room-based message isolation
-
User Management
- Nickname-based authentication
- Duplicate nickname prevention
- Real-time user list per room
-
Messaging
- Real-time message send/receive
- Room-based broadcasting
- Timestamp display
- XSS prevention (HTML escaping)
-
User Experience
- Responsive design (Mobile/Desktop)
- Room creation modal
- Active room highlighting
- Enter key support
- Auto-scroll
- Join/Leave notifications
- Error handling and user feedback
This application is optimized for deployment on Render.
- Push your code to GitHub
- Connect your repository to Render
- Configure:
- Build Command:
pnpm install - Start Command:
pnpm start
- Build Command:
- Deploy
For detailed deployment instructions, see Render Deployment Guide.
See Code Style Guide for detailed coding conventions.
Key Rules
- Package manager:
pnpmrequired - Indentation: 2 spaces
- Variables:
constpreferred,letwhen needed - Naming: camelCase (functions/variables), PascalCase (classes)
- Error handling: Explicit try-catch
# Start development server
pnpm start
# Test with multiple browser tabs
# http://localhost:3001MIT License - see LICENSE file for details
Issues and PRs are welcome. Please check the Code Style Guide before contributing.
Chatty - An extensible chat platform for real-time collaboration