A scalable real-time messaging platform with analytics capabilities, built with WebSocket technology and Hub-and-Spoke architecture.
This platform provides real-time chat functionality with comprehensive analytics tracking. The system is designed to handle concurrent connections efficiently while collecting and analyzing message patterns, user engagement, and system performance metrics.
The platform currently consists of:
- Backend: Go-based WebSocket server with Hub-and-Spoke architecture
- Storage: DynamoDB for message persistence
- Analytics (planned): Real-time message analytics and user behavior tracking
- Frontend (planned): Web-based chat interface
┌─────────────────────────────────────────┐
│ WebSocket Clients │
│ (Browser, Mobile, Desktop) │
└──────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Hub (Central Manager) │
│ • Connection management │
│ • Message broadcasting │
│ • Channel-based communication │
└──────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Client Connections │
│ • Read/Write goroutines │
│ • Message validation │
│ • Ping/Pong keepalive │
│ • Non-blocking persistence │
└──────────┬──────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ DynamoDB (Message Storage) │
│ • Message history │
│ • User-based queries (GSI) │
│ • Room-based queries (GSI) │
└─────────────────────────────────────────┘
- Real-time bidirectional messaging
- WebSocket-based communication
- Hub-and-Spoke connection management
- Type-safe message validation
- Automatic connection cleanup
- Graceful shutdown
- Health check endpoint
- Comprehensive test coverage
- Message persistence (DynamoDB) - Phase 2A ✅
- Non-blocking async storage - Phase 2A ✅
- Docker Compose setup - Phase 2A ✅
- DynamoDB Local integration - Phase 2A ✅
- AWS SDK v2 integration - Phase 2A ✅
- AWS deployment preparation (ECS, CloudFormation)
- Production Dockerfile
- Integration and load tests
- User analytics dashboard
- Active user tracking
- Message rate analytics
- Performance metrics
- Private messaging
- Authentication & authorization
- Frontend chat interface (React)
Prerequisites:
- Docker and Docker Compose
- Git
# Clone the repository
git clone https://github.com/EPW80/Chat-Analytics-Platform.git
cd Chat-Analytics-Platform
# Start services (Backend + DynamoDB Local)
docker-compose up -d
# Check health
curl http://localhost:8080/health
# Response: {"status":"ok","clients":0}
# Initialize DynamoDB tables (optional - for persistence)
./scripts/init-tables.sh
# View logs
docker-compose logs -f backend
# Stop services
docker-compose downServices:
- Backend:
http://localhost:8080 - DynamoDB Local:
http://localhost:8000 - WebSocket:
ws://localhost:8080/ws
Prerequisites:
- Go 1.23 or higher
- Git
# Clone the repository
git clone https://github.com/EPW80/Chat-Analytics-Platform.git
cd Chat-Analytics-Platform
# Navigate to backend
cd backend
# Install dependencies
go mod download
# Run the server
go run cmd/server/main.goThe server will start on port 8080 by default.
curl http://localhost:8080/health
# Response: {"status":"ok","clients":0}Install wscat:
npm install -g wscatConnect and send messages:
# Terminal 1
wscat -c "ws://localhost:8080/ws?userId=alice&username=Alice"
# Terminal 2
wscat -c "ws://localhost:8080/ws?userId=bob&username=Bob"
# Send a message (in either terminal)
{"type":"chat","content":"Hello everyone!"}RealTimeChatAnalyticsPlatform/
├── backend/ # Go WebSocket server
│ ├── cmd/
│ │ └── server/ # Main server entry point
│ ├── pkg/
│ │ ├── client/ # WebSocket client handler
│ │ ├── config/ # Environment configuration
│ │ ├── hub/ # Connection manager
│ │ ├── message/ # Message types & validation
│ │ └── storage/ # DynamoDB persistence (Phase 2A)
│ │ ├── interface.go # Repository interface
│ │ ├── dynamodb.go # DynamoDB implementation
│ │ └── schema.go # Table schema
│ ├── scripts/
│ │ └── init-dynamodb.go # Table initialization
│ ├── Dockerfile # Development container
│ ├── .dockerignore
│ ├── go.mod
│ └── README.md # Backend documentation
├── scripts/
│ ├── wait-for-dynamodb.sh # Health check script
│ └── init-tables.sh # Table setup wrapper
├── docker-compose.yml # Local development stack
├── .env.example # Environment template
├── .gitignore
├── claude.md # Implementation plan
└── README.md # This file
Health check endpoint that returns server status and connected client count.
Response:
{
"status": "ok",
"clients": 5
}WebSocket endpoint for real-time chat connections.
Query Parameters:
userId(optional): User identifier (defaults to "anonymous")username(optional): Display name (defaults to "Anonymous")
Example:
ws://localhost:8080/ws?userId=user123&username=Alice
All messages follow this JSON structure:
{
"messageId": "550e8400-e29b-41d4-a716-446655440000",
"roomId": "global",
"type": "chat",
"userId": "user123",
"username": "Alice",
"content": "Hello world",
"timestamp": "2025-12-30T10:30:00Z"
}Message Fields:
messageId: Unique UUID (auto-generated, Phase 2A)roomId: Room identifier (defaults to "global", Phase 2A)type: Message type (see below)userId: User identifierusername: Display namecontent: Message texttimestamp: ISO 8601 timestamp (UTC)
Message Types:
chat: User chat messagesystem: System announcementjoin: User joined notificationleave: User left notification
Validation Rules:
- Username: Required, max 50 characters
- Content (for chat messages): Required, max 1000 characters
- Timestamp: Automatically set to UTC
- MessageID: Auto-generated UUID v4 if not provided
- RoomID: Defaults to "global" if not provided
cd backend
# Run all tests
go test ./...
# Run with race detection
go test -race ./...
# Test coverage
go test -cover ./...cd backend
go build -o chat-server cmd/server/main.go
./chat-serverServer Configuration:
PORT: Server port (default: 8080)LOG_LEVEL: Logging level (debug, info, warn, error; default: info)
DynamoDB Configuration (Phase 2A):
DYNAMODB_ENDPOINT: DynamoDB endpoint URL (e.g., http://localhost:8000 for local)DYNAMODB_REGION: AWS region (default: us-east-1)AWS_ACCESS_KEY_ID: AWS access key (use "dummy" for local DynamoDB)AWS_SECRET_ACCESS_KEY: AWS secret key (use "dummy" for local DynamoDB)
Example (.env.example):
PORT=8080
LOG_LEVEL=info
DYNAMODB_ENDPOINT=http://localhost:8000
DYNAMODB_REGION=us-east-1
AWS_ACCESS_KEY_ID=dummy
AWS_SECRET_ACCESS_KEY=dummy- Capacity: 100+ concurrent connections
- Latency: <100ms message delivery (p95)
- Throughput: Non-blocking broadcast to all clients
- Reliability: Automatic connection cleanup, no goroutine leaks
- Language: Go 1.23+
- WebSocket: gorilla/websocket v1.5.3
- Storage: AWS SDK v2 for DynamoDB (Phase 2A)
- Configuration: github.com/epw80/chat-analytics-platform/pkg/config
- Concurrency: Goroutines and channels
- Logging: slog (structured logging)
- UUID Generation: google/uuid v1.6.0
- Containerization: Docker and Docker Compose
- Database: DynamoDB Local (development), AWS DynamoDB (production)
- Networking: Docker bridge networks
- WebSocket server with Hub-and-Spoke architecture
- Real-time message broadcasting
- Comprehensive test coverage
- Health check endpoint
- Graceful shutdown
- Message persistence (DynamoDB)
- Docker containerization
- DynamoDB Local integration
- AWS SDK v2 integration
- Configuration management
- Non-blocking async storage
- AWS deployment files (ECS, CloudFormation)
- Production Dockerfile
- Integration and load tests
- Real-time analytics backend
- In-memory metrics tracking
- Analytics API endpoint
- Performance metrics collection
- Frontend chat interface (React)
- Analytics dashboard
- User list component
- Message history visualization
- User authentication & authorization
- Private messaging
- Rate limiting
- Kubernetes deployment
- Horizontal scaling with Redis pub/sub
- CloudWatch integration
- API Gateway + Lambda
Contributions are welcome! Please feel free to submit a Pull Request.
This is currently a development implementation. For production use:
- Authentication: Implement proper JWT/OAuth instead of query parameters
- CORS: Restrict allowed origins
- Rate Limiting: Add per-client message rate limits
- Input Validation: Add content filtering and sanitization
- TLS: Use WSS (WebSocket Secure) with proper certificates
- Environment Variables: Use secure secret management
For detailed backend documentation, see backend/README.md.
MIT
Erik Williams (@EPW80)