Skip to content

Commit

Permalink
Merge branch 'main' into role-based-authorization-spa
Browse files Browse the repository at this point in the history
  • Loading branch information
LimZiJia committed Nov 1, 2024
2 parents fcd5022 + f85a63b commit 1667d91
Show file tree
Hide file tree
Showing 141 changed files with 9,849 additions and 577 deletions.
20 changes: 16 additions & 4 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This is a sample environment configuration file.
# Copy this file to .env and replace the placeholder values with your own.

# Question Service
QUESTION_DB_CLOUD_URI=<FILL-THIS-IN>
QUESTION_DB_LOCAL_URI=mongodb://question-db:27017/question
Expand All @@ -19,7 +16,22 @@ MATCH_DB_LOCAL_URI=mongodb://match-db:27017/match
MATCH_DB_USERNAME=user
MATCH_DB_PASSWORD=password

# Room Service
COLLAB_DB_CLOUD_URI=mongodb+srv://<username>:<password>@cluster0.h5ukw.mongodb.net/collaboration-service?retryWrites=true&w=majority&appName=Cluster0
COLLAB_DB_LOCAL_URI=mongodb://collaboration-db:27017/collaboration-service

# Collaboration Service (Yjs Documents)
YJS_DB_CLOUD_URI=mongodb+srv://<username>:<password>@cluster0.h5ukw.mongodb.net/yjs-documents?retryWrites=true&w=majority&appName=Cluster0
YJS_DB_LOCAL_URI=mongodb://collaboration-db:27017/yjs-documents

# Will use cloud MongoDB Atlas database
ENV=PROD

# Broker
BROKER_URL=amqp://broker:5672

# Secret for creating JWT signature
JWT_SECRET=you-can-replace-this-with-your-own-secret

NODE_ENV=development
# Node environment
NODE_ENV=development
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
service: [frontend, services/question, services/user, services/match]
service: [frontend, services/question, services/user, services/match, services/collaboration]
steps:
- uses: actions/checkout@v4
- name: Use Node.js
Expand Down
48 changes: 29 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/bzPrOe11)

# CS3219 Project (PeerPrep) - AY2425S1

## Group: G03

### Note:
- You can choose to develop individual microservices within separate folders within this repository **OR** use individual repositories (all public) for each microservice.
- In the latter scenario, you should enable sub-modules on this GitHub classroom repository to manage the development/deployment **AND** add your mentor to the individual repositories as a collaborator.
- 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.
### Note:

- You can choose to develop individual microservices within separate folders within this repository **OR** use
individual repositories (all public) for each microservice.
- In the latter scenario, you should enable sub-modules on this GitHub classroom repository to manage the
development/deployment **AND** add your mentor to the individual repositories as a collaborator.
- 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.

## Pre-requisites

