The platform is actively developed by the Technology & International Development Lab at Georgia Tech in collaboration with Emory University & the Morehouse School of Medicine. (?)
This platform is a Node.js application with a MongoDB database.
server
is an Express app that hosts both a client-side React application in production and a server-side RESTful web API that queries the database based on user input.
The platform...
- interfaces with the database through the Mongoose model layer.
- is managed in production using PM2.
- pull secrets & API keys from a shared .env file located at the project root folder.
server/
- Contains the source code for theserver
application.client/
- In development, this folder contains the source code for a self-hosted version of the client-side React application that comes with a bunch of goodies that you'll want to use (like hot module reloading). All client-side requests are proxied to the RESTful web API hosted by the server.
- In production, this folder contains a
build/
folder that stores a bundled & optimized version of the React app which is served up as static files by theserver
.
assets/
- Contains image files for this README :-)
-
Clone this repository on your local machine.
-
Download the MongoDB Community server to your computer.
-
Install nvm. We'll use this to install Node.js properly in the next step.
-
Open a terminal and
cd
to your clone of this repository. From there, runnvm install
to install the right version of Node.js onto your machine. -
Run
npm install
in theserver/
andclient/
folders to install their respective dependencies. -
You're done! I'm proud of you. 😁👍
Create an empty .env
file in the root folder for this repo and add the following environment variables using the dotenv format:
SESSION_SECRET
- An alphanumeric secret string used to secure user sessions; should be random.STORE_SECRET
- An alphanumeric secret string used to encrypt user session information in the database; should be random.CALLBACK_URL
- The callback URL used for Oauth. This is only needed for local testing. If not specified, our live website's URL is given.
To populate the database with sample data found in server\src\sampleData.js
, simply start the MongoDB server and run node populateDB.js
within server\src
.
Running the dashboard in development requires starting up two separate Node.js applications.
Open up 2 terminal windows or tabs, and then execute the commands below in the order they are listed, one to each terminal. In each case, make sure to cd
into the corresponding folder first.
- Run the
server
app withnpm run dev
* - Run the
client
app withnpm start
* A default admin user with the name Georgia Tech
and password letmein1
will be created when you run the server
app for the first time.
To do any maintenance on the production deployment of the dashboard, SSH into the virtual machine where the production dashboard is being hosted first.
This project uses PM2 to manage its Node.js applications in production. Below is a handy glossary of important PM2 commands that you'll want in your maintenance tool belt.
Command | Description |
---|---|
pm2 start <process> |
Starts a process. |
pm2 stop <process> |
Stops a process. |
pm2 restart <process> |
Stops and starts a process. |
pm2 status |
Reports the status (e.g. active, stopped, erroring) of all processes. |
pm2 logs <process> |
Prints out the recent logs from a process. |
For all commands above, your options for <process>
are:
fetch
server
These processes are the two Node.js applications described above at the top of the Architecture Overview section.
You've made changes to the source code, and now you want to apply those changes to the deployed dashboard. Depending on where you made your changes, you'll need to run different commands.
First, make sure that you've pushed those changes to this GitHub repo, and then pulled them down on the production VM with git pull
.
If you made changes...
-
in the
client/
folder, runnpm run build
from theclient/
folder to manually build the React app. -
in the
server/
folder, runpm2 restart server
.- if it's the first time running the app, or you're starting a new PM2 instance, instead run
pm2 start ecosystem.config.js
- if it's the first time running the app, or you're starting a new PM2 instance, instead run
And that's it. You've upgraded the dashboard! Woo woo 🎉
In some cases, one way to avoid this problem is to just play with existing data. You'll have to get creative with simulating the production environment, but your development cycle will be much faster as a result!
This project is licensed under the GNU GPLv3 license.