Community road hazard reporter — pin it, verify it, fix it. Built with Next.js 15 + Cloudflare Pages + Cloudflare Workers. Uses D1 for relational data, R2 for photo storage, KV for sessions/leaderboard cache, and Durable Objects for review aggregation and leaderboard recomputation.
- Clone the repo.
- Install dependencies:
npm install
- Configure Wrangler:
- Create a Cloudflare D1 database, KV namespace, and R2 bucket.
- Update
wrangler.toml with the real IDs.
- Deploy D1 migrations:
npx wrangler d1 migrations apply pothole-patrol-db
- Deploy Durable Objects + Workers:
npx wrangler deploy
- Build locally:
npm run build
- Deploy to Cloudflare Pages:
npm run pages:build && npm run pages:deploy
| Name |
Description |
Where |
NEXTAUTH_SECRET |
Auth secret |
wrangler secret put |
NEXT_PUBLIC_APP_URL |
App domain |
wrangler.toml vars |
| Path |
Purpose |
src/app/api/reports |
Reports API (list, create) |
src/app/api/reports/[id] |
Report detail API |
src/app/api/reports/[id]/reviews |
Vote/review API |
src/app/api/upload/presign |
R2 presigned URL generation |
src/app/api/leaderboard |
Leaderboard list API |
workers/durable-objects/ReviewAggregator.ts |
Per-report vote tally + status update |
workers/durable-objects/Leaderboard.ts |
Recalculate leaderboard every 5 min |
db/migrations/0001_init.sql |
D1 schema migrations |
- App uses raw SQL via D1
prepare()/bind()/run().
- Photos are uploaded to R2 via presigned PUT URLs (placeholder implementation using aws4fetch).
- Review weight defaults to 1.0 until reviewer accuracy scoring is implemented.
- Tier progression: Community → Trusted (10 verified) → Verified (50 verified).
- Municipal API, push notifications, AI image validation, heatmap view, i18n, route planner.