This document replaces the original course boilerplate and explains how to start, verify, and understand the PeerPrep microservices system.
| Service | Path | Port(s) | Purpose |
|---|---|---|---|
| frontend | frontend/ |
3000 |
React UI for problems, matching, code editor, collaboration, and chatbot. |
| matching-service | matching-service/ |
8084 (host) → 3001 (container) |
Redis-backed matching engine with relaxed difficulty retry. |
| question-service | question-service/ |
3001 |
Node/Express service with MongoDB store for questions and execution. Difficulty ordering is fixed at Easy → Medium → Hard. |
| chatbot-service | chatbot-service/ |
3302 (host) → 3002 (container) |
Node/Express wrapper around OpenAI (falls back to mock when key unavailable). |
| user-service | user_service/ |
8000 |
FastAPI for registration/login/profile stored in MongoDB. |
| collaboration-service | collaboration-service/ |
8090 |
TypeScript WebSocket/Yjs server for live code sharing plus partner chat. |
| mongo | docker | 27017 |
Question and user data. |
| redis | docker | 6379 |
Matching queues, sweeper indices. |
- Docker Desktop or Docker Engine (with Docker Compose v2).
- Node.js 18+ with npm for local dev (optional).
- Python 3.11 and pip (for running user-service outside Docker).
- OpenAI API key (optional). Without a key, chatbot returns mock responses.
git clone https://github.com/CS3219-AY2526Sem1/cs3219-ay2526s1-project-g20.git
cd cs3219-ay2526s1-project-g20
git fetch origin
git checkout staging
git pull origin stagingCopy env template and edit values as needed:
cp env.example .env
# Fill in OPENAI_API_KEY, etc.Individual services also respect .env files in their directories when run manually.
docker compose up --build -dThis sets up Mongo, Redis, and all application services on the peerprep-g20_app-network. Review status:
docker compose psAll services should be Up (healthy). Sample endpoints:
- Frontend: http://localhost:3000/
- Matching: http://localhost:8084/
- Question API: http://localhost:3001/
- Chatbot API: http://localhost:3302/
- User API: http://localhost:8000/
- Collaboration WS: ws://localhost:8090/ws
Stop everything:
docker compose down- Frontend loads, login/signup works (User service + Mongo).
- Problems page shows questions ordered by
Easy → Medium → Hard(Question service). - Code execution in editor works for Python and JavaScript (server-supplied test cases).
- Matching: open two browsers, request a match with overlapping criteria, and accept the match to enter collaboration (Matching service → Collaboration service → Frontend).
- Partner chat: within collaboration, typing
@partner Hellosends a peer-only message and shows a header alert. - Chatbot: messages go to OpenAI if valid key; otherwise fallback responses appear.
If anything loops (e.g., repeated matching), inspect logs:
docker compose logs matching-service
docker compose logs collaboration-serviceFlush Redis if stale queue entries persist:
docker compose exec redis redis-cli flushallFor targeted development, you can run services without Docker. Ensure local MongoDB/Redis if required.
-
Frontend (dev mode)
cd frontend npm install npm run dev -
Matching service
cd matching-service npm install npm run devRequires
REDIS_URLpointing to Redis (redis://localhost:6379if running locally). -
Question service
cd question-service npm install npm run devRequires MongoDB (
MONGODB_URI=mongodb://localhost:27017/peerprep-questions). -
User service
cd user_service pip install -r requirements.txt uvicorn app.main:app --host 0.0.0.0 --port 8000 -
Chatbot service
cd chatbot-service npm install npm run devSet
OPENAI_API_KEYfor real responses. -
Collaboration service
cd collaboration-service npm install npm run devNeeds the same JWT secret as matching (
COLLAB_JWT_SECRET, etc.).
-
Seed questions with test cases using
question-servicescripts:docker compose exec question-service npm run seed:prod docker compose exec question-service npm run add-test-cases:prod
or locally with
npm run seed. -
Redis stores match queues in-memory; resetting is optional:
docker compose exec redis redis-cli flushall
- Black/white text mismatch in chat: styles live in
frontend/src/css/CodeEditor.css. - OpenAI errors: check logs for
insufficient_quota; remove key or update billing. - Matching stuck: ensure both clients accept. Examine
matching-servicelogs to confirm status transitions. - JWT issues: tokens issued by matching contain
sub(userId) androomIdclaims. Collaboration service uses these to route messages and Yjs updates.
- Clone > fetch > pull latest staging.
- Configure
.env. docker compose up --build -dto run all services.- Validate features in the frontend with two browser sessions.
- Use per-service commands for focused development.
- Keep question data seeded and Redis clear for reliable matching.
This README replaces the previous course boilerplate and should equip contributors and testers to start the PeerPrep environment end-to-end. Feel free to extend it with further developer notes or onboarding tips.