A platform powered by AWS to host and solve Capture The Flag (CTF) challenges. This platform allows users to launch isolated Docker containers for each challenge, providing a secure environment for solving CTF problems.
- User authentication and authorization (JWT)
- Dynamic Docker container management for CTF challenges
- Flag submission and tracking
- Automatic cleanup of expired instances
- User progress tracking
- Node.js 25.x
- MongoDB 6.0+
- Docker 20.10+
-
Clone the repository
git clone https://github.com/sfeedbackx/ctf_platform.git cd ctf_platform/backend -
Install dependencies
npm install
-
Configure environment Create a
.envfile in thebackend/directory:PORT=3000 NODE_ENV=development SERVER_HOST=localhost DB_URL=mongodb://localhost:27017/ctf_platform SECRET=your-secret-key-change-this-in-production MAX_AGE=604800000
-
Start MongoDB and Docker
# Start MongoDB (Linux/Mac) sudo systemctl start mongod # Verify Docker is running docker ps
-
Run the server
# Development mode (with hot reload) npm run dev # Production mode npm run build npm start
The backend API will be available at http://localhost:3000
Note: The frontend is a React application. Setup instructions:
-
Navigate to frontend directory
cd frontend -
Install dependencies
npm install
-
Configure environment Create a
.envfile:VITE_API_URL=http://localhost:3000/api/v1 # or REACT_APP_API_URL (depending on your build tool)
-
Start development server
npm run dev
-
Configure CORS in backend
Important: CORS is currently not configured. You need to add CORS middleware:
cd backend npm install cors @types/corsThen update
backend/src/app.ts:import cors from 'cors'; app.use(cors({ origin: process.env.FRONTEND_URL || 'http://localhost:5173', credentials: true }));
ctf_platform/
├── backend/ # Backend API server (Node.js + Express + TypeScript)
│ ├── src/
│ │ ├── config/ # Configuration and database setup
│ │ ├── controller/ # Business logic
│ │ ├── middlewares/ # Express middlewares
│ │ ├── models/ # Mongoose models
│ │ ├── router/ # Route definitions
│ │ ├── types/ # TypeScript types
│ │ ├── utils/ # Utility functions
│ │ ├── app.ts # Express app configuration
│ │ └── server.ts # Server entry point
│ ├── scripts/ # Migration scripts
│ └── package.json
├── frontend/ # Frontend application (to be implemented)
└── docs/ # Documentation
├── architecture.md # System architecture
├── api.md # API documentation
├── setup.md # Detailed setup guide
├── sequences.md # Sequence diagrams
└── security.md # Security considerations
- Constants:
UPPER_SNAKE_CASE - Variables & Functions:
camelCase - Classes:
UpperCamelCase
Comprehensive documentation is available in the docs/ directory:
- Architecture: System architecture and design decisions
- API Documentation: Complete API reference
- Setup Guide: Detailed setup instructions
- Sequence Diagrams: Visual flow diagrams
- Security: Security considerations and gaps
Before Production Deployment:
- CORS: Not configured - must be added for frontend communication
- Rate Limiting: Not implemented - critical for preventing abuse
- Database Security: Database is exposed until AWS migration - use strong credentials and restrict access
See Security Documentation for details.
POST /api/v1/signup- Create user accountPOST /api/v1/login- Authenticate userPOST /api/v1/logout- Logout user
GET /api/v1/ctfs- List all CTF challengesPOST /api/v1/ctfs/:id/instances- Start CTF instanceGET /api/v1/ctfs/instances- Get active instancePATCH /api/v1/ctfs/instances/:id- Stop instancePATCH /api/v1/ctfs/:id- Submit flag
See API Documentation for complete details.
# Development
npm run dev # Start dev server with hot reload
npm run build # Build TypeScript to JavaScript
npm start # Start production server
# Code Quality
npm run lint # Run ESLint
npm run format # Format code with Prettier
npm run check # Check code formatting
# Utilities
npm run migrate # Run database migrations
npm run docker_test # Test Docker utilities- Runtime: Node.js 25.x
- Framework: Express.js 5.2.1
- Language: TypeScript 5.9.3
- Database: MongoDB (Mongoose 9.0.2)
- Authentication: JWT (jsonwebtoken 9.0.3)
- Docker: dockerode 4.0.9
- Scheduling: node-cron 4.2.1
- Follow the naming conventions
- Run
npm run lintbefore committing - Update documentation for new features
- Add tests for new functionality
See LICENSE file for details.
- Backend setup inspired by Aman Mittal's Express + TypeScript guide:
- Backend setup reference — Aman Mittal