A production-ready, real-time chat server built with Go, demonstrating concurrent programming, WebSocket communication, and clean architecture patterns.
- Overview
- Features
- Architecture
- Requirements
- Installation
- Configuration
- Running the Server
- Usage
- API Documentation
- Testing
- Deployment
- Troubleshooting
- License
This project is a real-time chat server that showcases Go's strengths in concurrent programming and network communication. It implements a WebSocket-based messaging system with multiple chat rooms, user presence tracking, and message history persistence.
The application demonstrates:
- Goroutine management and channel-based communication
- WebSocket protocol implementation
- Real-time message broadcasting
- Clean architecture with separation of concerns
- Production-ready error handling and logging
- Real-time messaging with WebSocket support
- Multiple chat rooms (general, technology, random)
- User presence indicators
- Message history (last 100 messages per room)
- Persistent message storage in memory
- Custom username on join
- Room switching with /join command
- User list display with /users command
- Help system with /help command
- Current room display with /room command
- Concurrent client handling with goroutines
- Graceful shutdown handling
- Cross-origin resource sharing (CORS) enabled
- Mobile-responsive web interface
- Network-wide accessibility
┌─────────────────────────────────────────────────────────────┐ │ Client Browser │ │ (WebSocket Connection) │ └──────────────────────────┬──────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────┐ │ Go Server │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │ │ │ Hub │ │ Client │ │ Message Protocol │ │ │ │ - Registry │ │ - Read Pump │ │ - Chat Messages │ │ │ │ - Rooms │ │ - Write Pump│ │ - System Messages │ │ │ │ - Broadcast │ │ - Commands │ │ - Command Handling │ │ │ └─────────────┘ └─────────────┘ └─────────────────────┘ │ └─────────────────────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────┐ │ In-Memory Storage │ │ (Message History per Room) │ └─────────────────────────────────────────────────────────────┘
- Hub Pattern: Centralized client and room management
- Observer Pattern: Message broadcasting to multiple clients
- Command Pattern: Chat command processing
- Factory Pattern: Message creation and validation
| Tool | Version | Verification Command |
|---|---|---|
| Go | 1.21+ | go version |
| Git | Latest | git --version |
| Make | 3.81+ | make --version |