- Add hotspot calculation methods to analytics service - Implement MySQL spatial queries for clustering (5+ reports within 500m) - Calculate severity scores based on report count and frequency - Create GET /api/analytics/hotspots endpoint - Create GET /api/analytics/hotspots/:id endpoint for details - Create POST /api/analytics/hotspots/calculate for manual trigger - Implement scheduled job with node-cron (runs every 5 minutes) - Add comprehensive test scripts for hotspot functionality - Create detailed implementation documentation Requirements addressed: - 3.2: Identify areas with 5+ reports within 500m radius - 3.3: Rank hotspots by severity score - 3.4: Update calculations within 5 minutes - 3.5: Provide data for map visualization with severity indicators
Beach Litter Mapping API
Backend API server for the Beach Litter Mapping Platform.
Setup
- Install dependencies:
cd server
npm install
- Configure environment variables:
cp .env.example .env
# Edit .env with your configuration
- Set up the database:
npm run prisma:generate
npm run prisma:migrate
- Start the development server:
npm run dev
The API will be available at http://localhost:3000
API Endpoints
Reports
POST /api/reports/upload- Upload a photo (requires auth)POST /api/reports- Create a new report (requires auth)GET /api/reports- Get all reports (with optional filters)GET /api/reports/:id- Get a single reportDELETE /api/reports/:id- Delete a report (requires auth, owner only)
Health Check
GET /health- Server health status
Environment Variables
See .env.example for required environment variables.
Database
The API uses MySQL 8.0+ with Prisma ORM. Connection details are configured in the .env file.
Authentication
Authentication is handled by Clerk. Protected endpoints require a Bearer token in the Authorization header.