|
1 |
| -Matching Service |
2 |
| -Overview |
3 |
| -The Matching Service is responsible for pairing users in PeerPrep based on selected topic, difficulty, and programming language. It manages user queues, handles match creation, and communicates with other services (User Service, Question Service, Collaboration Service). |
| 1 | +# Matching Service |
4 | 2 |
|
5 |
| -This service is built using FastAPI and is designed to be containerised using Docker. |
| 3 | +## Overview |
6 | 4 |
|
7 |
| -Features |
| 5 | +The **Matching Service** is responsible for pairing users in PeerPrep based on selected topic, difficulty, and programming language. It manages user queues, handles match creation, and communicates with other services such as: |
| 6 | + |
| 7 | +- **User Service** |
| 8 | +- **Question Service** |
| 9 | +- **Collaboration Service** |
| 10 | + |
| 11 | +This service is built using **FastAPI** and is designed to be **containerised using Docker**. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Features |
8 | 16 |
|
9 | 17 | - Join a match queue for a specific topic, difficulty, and programming language
|
10 | 18 | - Automatic peer matching from the queue
|
11 | 19 | - Cancel a queue request
|
12 | 20 | - Integration points for collaboration sessions
|
13 | 21 | - Health check endpoint for service monitoring
|
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## API Testing with Postman |
| 26 | + |
| 27 | +A **Postman collection** is provided to test the Matching Service: |
| 28 | + |
| 29 | +1. Open Postman -> Import -> File -> `postman/PeerPrep.postman_collection.json` |
| 30 | +2. The collection includes: |
| 31 | + - Join queue (`/match/request`) |
| 32 | + - Cancel queue (`/match/cancel`) |
| 33 | +3. Update environment variables if needed (e.g., `url`) |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## WebSocket Testing |
| 38 | + |
| 39 | +To test real-time events such as match found or timeout: |
| 40 | + |
| 41 | +1. Open Postman -> New -> WebSocket Request |
| 42 | +2. URL: `ws://localhost:8000/match/ws/{{user_id}}` |
| 43 | +3. Replace `{{user_id}}` with your test user |
| 44 | +4. Click **Connect** |
| 45 | +5. To simulate events: |
| 46 | + - POST `/match/request` from **user 1** and **user 2** to trigger `match.found` |
| 47 | + - POST `/match/request` to trigger `match.timeout` if no peer is found within 60 seconds |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## Running the service |
| 52 | + |
| 53 | +### Using Make |
| 54 | + |
| 55 | +From the `matching-service` folder, run: |
| 56 | + |
| 57 | +```bash |
| 58 | +make run |
| 59 | +``` |
0 commit comments