Skip to content

Commit

Permalink
Merge branch 'main' into ci-cd-aws-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelim01 committed Nov 1, 2024
2 parents c0b9e6d + 097b6b7 commit d4358d4
Show file tree
Hide file tree
Showing 115 changed files with 9,197 additions and 369 deletions.
17 changes: 13 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,10 +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.
9 changes: 9 additions & 0 deletions compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ services:
ports:
- 27019:27017

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

broker:
ports:
- 5672:5672
Expand All @@ -50,3 +58,4 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 8000:8080
restart: always
70 changes: 55 additions & 15 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,26 @@ services:
- question
- user
- match
- collaboration
networks:
- gateway-network
restart: always

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

question:
container_name: question
image: question
Expand All @@ -34,7 +51,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 @@ -70,7 +91,7 @@ services:
- gateway-network
- user-db-network
restart: always

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

match:
container_name: match
image: match
Expand Down Expand Up @@ -116,25 +137,42 @@ services:
networks:
- match-db-network
restart: always

broker:
container_name: broker
hostname: broker
image: rabbitmq:4.0.2
user: rabbitmq

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
healthcheck:
test: rabbitmq-diagnostics check_port_connectivity
interval: 30s
timeout: 30s
retries: 10
start_period: 30s
- 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 @@ -145,3 +183,5 @@ networks:
driver: bridge
match-db-network:
driver: bridge
collaboration-db-network:
driver: bridge
8 changes: 7 additions & 1 deletion frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
"sourceMap": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.development.ts"
}
]
}
},
"defaultConfiguration": "production"
Expand Down
Loading

0 comments on commit d4358d4

Please sign in to comment.