A full-stack web application featuring a NestJS backend API, React frontend, and PostgreSQL database. The project is containerized with Docker and managed via Makefile for seamless local development and deployment. Built as part of the 42 cursus.
- Project Structure
- Getting Started
- Services Overview
- Useful Commands
- API Documentation (Swagger/OpenAPI)
- Authentication & Usage
- Contributing
- License
ft_transcendence/
├── api/ # NestJS backend API
├── front/ # React frontend
├── db/ # (Optional) Database schema/migrations
- Clone the repository:
git clone https://github.com/B-ki/ft_transcendence.git cd ft_transcendence
- Configure Environment Variables:
- Copy
.env.example
fromapi/
andfront/
to.env
in each folder, fill in required values (DB credentials, JWT secrets, etc).
- Copy
Run all services with hot-reload:
make dev
This will:
- Start API, frontend, and database in development mode using Docker Compose
- Hot-reload code on changes
For optimized builds:
make prod
- Location:
api/
- Tech: NestJS (TypeScript)
- Port:
3000
(default) - How to run locally:
cd api npm install npm run dev # Development npm run build && npm run prod # Production
- Environment: See
api/.env.example
- Features: REST endpoints for users, authentication, games, chat, notifications; JWT/2FA; Swagger docs
All endpoints are prefixed by /api
.
-
GET /auth/42/login
Start OAuth with 42, returns JWT and login (or 2FA challenge) -
POST /auth/2fa/login
Complete login with 2FA code{ twoFACode }
(JWT required) -
GET /auth/2fa/qrcode
Get a 2FA QR code (JWT required) -
POST /auth/2fa/activate
Activate 2FA with code{ twoFACode }
(JWT required) -
POST /auth/2fa/deactivate
Disable 2FA with code{ twoFACode }
(JWT required)
-
GET /user
Get self profile (JWT+2FA) -
GET /user/friends
List friends (JWT+2FA) -
GET /user/profile/:login
Get user profile by login (JWT+2FA) -
GET /user/all
List all users (JWT+2FA)
- Additional RESTful endpoints for games (
/api/game
), chat (/api/chat
), notifications (/api/notify
). See Swagger for full details.
- Most endpoints require a valid JWT (and in most cases, completed 2FA).
- Obtain JWT by authenticating via 42 OAuth and completing 2FA if enabled.
- Location:
front/
- Tech: React (TypeScript, Vite)
- Port:
8080
(default) - How to run locally:
cd front npm install npm run dev
- Environment: See
front/.env.example
- Features: Responsive UI, connects to backend API, real-time interactions
- Type: PostgreSQL (default)
- Setup: Handled by Docker Compose and API migrations (
prisma
) - Connection: Configured via environment variables
make dev
— Start all services in development modemake prod
— Start all services in production modemake dev.logs
/make prod.logs
— View logsmake dev.stop
/make prod.stop
— Stop all containers- (See
Makefile
for more)
- URL: http://localhost:3000/api/docs
- Browse and test all endpoints, view parameters and models
- Register/login via frontend (OAuth 42, 2FA supported)
- Use JWT (stored by frontend) for authenticated API calls
- Most API endpoints require JWT and completed 2FA
- Fork the repo and create a feature branch
- Follow coding standards and commit conventions
- Test changes locally (
make dev
) - Open a pull request
MIT License
For more technical details, see the README in each of the api/
or front/
folders, or the Swagger docs.
- The project uses
pnpm
by default, but you can usenpm
for all scripts (npm install
,npm run dev
, etc.). - If switching to npm, remove
pnpm-lock.yaml
and regeneratepackage-lock.json
for consistency.