An open API service indexing awesome lists of open source software.

https://github.com/0bvim/ft_transcendence


https://github.com/0bvim/ft_transcendence

Last synced: 8 months ago
JSON representation

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*