Production-ready microservices chat application with real-time messaging, user profiles, image sharing, JWT authentication, distributed tracing, and comprehensive monitoring built with Spring Boot, Node.js, FastAPI, Go, and React.
- β User Management: Registration, authentication, and JWT-based security
- β Real-time Chat: Public and private messaging with WebSocket support
- β Image Sharing: Post images with automatic resizing and preview
- β User Profiles: Profile management with image upload capabilities
- β Service Monitoring: Health checks, metrics, and status dashboard
- β Distributed Tracing: OpenTelemetry integration with Jaeger
- β Code Quality: Comprehensive linting, static analysis, and security scanning
- β Online Users: Real-time tracking of active users
Frontend (React) βββ
ββββ User Service (Spring Boot) ββββ PostgreSQL
ββββ Chat Service (Node.js) ββββββββββ MongoDB, Redis, Kafka
ββββ Profile Service (FastAPI) βββββββ PostgreSQL, Redis
ββββ Posts Service (Go) βββββββββββββββ PostgreSQL, MongoDB, Redis
| Service | Technology | Database | Purpose |
|---|---|---|---|
| Frontend | React 18 | - | Web Interface |
| User Service | Spring Boot 3.1 | PostgreSQL | Authentication & User Management |
| Chat Service | Node.js 18 | MongoDB, Redis, Kafka | Real-time Messaging |
| Posts Service | Go 1.21 | PostgreSQL, MongoDB, Redis | Image Sharing |
| Profile Service | Python FastAPI | PostgreSQL, Redis | User Profiles |
| Component | Purpose | Port |
|---|---|---|
| PostgreSQL | Primary Database | 5432 |
| MongoDB | Document Storage | 27017 |
| Redis | Caching & Sessions | 6379 |
| Kafka | Message Queue | 9092 |
| Jaeger | Distributed Tracing | 16686 |
- Docker & Docker Compose
- Git
-
Clone the repository
git clone <your-repo-url> cd chat-microservices-app
-
Start all services
docker compose up -d
-
Access the application
- Web App: http://localhost:3000
- Service Dashboard: http://localhost:3000/services
- Jaeger Tracing: http://localhost:16686
-
Verify services are running
# Check all service health curl http://localhost:8080/health # User Service curl http://localhost:3001/health # Chat Service curl http://localhost:8081/health # Profile Service curl http://localhost:8083/health # Posts Service
| Service | Port | Health Check | Metrics |
|---|---|---|---|
| Frontend | 3000 | - | - |
| User Service | 8080 | /health |
/metrics |
| Chat Service | 3001 | /health |
/metrics |
| Profile Service | 8081 | /health |
/metrics |
| Posts Service | 8083 | /health |
/metrics |
# Register a new user
curl -X POST http://localhost:8080/api/users/register \
-H "Content-Type: application/json" \
-d '{"username":"testuser","email":"user@example.com","password":"password123"}'
# Login
curl -X POST http://localhost:8080/api/users/login \
-H "Content-Type: application/json" \
-d '{"username":"testuser","password":"password123"}'
# Get chat messages
curl http://localhost:3001/api/messages
# Get posts
curl http://localhost:8083/api/posts
# Check all service health
for port in 8080 3001 8081 8083; do
echo "=== Service on port $port ==="
curl -s http://localhost:$port/health | jq .
done- Open http://localhost:3000
- Register a new account
- Login with your credentials
- Test real-time chat functionality
- Upload and share images
- Update your profile
- Monitor services at
/servicespage
# User Service (Java/Spring Boot)
cd user-service
mvn spring-boot:run
# Chat Service (Node.js)
cd chat-service
npm install && npm start
# Profile Service (Python/FastAPI)
cd profile-service
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000
# Posts Service (Go)
cd posts-service
go run main.go
# Frontend (React)
cd frontend
npm install && npm startRun all linting checks:
./lint-all.shIndividual service linting:
# Java (Checkstyle + SpotBugs)
cd user-service && mvn checkstyle:check && mvn spotbugs:check
# Node.js (ESLint)
cd chat-service && npm run lint
# Python (Flake8)
cd profile-service && flake8 app/
# Go (vet + fmt)
cd posts-service && go vet ./... && go fmt ./...
# React (ESLint)
cd frontend && npm run lintDependency vulnerability scanning:
# Java (OWASP Dependency Check)
cd user-service && mvn org.owasp:dependency-check-maven:check
# Node.js (npm audit)
cd chat-service && npm audit
# Python (Safety)
cd profile-service && safety check
# Go (govulncheck)
cd posts-service && govulncheck ./...- Service Status Dashboard: http://localhost:3000/services
- Individual Health Checks:
GET /{service}/health - Metrics Endpoints:
GET /{service}/metrics
- Jaeger UI: http://localhost:16686
- Trace Generation: Use the application normally - traces are automatically generated
- Cross-Service Correlation: View how requests flow between services
- Structured JSON Logs: Each service writes logs to
logs/directory - Centralized Correlation: Trace IDs included in all log entries
-
Build production images
docker compose build
-
Deploy to your platform
# Example for AWS ECS, Kubernetes, etc. # Update docker-compose.yml with your production configuration docker compose -f docker-compose.prod.yml up -d
-
Environment Configuration
# Update service URLs for your environment ./generate-config.sh \ https://user-service.yourapp.com \ https://chat-service.yourapp.com \ https://posts-service.yourapp.com \ https://profile-service.yourapp.com
cd frontend
npm run build
aws s3 sync build/ s3://your-bucket-name --deleteEach service supports environment configuration:
CORS_ORIGINS: Allowed CORS origins (default:*)LOG_DIR: Directory for log filesSERVICE_NAME: Service identifier for logs/metricsDATABASE_URL: Database connection stringREDIS_URL: Redis connection string
Check env.example files in each service directory for complete configuration options.
# User Service (Java/JUnit)
cd user-service && mvn test jacoco:report
# Chat Service (Node.js/Jest)
cd chat-service && npm test -- --coverage
# Profile Service (Python)
cd profile-service && python -m pytest test/ --cov=app
# Posts Service (Go)
cd posts-service && go test -v -cover ./...
# Frontend (React/Jest)
cd frontend && npm test -- --coverage --watchAll=false- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Run linting and tests (
./lint-all.sh) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- All code must pass linting checks
- Security vulnerabilities must be addressed
- Unit tests required for new features
- Documentation updates for API changes
POST /api/users/register- User registrationPOST /api/users/login- User authenticationGET /health- Health checkGET /metrics- Service metrics
GET /api/messages- Get chat messagesPOST /api/messages- Send messageWebSocket /socket.io- Real-time messagingGET /health- Health check
GET /api/profile/{userId}- Get user profilePUT /api/profile/{userId}- Update profilePOST /api/profile/{userId}/image- Upload profile imageGET /health- Health check
GET /api/posts- Get all postsPOST /api/posts- Create new postPOST /api/posts/{id}/like- Like/unlike postGET /api/images/{imageId}- Get imageGET /health- Health check
- Port conflicts: Ensure ports 3000, 3001, 8080-8083, 5432, 27017, 6379, 9092 are available
- Docker issues: Run
docker compose downthendocker compose up -d - Database connection issues: Check if PostgreSQL/MongoDB containers are running
- CORS errors: Verify
CORS_ORIGINSenvironment variable - Service startup failures: Check logs with
docker compose logs [service-name]
# View service logs
docker compose logs -f [service-name]
# Check container status
docker compose ps
# Restart specific service
docker compose restart [service-name]
# Clean restart
docker compose down && docker compose up -d- Built with modern microservices architecture principles
- Implements enterprise-grade security and monitoring
- Follows industry best practices for code quality and testing
- Designed for scalability and production deployment
Ready for production! π
For questions or support, please open an issue in the repository.