A scalable, production-ready real-time chat application built with Go backend and JavaScript frontend. Features include real-time messaging, user authentication, comprehensive monitoring, and high availability support.
- Real-time messaging with WebSocket support
- User authentication and authorization with JWT
- Message persistence with PostgreSQL
- High-performance caching with Redis
- Prometheus metrics and monitoring
- Docker containerization
- Kubernetes deployment support
- Load balancing with Nginx
- Comprehensive test coverage
- Docker
- Docker Compose
- Go 1.19 or later (for local development without Docker)
- Node.js (for local development without Docker)
-
Clone the repository
-
Set up environment variables:
cd backend cp .env.example .env
-
Start all services:
make dev
This will:
- Build all containers
- Start PostgreSQL database
- Start Redis server
- Launch Backend API server
- Serve Frontend application
-
Access the application:
- Frontend: http://localhost:8080
- Backend API: http://localhost:8080/api
- Metrics Dashboard: http://localhost:8080/metrics
# Install all dependencies
make install-deps
# Start development environment
make dev
# View logs
make logs
# Restart services
make restart
# Run tests
make test
# Run linting
make lint
-
Install and start PostgreSQL and Redis locally
-
Set up environment variables in backend:
cd backend cp .env.example .env # Edit .env file with your local configuration
-
Start the backend server:
cd backend go run cmd/server/main.go
-
Serve the frontend:
cd frontend npm install npm run dev
- Configure container registry credentials
- Update deployment configurations in
k8s/base/
# Deploy to Kubernetes
kubectl apply -k k8s/base
# Check deployment status
kubectl get pods
# View logs
kubectl logs -f deployment/chat-app
# Build for production
make prod-build
# Deploy to production
make prod-deploy
# Rollback to previous version
make prod-rollback
/health
- Application health status/metrics
- Prometheus metrics/ready
- Kubernetes readiness probe
# View production logs
make prod-logs
# Check service status
make prod-status
The project includes k6 load tests and Jupyter notebooks for analysis:
# Run load tests
k6 run tests/load_test_suite.js
# Start Jupyter notebook for analysis
make jupyter
# Access at http://localhost:8888
-
POST
/api/register
- Register a new user- Request:
{"username": string, "password": string, "email": string}
- Response:
{"token": string}
- Request:
-
POST
/api/login
- Login and get JWT token- Request:
{"username": string, "password": string}
- Response:
{"token": string}
- Request:
- WS
/ws
- WebSocket endpoint for real-time chat- Authentication: Bearer token in WebSocket handshake
- Message format:
{"type": string, "content": string, "recipient": string}
- GET
/metrics
- Prometheus metrics endpoint - GET
/health
- Health check endpoint - GET
/ready
- Readiness probe endpoint
- Go with Gorilla WebSocket for real-time communication
- JWT authentication
- Prometheus metrics collection
- Structured logging with correlation IDs
- Rate limiting and circuit breakers
- Vanilla JavaScript
- Real-time WebSocket client
- Metrics dashboard
- Responsive design
- PostgreSQL for persistent storage
- Redis for caching and pub/sub
- Nginx for load balancing and static file serving
- Docker containers for consistent environments
- Health checks for all services
- Kubernetes for orchestration
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.