From 5a88b01da78b62cdfc646040871ebc35c4a40c99 Mon Sep 17 00:00:00 2001 From: chloelim Date: Sat, 18 Nov 2023 14:55:01 +0800 Subject: [PATCH 1/2] chore: add assignment 2 readme --- Assignment2.md | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Assignment2.md diff --git a/Assignment2.md b/Assignment2.md new file mode 100644 index 00000000..83663bb9 --- /dev/null +++ b/Assignment2.md @@ -0,0 +1,80 @@ +# Assignment 2 + +> [!IMPORTANT] +> As of late, the list of questions appear to take very long to load, as there are over 2000 being fetched. Please wait for a minute and a half if you see no questions on the question list page. We apologise for the inconvenience, and seek your understanding. + +## To set up and execute + +### Download +1. Download the ZIP file named `ay2324s1-course-assessment-g17-Assignment-2.zip` from [Assignment-2](https://github.com/CS3219-AY2324S1/ay2324s1-course-assessment-g17/releases/tag/Assignment-2). +2. Unzip the file and navigate to the folder `ay2324s1-course-assessment-g17-Assignment-2`. + +### Include .env files +3. Set up the environment for the question service, user service, and frontend by including the `.env` files for each, which have been submitted as: +`Assignment2-QuestionServiceEnv.txt`, +`Assignment2-UserServiceEnv.txt`, +`Assignment2-FrontendEnv.txt` respectively. +Make sure they are `.env` files within the question service, user service, and frontend directories. + +For convenience, they have been placed here: + +`Assignment2-QuestionServiceEnv.txt` +``` +MONGO_CONNECTION_STRING=mongodb+srv://sherylhci:wsY2vQnTjSStiIQ8@cluster0.kxz8d7c.mongodb.net/peerprep_app?retryWrites=true&w=majority +PORT=8080 +ACCESS_TOKEN_SECRET="access_secret" +REFRESH_TOKEN_SECRET="refresh_secret" +FRONTEND_URL="http://localhost:3000" +``` + +`Assignment2-UserServiceEnv.txt` +``` +DATABASE_URL="postgresql://postgres@localhost:5432/postgres?schema=public" +PORT=8000 +ACCESS_TOKEN_SECRET="access_secret" +REFRESH_TOKEN_SECRET="refresh_secret" +FRONTEND_URL="http://localhost:3000" +``` + +`Assignment2-FrontendEnv.txt` +``` +REACT_APP_BACKEND_URL=http://localhost:8080/api +REACT_APP_USER_SERVICE_BACKEND_URL=http://localhost:8000/ +``` + +### Install dependencies +4. Change into each directory (`frontend`, `backend/question-service`, `backend/user-service`) and run `npm install` to install the dependencies for the question service, user service, and frontend. + +### Set up postgresql +5. Start the postgresql used by the frontend by running below on another terminal window. + +``` +docker run --rm -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres; +``` + +6. Then navigate to the user service directory (i.e. `ay2324s1-course-assessment-g17-Assignment-2/ay2324s1-course-assessment-g17-Assignment-2/backend/user-service`) and run the following commands: + +``` +npx prisma db push +npx prisma db seed +``` + +This will set up the postgresql database schema, and also seed the database with 1 ADMIN role user account, the "designated maintainer role" account, and 1 USER role user accounts, "registered users". Details for usernames and passwords below. + +``` +ADMIN role account details: +username: admin_user +password: admin_password + +USER role account details: +username: regular_user +password: user_password +``` + +Other accounts signed up from the application interface are all USER role user accounts, "registered users". + +## Finished set up +7. `npm start` the question service, user service, and frontend. + +## Notes +To see the user database, you can simply run the command `npx prisma studio`, which will open up an interface for you to easily view the user database. From 5493b2b39178c1a6401521f2f814e779373bd2e2 Mon Sep 17 00:00:00 2001 From: "Justin Lam, juslam19" <77272958+juslam19@users.noreply.github.com> Date: Sat, 18 Nov 2023 15:40:47 +0800 Subject: [PATCH 2/2] Update Assignment2.md Co-authored-by: see leng <34371483+seelengxd@users.noreply.github.com> --- Assignment2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assignment2.md b/Assignment2.md index 83663bb9..663a3c16 100644 --- a/Assignment2.md +++ b/Assignment2.md @@ -6,7 +6,7 @@ ## To set up and execute ### Download -1. Download the ZIP file named `ay2324s1-course-assessment-g17-Assignment-2.zip` from [Assignment-2](https://github.com/CS3219-AY2324S1/ay2324s1-course-assessment-g17/releases/tag/Assignment-2). +Download the ZIP file named `ay2324s1-course-assessment-g17-Assignment-2.zip` from [Assignment-2-Updated](https://github.com/CS3219-AY2324S1/ay2324s1-course-assessment-g17/releases/tag/Assignment-2-Updated). 2. Unzip the file and navigate to the folder `ay2324s1-course-assessment-g17-Assignment-2`. ### Include .env files