1. Install [Docker Desktop](https://www.docker.com/products/docker-desktop/)
2. Clone the GitHub repository

```
git clone https://github.com/CS3219-AY2425S1/cs3219-ay2425s1-project-g03.git
```
Expand All @@ -19,7 +26,7 @@ git clone https://github.com/CS3219-AY2425S1/cs3219-ay2425s1-project-g03.git

**Step 1: Copy Environment Configuration File**

To get started, copy the contents of `.env.sample` into a new `.env` file located at the root level of the project.
To get started, copy the contents of `.env.sample` into a new `.env` file located at the root level of the project.

**Step 2: Build the Docker containers**

Expand All @@ -37,25 +44,26 @@ Once the build is complete, you can start the Docker containers.
docker compose -f compose.yml up -d
```

After spinning up the services, you may access the frontend client at `127.0.0.1:4200`. Specifically, you can navigate to the Question SPA at `127.0.0.1:4200/questions` and the login page at `127.0.0.1/account`.
After spinning up the services, you may access the frontend client at `127.0.0.1:4200`. Specifically, you can navigate
to the Question SPA at `127.0.0.1:4200/questions` and the login page at `127.0.0.1/account`.

If you would like to spin up the services in development mode, you may use the following command. This enables hot reloading and exposes the ports for all microservices.
If you would like to spin up the services in development mode, you may use the following command. This enables hot
reloading and exposes the ports for all microservices.

```bash
docker compose -f compose.yml -f compose.dev.yml up -d
```

| Service | Port |
|-----------------------|------|
| Frontend | 4200 |
| API Gateway | 8080 |
| Question Service | 8081 |
| User Service | 8082 |
| Match Service | 8083 |
| Collaboration Service | 8084 |
| Chat Service | 8085 |
| History Service | 8086 |

| Service | Port |
|------------------------------|------|
| Frontend | 4200 |
| API Gateway | 8080 |
| Question Service | 8081 |
| User Service | 8082 |
| Match Service | 8083 |
| Collaboration & Room Service | 8084 |
| Chat Service | 8085 |
| History Service | 8086 |

**Step 4: Stop the Docker containers**

Expand All @@ -65,4 +73,6 @@ Once you are done, stop and remove the containers using:
docker compose down -v
```

Note that this will clear any data stored in volumes associated with the containers. If you would like to keep your data, you can run the command without the `-v` flag, which will remove the containers but retain the data in the volumes for future use.
Note that this will clear any data stored in volumes associated with the containers. If you would like to keep your
data, you can run the command without the `-v` flag, which will remove the containers but retain the data in the volumes
for future use.
18 changes: 17 additions & 1 deletion compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ services:
ports:
- 27019:27017

match-broker:
collaboration:
command: npm run dev
ports:
- 8084:8084
volumes:
- /app/node_modules
- ./services/collaboration:/app

broker:
ports:
- 5672:5672

dozzle:
image: amir20/dozzle:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 8000:8080
restart: always
63 changes: 53 additions & 10 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
ports:
- 4200:4200
restart: always

gateway:
container_name: gateway
image: nginx:1.27
Expand All @@ -20,9 +20,11 @@ services:
- question
- user
- match
- collaboration
networks:
- gateway-network

restart: always

question:
container_name: question
image: question
Expand All @@ -34,6 +36,11 @@ services:
DB_LOCAL_URI: ${QUESTION_DB_LOCAL_URI}
DB_USERNAME: ${QUESTION_DB_USERNAME}
DB_PASSWORD: ${QUESTION_DB_PASSWORD}
BROKER_URL: ${BROKER_URL}
JWT_SECRET: ${JWT_SECRET}
depends_on:
broker:
condition: service_healthy
networks:
- gateway-network
- question-db-network
Expand Down Expand Up @@ -69,7 +76,7 @@ services:
- gateway-network
- user-db-network
restart: always

user-db:
container_name: user-db
image: mongo:7.0.14
Expand All @@ -82,7 +89,7 @@ services:
- user-db-network
command: --quiet
restart: always

match:
container_name: match
image: match
Expand All @@ -94,8 +101,10 @@ services:
DB_LOCAL_URI: ${MATCH_DB_LOCAL_URI}
DB_USERNAME: ${MATCH_DB_USERNAME}
DB_PASSWORD: ${MATCH_DB_PASSWORD}
JWT_SECRET: ${JWT_SECRET}
BROKER_URL: ${BROKER_URL}
depends_on:
match-broker:
broker:
condition: service_healthy
networks:
- gateway-network
Expand All @@ -113,25 +122,57 @@ services:
networks:
- match-db-network
restart: always
match-broker:
container_name: match-broker
hostname: match-broker

broker:
container_name: broker
hostname: broker
image: rabbitmq:4.0.2
user: rabbitmq
networks:
- match-db-network
- gateway-network
healthcheck:
test: rabbitmq-diagnostics check_port_connectivity
interval: 30s
timeout: 30s
retries: 10
start_period: 30s
restart: always

collaboration:
container_name: collaboration
image: collaboration
build:
context: services/collaboration
dockerfile: Dockerfile
environment:
COLLAB_DB_CLOUD_URI: ${COLLAB_DB_CLOUD_URI}
COLLAB_DB_LOCAL_URI: ${COLLAB_DB_LOCAL_URI}
YJS_DB_CLOUD_URI: ${YJS_DB_CLOUD_URI}
YJS_DB_LOCAL_URI: ${YJS_DB_LOCAL_URI}
BROKER_URL: ${BROKER_URL}
JWT_SECRET: ${JWT_SECRET}
depends_on:
broker:
condition: service_healthy
networks:
- gateway-network
- collaboration-db-network
restart: always

collaboration-db:
container_name: collaboration-db
image: mongo:7.0.14
volumes:
- collaboration-db:/data/db
networks:
- collaboration-db-network
restart: always

volumes:
question-db:
user-db:
match-db:
collaboration-db:

networks:
gateway-network:
Expand All @@ -142,3 +183,5 @@ networks:
driver: bridge
match-db-network:
driver: bridge
collaboration-db-network:
driver: bridge
Loading

0 comments on commit 1667d91

Please sign in to comment.