How isaluki/nightflare works
Nightflare is a Cloudflare Workers implementation of the Nightscout CGM platform, pairing a Nightscout-compatible REST backend with its classic dashboard and an optional modern UI. Users and device apps authenticate, read or upload glucose and treatment data, and receive live updates; the platform also supports profile, food, activity, reporting, administration, and importing from an existing Nightscout. The README documents D1, KV, and Durable Objects; the sampled backend entry point confirms route mounting and UI selection, while detailed wiring inside unsampled route and import handlers is not shown.
Main entry points: index.ts Worker router · collection.ts Collection access · entries.ts Glucose entries · auth.ts Authentication
Components 21
Request and access
- Worker router
src/index.ts - Authentication
src/lib/auth.ts - Admin and roles
src/routes/authorization2.ts
Health data
- Glucose entries
src/routes/entries.ts - Treatments
src/routes/treatments.ts - Device status
src/routes/devicestatus.ts - Profile and food
src/routes/profile.ts - Food catalog
src/routes/food.ts - Activity data
src/routes/activity.ts - Status and Pebble
src/routes/status.ts - Collection access
src/db/collection.ts - D1 database
src/db/index.ts - Mongo-style queries
src/lib/mongo-query.ts
Realtime and import
- Realtime endpoint
src/routes/realtime.ts - Realtime hub
src/durable-objects/realtime-hub.ts - Nightscout import job
src/durable-objects/import-job.ts
User interfaces
- Classic dashboard
client/lib/client/index.js - Modern UI
public/new-ui/app.js - Reports and editors
client/lib/report/reportclient.js
Other components
- Users and apps
- Nightscout source
Connections 29
- Users and apps → Worker router: send requests
- Worker router → Authentication: checks credentials
- Worker router → Glucose entries: dispatches API
- Worker router → Treatments: dispatches API
- Worker router → Device status: dispatches API
- Worker router → Profile and food: dispatches API
- Worker router → Food catalog: dispatches API
- Worker router → Activity data: dispatches API
- Worker router → Status and Pebble: dispatches API
- Worker router → Admin and roles: dispatches API
- Worker router → Realtime endpoint: dispatches socket
- Worker router → Classic dashboard: serves by default
- Worker router → Modern UI: serves when enabled
- Authentication → Admin and roles: checks permissions
- Glucose entries → Collection access: uses storage
- Treatments → Collection access: uses storage
- Device status → Collection access: uses storage
- Profile and food → Collection access: uses storage
- Food catalog → Collection access: uses storage
- Activity data → Collection access: uses storage
- Collection access → D1 database: reads and writes
- Glucose entries → Mongo-style queries: parses filters
- Realtime endpoint → Realtime hub: forwards connection
- Realtime hub → Users and apps: pushes updates
- Nightscout source → Nightscout import job: provides records
- Nightscout import job → Collection access: imports data
- Classic dashboard → Worker router: calls REST API
- Modern UI → Worker router: calls REST API
- Reports and editors → Worker router: requests reports