A real-time emergency event tracking API with SSE (Server-Sent Events) support and PostgreSQL database.
- Bun (v1.3.4 or later)
- PostgreSQL (v14 or later)
bun installCreate a PostgreSQL database:
createdb emergency_copilotCreate a .env file with the following variables:
PORT=8080
GEMINI_API_KEY=your_gemini_api_key_here
OVERSHOOT_API_KEY=your_overshoot_api_key_here
DATABASE_URL=postgresql://username:password@localhost:5432/emergency_copilotGenerate and push database schema:
bun run db:generate
bun run db:pushRun the development server with hot reload:
bun run devThe server will start on http://localhost:8080 (or the port specified in .env).
bun run dev- Start development server with hot reloadbun run db:generate- Generate database migration filesbun run db:migrate- Run pending migrationsbun run db:push- Push schema changes directly (dev only)bun run db:studio- Open Drizzle Studio (visual database browser)
GET /health- Server health status, SSE/WebSocket client counts
GET /incidents- List all incidents (filter by status)GET /incidents/:id- Get incident with videos and countsGET /incidents/:id/timeline- Get AI-generated timeline eventsGET /incidents/:id/snapshots- Get raw snapshots (debug)
GET /videos- List videos (filter by status/incidentId)GET /videos/:id- Get video detailsGET /videos/:id/timeline- Get timeline for specific videoPATCH /videos/:id- Update status or videoUrl
POST /snapshots- Submit snapshot (auto-creates video/incident)GET /snapshots- List snapshotsGET /snapshots/:id- Get specific snapshot
WS /ws/snapshots- Real-time snapshot streaming from callers
GET /stream- Global real-time event stream for dispatchers
For complete API documentation, see API.md.
- API Reference - Full endpoint documentation
- SSE Usage Guide - Server-Sent Events infrastructure
- Database Setup - Schema and migrations
- Overshoot SDK - Video analysis integration
- Next.js Client - Caller client integration
- Dashboard Client - Dashboard integration