In this project, you are task with working on an existing application. A significant part of the challenge will be to familiarise yourself with the codebase you've inherited, as you work to improve and extend it.
This repo contains two applications:
- A frontend React App
- A backend api server
These two applications will communicate through HTTP requests, and need to be run separately.
More documentation of the codebase and its architecture can be found here. It's recommended you all read the suggested docs after making sure the whole setup below worked for everyone. Then work together on a diagram describing how the application works.
If you haven't already, make sure you have node and NVM installed.
- Install Node Version Manager (NVM)
Then follow the instructions to update your
brew install nvm~/.bash_profile. - Open a new terminal
- Install the latest version of Node.js, (
20.5.0at time of writing).nvm install 20
-
Install dependencies for both the
frontendandapiapplications:cd frontend npm install npm install apexcharts --save cd ../api npm install -
Install MongoDB
brew tap mongodb/brew brew install mongodb-community@6.0Note: If you see a message that says
If you need to have mongodb-community@6.0 first in your PATH, run:, follow the instruction. Restart your terminal after this. -
Start MongoDB
brew services start mongodb-community@6.0 -
Install React Map
npm install @react-map/world npm install d3 -
Install React Tooltip
npm install react-tooltip
We need to create two .env files, one in the frontend and one in the api.
Create a file frontend/.env with the following contents:
VITE_BACKEND_URL="http://localhost:3000"
Create a file api/.env with the following contents:
MONGODB_URL="mongodb://0.0.0.0/Terra"
NODE_ENV="development"
JWT_SECRET="secret"
For an explanation of these environment variables, see the documentation.
- Save your API
; create an apiKey.js file - ensure it's at the top level
- Seed the data:
; delete the cities table Table Plus
; cd models
; node apiToMongo.js
- Start the server application (in the
apidirectory) in dev mode:
; cd .. (up to the `api` directory)
; npm run dev
- Start the front end application (in the
frontenddirectory)
In a new terminal session...
; cd frontend
; npm run dev
You should now be able to open your browser and go to
http://localhost:5174/ to view the site.