node-mongo-demo
node.js and mongodb demo
git clone https://9o.is/git/node-mongo-demo.git
readme.md
(1336B)
1 # Node.js MongoDB Demo
2
3 A Node.js and MongoDB demo.
4
5 ## Backend Architecture
6
7 See the architecture document for details on design decisions for
8 the backend lucky7 code.
9
10 ## Project setup
11
12 Enter each folder:
13
14 - backend
15 - frontend
16
17 and run the following command
18
19 ```bash
20 npm install
21 ```
22 ---
23
24 ## Backend
25
26 To run the backend, you first need a MongoDB replica set.
27 A replica set is required because the backend uses MongoDB change streams.
28 To run a replica set locally, run the following command in the backend folder.
29
30 ```bash
31 npm run db
32 ```
33
34 The above command should print the connection string to connect to the
35 replica set locally. Create a **.env file** and populate the `MONGODB_URL`.
36
37
38 Now in the backend folder. Run the start command in a separate terminal.
39
40 ```bash
41 npm run start
42 ```
43
44 The backend is now up and running. There's a working frontend demo,
45 so feel free to test the API from there. There's also a
46 populate script to generate users and bets to inspect the
47 leaderboard endpoint.
48
49 ```bash
50 MONGODB_URL="<INPUT URL>" node scripts/populate_database.js
51 ```
52
53 To run unit and integration tests:
54
55 ```bash
56 npm run test
57 npm run test:integration
58 ```
59
60 Note, the app was tested with Node v20.18.1
61
62 ---
63
64 ## Frontend
65
66 The frontend is your standard create-react-app, the default ReadME is provided under frontend/readme.md for reference.