# CleanRoute Ghana — Backend API
GPS-pin based waste collection coordination & illegal dumping reporting platform for CSBC 252 (Introduction to Cloud Computing).
## Stack
- Node.js / Express
- MySQL (Amazon RDS)
- JWT auth with role-based access control (resident / dispatcher / admin)
- AWS S3 (presigned uploads for evidence photos)
- AWS Secrets Manager (DB credentials — never hardcoded)
## Local setup
```
npm install
cp .env.example .env # fill in JWT_SECRET at minimum
npm run dev
```
To run against a local MySQL instead of RDS, uncomment the `DB_*` variables in `.env`.
## Database
Schema lives in `src/db/schema.sql`, matching the ERD in the System Design Document exactly:
`users`, `locations`, `collection_requests`, `issue_reports`, `violation_reports`, `route_assignments`.
Apply it against RDS:
```
mysql -h -u -p cleanroute 0`. In production this metric should be refreshed by a scheduled job (e.g. EventBridge + Lambda) rather than only on-demand when an admin loads the dashboard.
## Security notes
- Violation report evidence (photo, suspect description) is restricted at the query level to the `admin` role — dispatchers are blocked by `requireRole`, residents only ever see their own submission's status.
- Photos never pass through the app server or EC2 local disk — clients upload directly to S3 via presigned URLs.
- DB credentials are pulled from Secrets Manager at runtime using the EC2 instance's IAM role, never stored in code or `.env` on the server.