cd civicfix
pip install flask flask-cors
python app.pyThen open: http://localhost:5000
civicfix/
├── app.py ← Flask backend (all API logic)
├── requirements.txt
├── data/
│ └── incidents.json ← auto-created on first run (demo data seeded)
└── templates/
├── index.html ← Landing page
├── report.html ← Citizen report form
└── dashboard.html ← Admin dashboard + chatbot
| URL | What it is |
|---|---|
/ |
Landing page — pitch-ready hero + features |
/report |
Citizen report form with GPS + AI classification |
/dashboard |
Admin: overview, incidents, map, analytics, chatbot |
| Method | Endpoint | What it does |
|---|---|---|
| POST | /api/submit |
Submit a citizen report, get AI classification |
| GET | /api/incidents |
All incidents (sorted by priority) |
| GET | /api/incidents/<id> |
Single incident detail |
| PATCH | /api/incidents/<id>/status |
Update incident status |
| GET | /api/stats |
Stats for dashboard cards + charts |
The classification is rule-based keyword matching — fast, free, demo-ready:
- Issue type detection — scans description for keywords (leak, pipe → Water Leak, pothole, road → Pothole, etc.)
- Priority scoring — keywords like "school", "hospital", "burst", "flooding" elevate priority
- Duplicate detection — same issue type + within 150m + incident not resolved + within 72hrs → link to existing incident
- Auto-escalation — 5+ duplicate reports → High, 10+ reports → Critical
To plug in OpenAI later: replace the classify() function in app.py with an API call.
- Go to
/report - Click "📍 Detect" to capture location (or it uses Cape Town defaults)
- Type: "Burst pipe flooding the road near the primary school"
- Hit Submit — watch it classify as Water Leak, High/Critical priority
- Submit again from same location — it detects duplicate and links reports
- Go to
/dashboard— see it at the top of the priority queue - Show the map view — incident pin grows with each report
- Use the AI assistant: "What needs urgent attention?"
8 pre-seeded incidents across Cape Town covering all issue types and statuses. Located around the -33.92, 18.42 area.
"CivicFix AI turns geolocated citizen complaints into prioritised municipal action."