Skip to content

Commit 57b1da9

Browse files
committed
Update readme
1 parent 4fd4834 commit 57b1da9

File tree

10 files changed

+45
-24
lines changed

10 files changed

+45
-24
lines changed

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,28 @@
44

55
We will be using Docker to set up PeerPrep. Install Docker [here](https://docs.docker.com/get-started/get-docker).
66

7-
Follow the instructions in the [backend directory](./backend/) first before proceeding.
7+
Follow the instructions in [here](./backend/README.md) first before proceeding.
8+
9+
1. Build all the services (without using cache).
10+
11+
```
12+
docker-compose build --no-cache
13+
```
14+
15+
2. Run all the services (in detached mode).
16+
17+
```
18+
docker-compose up -d
19+
```
20+
21+
To stop all the services, use the following command:
822

9-
Run:
1023
```
11-
docker-compose up --build
24+
docker-compose down
1225
```
1326

1427
## Useful links
1528

1629
- User Service: http://localhost:3001
1730
- Question Service: http://localhost:3000
18-
- Frontend: http://localhost:5173
31+
- Frontend: http://localhost:5173

backend/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
3. Your local Mongo URI will be `mongodb://<MONGO_INITDB_ROOT_USERNAME>:<MONGO_INITDB_ROOT_PASSWORD>@mongo:27017/`. Take note of it as we will be using in the `.env` file in the various microservices later on.
1212

13-
5. You can view the MongoDB collections locally using Mongo Express. To set up Mongo Express, update `ME_CONFIG_BASICAUTH_USERNAME` and `ME_CONFIG_BASICAUTH_PASSWORD`. The username and password will be the login credentials when you access Mongo Express at http://localhost:8081.
13+
4. You can view the MongoDB collections locally using Mongo Express. To set up Mongo Express, update `ME_CONFIG_BASICAUTH_USERNAME` and `ME_CONFIG_BASICAUTH_PASSWORD`. The username and password will be the login credentials when you access Mongo Express at http://localhost:8081.
1414

1515
## Setting-up cloud MongoDB (in production)
1616

@@ -49,7 +49,6 @@
4949

5050
![alt text](./GuideAssets/Selection4.png)
5151

52-
5352
![alt text](./GuideAssets/Security.png)
5453

5554
7. Next, click on `Add my Current IP Address`. This will whitelist your IP address and allow you to connect to the MongoDB Database.
@@ -61,23 +60,26 @@
6160
9. [Optional] Whitelisting All IP's
6261

6362
1. Select `Network Access` from the left side pane on Dashboard.
64-
![alt text](./GuideAssets/SidePane.png)
63+
64+
![alt text](./GuideAssets/SidePane.png)
6565

6666
2. Click on the `Add IP Address` Button
67-
![alt text](./GuideAssets/AddIPAddress.png)
67+
68+
![alt text](./GuideAssets/AddIPAddress.png)
6869

6970
3. Select the `ALLOW ACCESS FROM ANYWHERE` Button and Click `Confirm`
70-
![alt text](./GuideAssets/IPWhitelisting.png)
71+
72+
![alt text](./GuideAssets/IPWhitelisting.png)
7173

7274
4. Now, any IP Address can access this Database.
7375

7476
10. After setting up, go to the Database Deployment Page. You would see a list of the Databases you have set up. Select `Connect` on the cluster you just created earlier.
7577

76-
![alt text](GuideAssets/ConnectCluster.png)
78+
![alt text](GuideAssets/ConnectCluster.png)
7779

7880
11. Select the `Drivers` option.
7981

80-
![alt text](GuideAssets/DriverSelection.png)
82+
![alt text](GuideAssets/DriverSelection.png)
8183

8284
12. Select `Node.js` in the `Driver` pull-down menu, and copy the connection string.
8385

backend/question-service/.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
NODE_ENV=development
22

33
MONGO_CLOUD_URI=<MONGO_CLOUD_URI>
4-
MONGO_LOCAL_URI=mongodb://root:example@mongo:27017/
4+
MONGO_LOCAL_URI=<MONGO_LOCAL_URI>
55

66
FIREBASE_PROJECT_ID=<FIREBASE_PROJECT_ID>
77
FIREBASE_PRIVATE_KEY=<FIREBASE_PRIVATE_KEY>

backend/question-service/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Question Service
22

3-
> If you have not set-up either a local or cloud MongoDB, go [here](../) first before proceding.
3+
> If you have not set-up either a local or cloud MongoDB, go [here](../README.md) first before proceding.
44
55
## Setting-up Firebase
66

@@ -32,7 +32,9 @@
3232

3333
1. In the `question-service` directory, create a copy of the `.env.sample` file and name it `.env`.
3434

35-
2. Update `MONGO_CLOUD_URI`, `MONGO_LOCAL_URI`, `FIREBASE_PROJECT_ID`, `FIREBASE_PRIVATE_KEY`, `FIREBASE_CLIENT_EMAIL`, `FIREBASE_STORAGE_BUCKET`.
35+
2. To connect to your cloud MongoDB instead of your local MongoDB, set the `NODE_ENV` to `production` instead of `development`.
36+
37+
3. Update `MONGO_CLOUD_URI`, `MONGO_LOCAL_URI`, `FIREBASE_PROJECT_ID`, `FIREBASE_PRIVATE_KEY`, `FIREBASE_CLIENT_EMAIL`, `FIREBASE_STORAGE_BUCKET`.
3638
- `FIREBASE_PROJECT_ID` is the value of `project_id` found in the downloaded json file.
3739
- `FIREBASE_PRIVATE_KEY` is the value of `private_key` found in the downloaded json file.
3840
- `FIREBASE_CLIENT_EMAIL` is the value of `client_email` found in the downloaded json file.
@@ -53,10 +55,8 @@
5355
1. With Docker
5456

5557
- Run `docker ps` to get a list of the Docker containers on your machine.
56-
5758
- Retrieve the `CONTAINER_ID` of `peerprep/question-service`.
58-
59-
- Run `docker exec -it <CONTAINER_ID> npm run seed`.
59+
- Run `docker exec -it <CONTAINER_ID> npm run seed`.
6060

6161
2. Without Docker
6262

backend/question-service/config/db.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const connectDB = async () => {
1515
}
1616

1717
await mongoose.connect(mongoDBUri);
18-
console.log("MongoDB connected");
1918
} catch (error) {
2019
console.error(error);
2120
process.exit(1);

backend/question-service/server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ const PORT = process.env.PORT || 3000;
66
if (process.env.NODE_ENV !== "test") {
77
connectDB()
88
.then(() => {
9-
console.log("MongoDB connected");
9+
console.log("MongoDB Connected!");
1010

1111
app.listen(PORT, () => {
12-
console.log(`Server running on port ${PORT}`);
12+
console.log(
13+
`Question service server listening on http://localhost:${PORT}`,
14+
);
1315
});
1416
})
1517
.catch((err) => {

backend/user-service/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
coverage
12
node_modules
23
tests
34
.env*

backend/user-service/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# User Service Guide
22

3-
> If you have not set-up either a local or cloud MongoDB, as well as Firebase, go [here](../) first before proceding.
3+
> If you have not set-up either a local or cloud MongoDB, as well as Firebase, go [here](../README.md) first before proceding.
44
55
## Setting-up
66

77
1. In the `user-service` directory, create a copy of the `.env.sample` file and name it `.env`.
88

9-
2. Update `MONGO_CLOUD_URI`, `MONGO_LOCAL_URI`, `FIREBASE_PROJECT_ID`, `FIREBASE_PRIVATE_KEY`, `FIREBASE_CLIENT_EMAIL`, `FIREBASE_STORAGE_BUCKET`, `JWT_SECRET`.
9+
2. To connect to your cloud MongoDB instead of your local MongoDB, set the `NODE_ENV` to `production` instead of `development`.
1010

11-
3. A default admin account (`email: [email protected]` and `password: Admin@123`) wil be created. If you wish to change the default credentials, update them in `.env`. Alternatively, you can also edit your credentials and user profile after you have created the default account.
11+
3. Update `MONGO_CLOUD_URI`, `MONGO_LOCAL_URI`, `FIREBASE_PROJECT_ID`, `FIREBASE_PRIVATE_KEY`, `FIREBASE_CLIENT_EMAIL`, `FIREBASE_STORAGE_BUCKET`, `JWT_SECRET`.
12+
13+
4. A default admin account (`email: [email protected]` and `password: Admin@123`) wil be created. If you wish to change the default credentials, update them in `.env`. Alternatively, you can also edit your credentials and user profile after you have created the default account.
1214

1315
## Running User Service without Docker
1416

frontend/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
coverage
12
node_modules
3+
*.md

frontend/src/contexts/AuthContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const AuthProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
5656
});
5757
} else {
5858
setUser(null);
59-
setLoading(false);
59+
setTimeout(() => setLoading(false), 500);
6060
}
6161
}, []);
6262

0 commit comments

Comments
 (0)