Skip to content

CS3219-AY2425S1/cs3219-ay2425s1-project-g38

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Review Assignment Due Date

CS3219 Project (PeerPrep) - AY2425S1

Group: G38

You can view the live project here: https://peerprep.delishad.com

Team Members:

Kubernetes Deployment

  1. Ensure that you have a Kubernetes cluster set up.
  2. Ensure that you have kubectl installed and configured to point to your Kubernetes cluster.
  3. Set up environemnt variables under the config-map.yaml files and secrets.yaml files in the kubernetes directory. Each service also has its own config-map and secret file. Template files have been provided in the kubernetes directory.
  4. Run kubectl apply -f kubernetes/ --recursive to deploy all services to your Kubernetes cluster.

Deploying project locally using docker-compose

  1. Clone this repository to your local machine.
  2. Ensure you have Docker installed.
  3. (Optional) Sign up for a MongoDB Atlas account
    • The docker compose file is configured to use a local MongoDB instance by default. If you would like to use a remote MongoDB instance, you can follow the instructions in the "Remote DB Setup" section below.

Building and starting frontend

  1. Navigate to the frontend directory: cd frontend/peerprep
  2. Duplicate the .env.sample file and rename it to .env
    • if you wish to, you can modify the values in the .env file
      Variable Description Default Value
      NEXT_PUBLIC_USER_SERVICE_URL URL of the user service http://localhost:8004
      NEXT_PUBLIC_QUESTION_SERVICE_URL URL of the question service http://localhost:8003
      NEXT_PUBLIC_MATCHING_SERVICE_URL URL of the matching service http://localhost:8002
      NEXT_PUBLIC_COLLAB_SERVICE_URL URL of the collab service http://localhost:8010
      NEXT_PUBLIC_COLLAB_SOCKET_URL URL of the collab socket service http://localhost:8010
      NEXT_PUBLIC_MATCHING_SOCKET_URL URL of the matching socket service http://localhost:8002
      NEXT_PUBLIC_IMAGE_UPLOAD_KEY AuthToken for image upload None, you can get this from https://www.portive.com, you need this for image uploads to work with the question editor.
      FRONTEND_PORT Port to run the frontend service 3000
      JWT_SECRET Secret for creating JWT signature, make sure this is the same as your user service you-can-replace-this-with-your-own-secret
  3. do npm install to install the required dependencies
  4. do npm run build to build the frontend
  5. do npm run start to start the frontend
  6. Access the frontend at http://localhost:3000

Docker Compose for all Microservices (excluding frontend)

  1. Open a terminal and navigate to the root directory of the project.

  2. Duplicate the .env.sample file and rename it to .env

    • If you wish to, you can modify the values in the .env file
      Variable Description Default Value
      USER_MONGODB_URI MongoDB URI for the user service None, commented out. If you are using a remote MongoDB instance, you can key in your connection string here
      USER_MONGO_INITDB_ROOT_USERNAME MongoDB root username for the user service userroot
      USER_MONGO_INITDB_ROOT_PASSWORD MongoDB root password for the user service userpassword
      GMAIL_USER Gmail account for verification emails None, you can key in your Gmail account here
      GMAIL_PASS Gmail password for verification emails None, you can key in your Gmail password here
      USER_PORT Port to run the user service 8004
      JWT_SECRET Secret for creating JWT signature you-can-replace-this-with-your-own-secret
      FRONTEND_URL URL of the frontend service (Do not change this, its fixed due to NextJS) http://localhost:3000
      QUESTION_MONGODB_URI MongoDB URI for the question service None, commented out. If you are using a remote MongoDB instance, you can key in your connection string here
      QUESTION_MONGO_INITDB_ROOT_USERNAME MongoDB root username for the question service questionroot
      QUESTION_MONGO_INITDB_ROOT_PASSWORD MongoDB root password for the question service questionpassword
      QUESTION_PORT Port to run the question service 8003
      MATCHING_SERVICE_PORT Port to run the matching service 8002
      REDIS_URL URL of the Redis instance for internal access redis://redis:6379
      MATCHING_SERVICE_LOGS_DIR Directory to store logs for the matching service ./logs
      MATCHING_TIMEOUT Timeout for matching in milliseconds 10000
      USER_SERVICE_URL URL of the user service for internal access http://g38-user-service:8004
      COLLAB_SERVICE_URL URL of the collab service for internal access http://g38-collab-service:8010
      QUESTION_SERVICE_URL URL of the question service for internal access http://g38-question-service:8003
      COLLAB_API_KEY API key for the collab service ( used by matching-service for initialising sessions) collab-api-key
  3. Run docker-compose up to start the services.

    • If you keyed in remote MongoDB URIs in the .env file, the MongoDB containers will not be started. The services will connect to the remote MongoDB instances instead.
  4. Once the services are up and running, you can access the frontend at http://localhost:<FRONTEND_PORT> (default: http://localhost:3000)

Docker Compose for individual services

If the services are to be run individually (e.g. for deployment on different platforms), you can follow the instructions below.

Matching Service

  1. cd into the matching-service directory

  2. Duplicate the .env.sample file and rename it to .env

    • If you wish to, you can modify the values in the .env file

      Variable Description Default Value
      MATCHING_SERVICE_PORT Port to run the service 8002
      USER_SERVICE_URL URL of the user service http://localhost:8004
      QUESTION_SERVICE_URL URL of the question service http://localhost:8003
      COLLAB_SERVICE_URL URL of the collab service http://localhost:8010
      COLLAB_API_KEY API key for the collab service ( used by matching-service for initialising sessions) collab-api-key
      REDIS_URL URL of the Redis instance redis://redis:6379
      MATCHING_SERVICE_LOGS_DIR Directory to store logs for the matching service ./logs
      MATCHING_TIMEOUT Timeout for matching in milliseconds 10000
  3. Run docker-compose up to start the matching service.

