https://github.com/0bvim/ft_transcendence
https://github.com/0bvim/ft_transcendence
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/0bvim/ft_transcendence
- Owner: 0bvim
- Created: 2025-07-11T23:28:48.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-03T04:25:11.000Z (10 months ago)
- Last Synced: 2025-08-03T06:21:04.076Z (10 months ago)
- Language: TypeScript
- Size: 4.03 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ft_transcendence - Microservices Architecture
๐ฎ **A modern transcendence project with microservices architecture and professional DevOps practices**
## ๐ Project Overview
This is a **microservices-based ft_transcendence** implementation featuring:
- ๐๏ธ **Microservices Architecture**: Separate services for frontend, authentication, and game
- ๐ฏ **Pong Game**: Classic game built with TypeScript and p5.js
- ๐ **Authentication Service**: JWT-based auth with Google OAuth and WebAuthn support
- ๐ **Frontend Service**: Modern UI with Vite, TypeScript, and Tailwind CSS
- ๐ **Complete Observability**: ELK Stack + Prometheus + Grafana for monitoring
- ๐ณ **Containerized**: All services run in Docker containers
- ๐ **Production Ready**: Structured logging, metrics, health checks
## ๐ Quick Start
```bash
# 1. Clone and navigate to project
cd ft_transcendence
# 2. Start all services
make up
# 3. Open applications in browser
make run
# 4. View monitoring dashboards
make metrics
```
## ๐ Service URLs
| Service | URL | Description | Status |
|---------|-----|-------------|--------|
| **Frontend** | https://localhost:3010 | Main application interface | โ
|
| **Authentication** | https://localhost:3001 | Auth API endpoints | โ
|
| **Game** | https://localhost:3003 | Pong game service | โ
|
| **Grafana** | https://localhost:3002 | Metrics dashboard (admin/admin) | โ
|
| **Kibana** | https://localhost:5601 | Logs visualization | โ
|
| **Prometheus** | https://localhost:9090 | Metrics collection | โ
|
| **Elasticsearch** | https://localhost:9200 | Search and analytics | โ
|
## ๐๏ธ Architecture
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ft_transcendence โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ Frontend โ โ Auth Service โ โ Game Service โ โ
โ โ (Port 3010) โ โ (Port 3001) โ โ (Port 3003) โ โ
โ โ โ โ โ โ โ โ
โ โ โข Vite + TS โ โ โข Fastify โ โ โข Fastify โ โ
โ โ โข Tailwind CSS โ โ โข Prisma ORM โ โ โข p5.js Game โ โ
โ โ โข UI Components โ โ โข JWT Auth โ โ โข Static Assets โ โ
โ โ โ โ โข Google OAuth โ โ โข Health Check โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Monitoring & Observability โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ โ
โ โ โ Elasticsearchโ โ Kibana โ โ Logstash โ โ Prometheus โ โ โ
โ โ โ (Port 9200) โ โ (Port 5601) โ โ (Port 5001) โ โ (Port 9090) โ โ โ
โ โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโ โ โ
โ โ โ Grafana โ โ โ
โ โ โ (Port 3002) โ โ โ
โ โ โโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
## ๐ Project Structure
```
ft_transcendence/
โโโ packages/
โ โโโ ms-frontend/ # Frontend microservice (Vite + TypeScript)
โ โ โโโ src/ # Source code
โ โ โโโ public/ # Static assets
โ โ โโโ Dockerfile # Container configuration
โ โ โโโ package.json # Dependencies
โ โ โโโ vite.config.ts # Vite configuration
โ โ
โ โโโ ms-auth/ # Authentication microservice (Fastify + Prisma)
โ โ โโโ src/ # Source code
โ โ โโโ prisma/ # Database schema
โ โ โโโ Dockerfile # Container configuration
โ โ โโโ package.json # Dependencies
โ โ
โ โโโ ms-game/ # Game microservice (Fastify + p5.js)
โ โ โโโ src/ # Server source code
โ โ โโโ public/ # Game assets
โ โ โโโ Dockerfile # Container configuration
โ โ โโโ package.json # Dependencies
โ โ โโโ env_example # Environment template
โ โ
โ โโโ observability/ # Shared observability library
โ โโโ src/ # Logging and metrics utilities
โ โโโ package.json # Dependencies
โ
โโโ devops/
โ โโโ elasticsearch/ # Elasticsearch configuration
โ โโโ grafana/ # Grafana dashboards and config
โ โโโ kibana/ # Kibana configuration
โ โโโ logstash/ # Logstash pipeline configuration
โ โโโ prometheus/ # Prometheus scraping configuration
โ
โโโ docs/
โ โโโ doc-devops/ # Architecture diagrams
โ
โโโ docker-compose.yml # All services orchestration
โโโ Makefile # Development commands
โโโ env.example # Environment variables template
โโโ README.md # This file
```
## ๐ ๏ธ Available Commands
```bash
# Service Management
make up # Start all services (with build)
make down # Stop all services
make restart # Restart all services
# Quick Access
make run # Open application URLs in browser
make metrics # Open monitoring dashboards (Grafana & Kibana)
# Cleanup
make clean # Complete cleanup (containers, volumes, images)
# Help
make help # Show all available commands
```
## ๐ง Development Setup
### Prerequisites
- Docker and Docker Compose
- Make (for convenience commands)
### Environment Configuration
1. **Copy environment files:**
```bash
# Main environment (optional - has defaults)
cp .env.example .env
# Game service environment
cp packages/ms-game/env_example packages/ms-game/.env
```
2. **Start development:**
```bash
make up
```
3. **Access services:**
- Frontend: https://localhost:3000
- Game: https://localhost:3002
- Auth API: https://localhost:3001
## ๐ Monitoring & Observability
### Logs (ELK Stack)
- **Elasticsearch**: Stores and indexes logs
- **Logstash**: Processes and forwards logs
- **Kibana**: Visualizes logs and provides search interface
### Metrics (Prometheus + Grafana)
- **Prometheus**: Collects metrics from services
- **Grafana**: Creates dashboards and visualizations
### Health Checks
All services provide health endpoints:
- Frontend: https://localhost:3000/health
- Auth: https://localhost:3001/health
- Game: https://localhost:3002/health
## ๐ฎ Game Features
- **Classic Pong gameplay** with modern graphics
- **TypeScript implementation** for type safety
- **p5.js rendering** for smooth graphics
- **Responsive design** for different screen sizes
- **Real-time game state** management
## ๐ Authentication Features
- **JWT-based authentication**
- **Google OAuth integration**
- **WebAuthn support** for passwordless login
- **Secure session management**
- **CORS configuration** for microservices
## ๐ Technical Highlights
### Microservices Architecture
- โ
**Service separation** by domain
- โ
**Independent deployments**
- โ
**Scalable design**
- โ
**Technology diversity** (different tech per service)
### DevOps Practices
- โ
**Containerization** with Docker
- โ
**Service orchestration** with docker-compose
- โ
**Monitoring** with Prometheus + Grafana
- โ
**Logging** with ELK stack
- โ
**Health checks** and readiness probes
- โ
**Environment configuration**
### Modern Development
- โ
**TypeScript** for type safety
- โ
**Modern frameworks** (Vite, Fastify)
- โ
**Database ORM** (Prisma)
- โ
**Linting and formatting**
- โ
**Hot reloading** in development
## ๐ Production Deployment
The project is designed for production deployment with:
- **Docker containers** for consistent environments
- **Health checks** for container orchestration
- **Structured logging** for log aggregation
- **Metrics collection** for monitoring
- **Environment-based configuration**
- **Security best practices**
## ๐ Troubleshooting
### Common Issues
1. **Port conflicts**: Check if ports are already in use
2. **Docker issues**: Ensure Docker daemon is running
3. **Build failures**: Check logs with `docker-compose logs [service]`
4. **Health check failures**: Verify service is responding on correct port
### Debugging Commands
```bash
# Check service logs
docker-compose logs ms-frontend
docker-compose logs ms-auth
docker-compose logs ms-game
# Check service health
curl https://localhost:3000/health
curl https://localhost:3001/health
curl https://localhost:3002/health
# Check metrics
curl https://localhost:3002/metrics
```
## ๐ Performance Monitoring
### Key Metrics to Monitor
- **HTTP request duration**
- **Request rate**
- **Error rate**
- **Memory usage**
- **CPU usage**
### Dashboards
- **Grafana**: Real-time metrics and alerting
- **Kibana**: Log analysis and troubleshooting
## ๐ค Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Test with `make up`
5. Submit a pull request
## ๐ Architecture Documentation
- [Container Architecture](docs/doc-devops/Containers.mmd) - Service relationships
- [Observability Setup](packages/observability/) - Logging and metrics library
- [Environment Configuration](.env.example) - Configuration options
---
**ft_transcendence** - Modern microservices architecture with professional DevOps practices
*Built with TypeScript, Docker, and industry-standard monitoring tools*