- Ensure that you have PostgreSQL, MongoDB, Redis and node v18 installed.
- Ensure that you have yarn v1.22.19 installed (e.g.
npm i -g yarn
). - Start PostgreSQL, MongoDB and Redis (e.g.
brew services start redis
if installed via Homebrew on MacOS) cd
to thebackend
directory.- Run
yarn install
. - Copy the
.env.example
file as.env
(e.g.cp .env.example .env
) and update the variables where necessary (you may find the Environment Variables setup section below useful). - Setup and populate the databases via
yarn migrate-and-seed:all
. - Open multiple terminals to the
backend
directory, and run each microservice in 'watch' mode (e.g.yarn start:dev http-gateway
,yarn start:dev ws-gateway
,yarn start:dev question
).NOTE: The complete list of microservices are the directory names under the
backend/apps
directory. All microservices have to be started for the backend to run correctly.
The teaching team can choose to setup the dockerized backend locally as follows:
- Install Docker Desktop if you have not already done so.
- Copy the
.env.docker.example
file as.env.docker
(e.g.cp .env.docker.example .env.docker
) and update the remaining empty secrets (you may find the Environment Variables setup section below useful). - In the
backend
directory, runyarn start:docker
to build and run all Dockerized microservices in detached mode locally. - Run
yarn stop:docker
to stop the microservice containers.
- Install Docker Desktop if you have not already done so.
- In the
backend
directory, runyarn test
to run the E2E tests
- Create a knex (SQL) database migration file via
yarn migrate:sql:make {microservice_name} {migration_file_name}
. - To rollback a knex migration, run
yarn knex {microservice_name} migrate:rollback
.
- Run
yarn lint
andyarn format
in thebackend
directory to lint and format the backend codebase.
- To test out CRUD operations with questions, update the role_id column of the you want entry in the user_profiles table in the peer-prep-user-service database. (e.g.
UPDATE user_profiles SET role_id=1 WHERE name='Your Name'
)
- For local PostgreSQL,
{MICROSERVICE}_SERVICE_SQL_DATABASE_HOST
can be left blank - Update the USER and PASSWORD related variables
- Populate CHATBOT_SERVICE_OPENAI_API_KEY={Your own API key from open AI}
- Set
ACCESS_TOKEN_SECRET
andREFRESH_TOKEN_SECRET
to some random secret string - Set the corresponding expiries to something desired (e.g.
1h
or30s
or7d
)
- From Google Console, generate a set of OAuth credentials and put it under
OAUTH_GOOGLE_ID
andOAUTH_GOOGLE_SECRET
- For local development:
- Under
Authorized JavaScript origins
, addhttp://localhost:4000
- Under
Authorized Redirect URIs
, addhttp://localhost:4000/v1/auth/google/redirect
(if running via Docker as per the section Building locally with Docker above)http://localhost/v1/auth/google/redirect
(if running via Kubernetes and minikube as per the instructions here)- OR simply add both
- Under
- For production deployment:
- Replace
Authorized JavaScript origins
with the production frontend URL - Replace
Authorized Redirect URIs
with the production backend domain with the same endpoints above
- Replace