Question Service

  1. cd into the question-service directory

  2. Duplicate the .env.sample file and rename it to .env

    • If you wish to, you can modify the values in the .env file

      Variable Description Default Value
      QUESTION_MONGODB_URI MongoDB URI None, commented out. If you are using a remote MongoDB instance, you can key in your connection string here
      QUESTION_PORT Port to run the service 8003
      MONGO_INITDB_ROOT_USERNAME MongoDB root username root
      MONGO_INITDB_ROOT_PASSWORD MongoDB root password password
      USER_SERVICE_URL URL of the user service http://localhost:8004
  3. Run docker-compose up to start the question service.

    • If you keyed in a remote MongoDB URI in the .env file, the MongoDB container will not be started. The question service will connect to the remote MongoDB instance instead.

Common Issue and Troubleshooting

Issue: MongoParseError: URI malformed

  • Solution: Ensure that the MONGODB_URI in your .env file is correctly formatted with the right username, password, and database name.

User Service

  1. cd into the user-service directory
  2. Duplicate the .env.sample file and rename it to .env
    • If you wish to, modify the values in the .env file to change the port that the service is hosted on.

      Variable Description Default Value
      USER_MONGODB_URI MongoDB URI None, commented out. If you are using a remote MongoDB instance, you can key in your connection string here
      MONGO_INITDB_ROOT_USERNAME MongoDB root username root
      MONGO_INITDB_ROOT_PASSWORD MongoDB root password password
      GMAIL_USER Gmail account for verification emails None, you can key in your Gmail account here
      GMAIL_PASS Gmail password for verification emails None, you can key in your Gmail password here
      USER_PORT Port to run the service 8004
      ENV Environment - determines if secure cookies should be used PROD
      JWT_SECRET Secret for creating JWT signature you-can-replace-this-with-your-own-secret
  3. Run docker-compose up to start the user service.
    • If you keyed in a remote MongoDB URI in the .env file, the MongoDB container will not be started. The user service will connect to the remote MongoDB instance instead.

Collaboration Service

  1. cd into the collab-service directory
  2. Duplicate the .env.sample file and rename it to .env
    • If you wish to, you can modify the values in the .env file

      Variable Description Default Value
      COLLAB_MONGODB_URI MongoDB URI None, commented out. If you are using a remote MongoDB instance, you can key in your connection string here
      COLLAB_MONGO_INITDB_ROOT_USERNAME MongoDB root username root
      COLLAB_MONGO_INITDB_ROOT_PASSWORD MongoDB root password password
      COLLAB_SERVICE_PORT Port to run the service 8010
      USER_SERVICE_URL URL of the user service http://localhost:8004
      QUESTION_SERVICE_URL URL of the question service http://localhost:8003
      COLLAB_REDIS_URL URL of the Redis instance redis://collab-redis:6379
      COLLAB_API_KEY API key for the collab service collab-api-key

Building your own Docker images

  1. cd into the any of the service directories (question-service, user-service, frontend/peerprep)
  2. Run docker build -t "<image-name>" . to build the Docker image.

Alternatively, you can use the build_and_push_services.sh or build_and_push_services_dev.sh script to build and push all services to the Docker image to Docker Hub.

Microservices API

User Service API Endpoints

The user service API can be found here: User Service API

Question Service API Endpoints

The question service API can be found here: Question Service API

Matching Service API

The matching service API can be found here: Matching Service API

Collaboration Service API

The collaboration service API can be found here: Collaboration Service API

Remote DB Setup (MongoDB Atlas)

  1. Visit the MongoDB Atlas Site https://www.mongodb.com/atlas and click on "Try Free"

  2. Sign Up/Sign In with your preferred method.

  3. You will be greeted with welcome screens. Feel free to skip them till you reach the Dashboard page.

  4. Create a Database Deployment by clicking on the green + Create Button:

alt text

  1. Make selections as followings:
  • Select Shared Cluster
  • Select aws as Provider

alt text

  • Select Singapore for Region

alt text

  • Select M0 Sandbox Cluster (Free Forever - No Card Required)

Ensure to select M0 Sandbox, else you may be prompted to enter card details and may be charged!

alt text

  • Leave Additional Settings as it is

  • Provide a suitable name to the Cluster

alt text

  1. You will be prompted to set up Security for the database by providing Username and Password. Select that option and enter Username and Password. Please keep this safe as it will be used in User Service later on.

alt text

  1. Next, click on Add my Current IP Address. This will whiteliste your IP address and allow you to connect to the MongoDB Database.

alt text

  1. Click Finish and Close and the MongoDB Instance should be up and running.

  2. The connection string can be found by clicking on the Connect button on the Cluster Overview Page. followed by Drivers.

alt text

alt text

alt text

Whitelisting All IP's

  1. Select Network Access from the left side pane on Dashboard.

alt text

  1. Click on the Add IP Address Button

alt text

  1. Select the ALLOW ACCESS FROM ANYWHERE Button and Click Confirm

alt text

Now, any IP Address can access this Database.

About

nus-cs3219-ay2425s1-cs3219-ay2425s1-project-project-template created by GitHub Classroom

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 83.6%
  • JavaScript 13.9%
  • Shell 1.1%
  • HTML 0.5%
  • Lua 0.5%
  • CSS 0.2%
  • Dockerfile 0.2%