This is the backend server for the Threshold project, built to help law enforcement officers track and improve their performance and physiological readiness during training exercises.
It is designed to:
- Collect heart rate and accuracy (MANTIS system) data
- Store the data securely in a MySQL (AWS RDS) database
- Process and serve data for visualization on the web dashboard
- Handle uploads directly from wearable devices (smartwatch app)
- Node.js
- Express.js
- MySQL2
- Multer (for handling CSV uploads)
- Render (for deployment)
- routes.js: Contains all API handlers. May be split into two route handlers for web-app and pixel watch for more readibility.
- db-connection.js: Contains the database connection setup.
- indes.js: Server entry point.
The backend handles:
- User Management: Storing officer information.
- Session Management: Recording training sessions and heart rate data.
- Data Uploads: Allowing officers to upload session CSVs manually or via smartwatch app.
- Graph Data: Providing pre-aggregated performance data for frontend dashboards.
- Secure Storage: Using AWS RDS (MySQL) to persist important training data.
The frontend (website) and the smartwatch app both interact with this backend.
- Inside the backend repository, first run npm install.
- Set up a .env File with the following:
- DB_HOST=your-db-endpoint
- DB_USER=your-db-username
- DB_PASSWORD=your-db-password
- DB_DATABASE=your-db-name
- If running backend locally on your localhost run: node index.js
- On Render, Create a new Web Service
- Connect your github repository.
- Environment: Node.js
- Build Command: npm install
- Start Command: node index.js
- Add the same environment variables on Render.
- Whenever you push your repository, deployment happens automatically. But you can manually deploy the latest commit.
- Use the backend URL Render gives you for your routing logic