|
2 | 2 | # CS3219 Project (PeerPrep) - AY2526S1 |
3 | 3 | ## Group: G13 |
4 | 4 |
|
5 | | -## Quick Start |
| 5 | +## Live Deployment |
| 6 | + |
| 7 | +**Deployment URL:** [https://cs3219-ay2526s1-g13.com/](https://cs3219-ay2526s1-g13.com/) |
| 8 | + |
| 9 | +## Local Development |
| 10 | + |
| 11 | +This section provides instructions for running the application locally on your machine. |
| 12 | + |
| 13 | +### Prerequisites |
| 14 | + |
| 15 | +Before starting, ensure you have the following installed: |
| 16 | +- [Node.js](https://nodejs.org/) (v18 or higher) |
| 17 | +- [pnpm](https://pnpm.io/) package manager |
| 18 | +- [Docker](https://www.docker.com/) and Docker Compose |
| 19 | +- Git |
| 20 | + |
| 21 | +### Step 1: Start Infrastructure Services |
| 22 | + |
| 23 | +Start all required infrastructure services (MongoDB, Redis, RabbitMQ, Kafka, Piston API) using Docker Compose: |
| 24 | + |
| 25 | +```bash |
| 26 | +# Start all infrastructure services |
| 27 | +docker-compose up -d mongodb redis rabbitmq zookeeper kafka piston-api |
| 28 | + |
| 29 | +# Verify services are running |
| 30 | +docker-compose ps |
| 31 | +``` |
| 32 | + |
| 33 | +**Note:** The Piston API container needs language packages installed. After the services start, run the initialization script (see Step 2). |
| 34 | + |
| 35 | +### Step 2: Initialize Piston Language Packages |
| 36 | + |
| 37 | +After starting the Docker services, install language packages for the Piston API: |
| 38 | + |
| 39 | +**Linux/Mac (Bash):** |
| 40 | +```bash |
| 41 | +chmod +x init-piston-languages.sh |
| 42 | +./init-piston-languages.sh |
| 43 | +``` |
| 44 | + |
| 45 | +**Windows (PowerShell):** |
| 46 | +```powershell |
| 47 | +powershell -ExecutionPolicy Bypass -File .\init-piston-languages.ps1 |
| 48 | +``` |
| 49 | + |
| 50 | +Alternatively, if your PowerShell execution policy allows it: |
| 51 | +```powershell |
| 52 | +.\init-piston-languages.ps1 |
| 53 | +``` |
| 54 | + |
| 55 | +**Note:** Language installation happens asynchronously in the background. Some languages may take 10-30 minutes to install. The API will be functional even while languages are installing. |
| 56 | + |
| 57 | +### Step 3: Start Backend Services |
| 58 | + |
| 59 | +Each backend service should be started individually. Navigate to each service directory and start them: |
| 60 | + |
| 61 | +```bash |
| 62 | +# User Service (Port 8001) |
| 63 | +cd backend/user-service |
| 64 | +pnpm install |
| 65 | +pnpm start |
| 66 | + |
| 67 | +# Matching Service (Port 8002) |
| 68 | +cd backend/matching-service |
| 69 | +pnpm install |
| 70 | +pnpm start |
| 71 | + |
| 72 | +# Question Service (Port 8003) |
| 73 | +cd backend/question-service |
| 74 | +pnpm install |
| 75 | +pnpm start |
| 76 | + |
| 77 | +# Collaboration Service (Port 8004) |
| 78 | +cd backend/collaboration-service |
| 79 | +pnpm install |
| 80 | +pnpm start |
| 81 | + |
| 82 | +# Execution Service |
| 83 | +cd backend/execution-service |
| 84 | +pnpm install |
| 85 | +pnpm start |
| 86 | + |
| 87 | +# Video Call Service (Port 8011) |
| 88 | +cd backend/video-call-service |
| 89 | +pnpm install |
| 90 | +pnpm start |
| 91 | +``` |
| 92 | + |
| 93 | +**Alternative:** You can also start all backend services using Docker Compose: |
| 94 | + |
| 95 | +```bash |
| 96 | +# Start all services including backend |
| 97 | +docker-compose up -d |
| 98 | +``` |
| 99 | + |
| 100 | +### Step 4: Start Frontend |
6 | 101 |
|
7 | | -### Frontend |
8 | 102 | ```bash |
9 | 103 | # Install dependencies |
10 | 104 | pnpm install |
11 | 105 |
|
12 | 106 | # Start development server |
13 | 107 | pnpm dev |
14 | 108 |
|
15 | | -# Open http://localhost:3000 |
| 109 | +# Open http://localhost:3000 in your browser |
16 | 110 | ``` |
17 | 111 |
|
18 | | -### Available Commands |
| 112 | +### Available Frontend Commands |
19 | 113 | - `pnpm dev` - Start frontend development server |
20 | 114 | - `pnpm build` - Build frontend for production |
21 | 115 | - `pnpm lint` - Run linting |
22 | 116 | - `pnpm format` - Format code |
23 | 117 |
|
| 118 | +### Service Ports |
| 119 | + |
| 120 | +When running locally, services are available at: |
| 121 | +- **Frontend:** http://localhost:3000 |
| 122 | +- **User Service:** http://localhost:8001 |
| 123 | +- **Matching Service:** http://localhost:8002 |
| 124 | +- **Question Service:** http://localhost:8003 |
| 125 | +- **Collaboration Service:** http://localhost:8004 |
| 126 | +- **Video Call Service:** http://localhost:8011 |
| 127 | +- **Piston API:** http://localhost:2000 |
| 128 | +- **RabbitMQ Management:** http://localhost:15672 (user: `user`, password: `password`) |
| 129 | + |
24 | 130 | ## MongoDB Setup |
25 | 131 |
|
26 | 132 | This project uses MongoDB as the database, configured with Docker Compose for easy development setup. |
@@ -104,30 +210,37 @@ docker exec mongodb mongodump --username admin --password password --out /data/b |
104 | 210 | docker exec mongodb mongorestore --username admin --password password /data/backup |
105 | 211 | ``` |
106 | 212 |
|
| 213 | +## Project Structure |
| 214 | + |
| 215 | +- **Frontend:** Next.js application in `frontend/` directory |
| 216 | +- **Backend Services:** Individual microservices in `backend/` directory: |
| 217 | + - `user-service/` - User authentication and management |
| 218 | + - `matching-service/` - User matching for practice sessions |
| 219 | + - `question-service/` - Question management |
| 220 | + - `collaboration-service/` - Real-time collaboration features |
| 221 | + - `execution-service/` - Code execution service |
| 222 | + - `video-call-service/` - Video call functionality |
| 223 | +- **Infrastructure:** Docker Compose configuration and Terraform deployment scripts |
| 224 | +- **Terraform:** Infrastructure as code for GCP deployment in `terraform/` directory |
| 225 | + |
107 | 226 | ### Note: |
108 | 227 | - You are required to develop individual microservices within separate folders within this repository. |
109 | 228 | - The teaching team should be given access to the repositories as we may require viewing the history of the repository in case of any disputes or disagreements. |
110 | 229 |
|
111 | | -## Note for execution service |
112 | | -- After run docker compose-up, run the next commands in terminal to install language packages for Piston |
| 230 | +### Execution Service API |
113 | 231 |
|
114 | | -### Linux/Mac (Bash) |
115 | | -```bash |
116 | | -chmod +x init-piston-languages.sh |
117 | | -./init-piston-languages.sh |
118 | | -``` |
119 | | - |
120 | | -### Windows (PowerShell) |
121 | | -```powershell |
122 | | -powershell -ExecutionPolicy Bypass -File .\init-piston-languages.ps1 |
123 | | -``` |
| 232 | +The execution service provides the following endpoints: |
124 | 233 |
|
125 | | -Alternatively, if your PowerShell execution policy allows it: |
126 | | -```powershell |
127 | | -.\init-piston-languages.ps1 |
128 | | -``` |
129 | | -- APIs |
130 | 234 | ```bash |
131 | 235 | POST /v1/execution/submit # submit language, code -> submit_id |
132 | 236 | GET /v1/execution/submit/{submit_id} # get result -> submit_status = {pending | processing | done}, result |
133 | 237 | ``` |
| 238 | + |
| 239 | +## Deployment |
| 240 | + |
| 241 | +For deployment instructions, please refer to the documentation in the `terraform/` folder: |
| 242 | + |
| 243 | +- **General Deployment:** See the README and configuration files in the `terraform/` directory |
| 244 | +- **Piston API Setup:** See [`terraform/PISTON_API_INSTALLATION_GUIDE.md`](terraform/PISTON_API_INSTALLATION_GUIDE.md) for detailed instructions on setting up Piston API on Google Cloud Platform |
| 245 | + |
| 246 | +The deployment uses Google Cloud Platform (GCP) with Terraform for infrastructure as code. |
0 commit comments