FastAPI backend for municipal complaint resolution:
- Firebase-authenticated users create civic issues with description + GPS + optional photo key.
- AI routes issues to a department (description-only), assigns priority (P0-P3), and clusters duplicates (geo + text).
- Main admin manages departments and department admins.
- Department admins process issue statuses.
- Community module supports posts, comments, and votes.
- Resources module supports admin-published links with title/thumbnail.
- Agent module provides tool-driven assistant actions.
- Create and activate a Python 3.11+ virtual environment.
- Install dependencies:
pip install -r requirements.txt
- Create
.envfrom.env.exampleand set real values. - Start API:
uvicorn app.main:app --reload
- Tables are auto-created at startup using SQLAlchemy
Base.metadata.create_all(). - This only creates missing tables.
- It does not apply schema migrations for changed columns/types. For schema changes, run manual SQL updates.
- Reporter:
POST /v1/issuesGET /v1/issues/{issue_id}GET /v1/issues/me
- Main admin:
POST/GET/PATCH /v1/departmentsPOST/GET /v1/departments/{department_id}/adminsGET /v1/issuesGET /v1/clusters
- Department admin:
GET /v1/departments/{department_id}/issuesPATCH /v1/issues/{issue_id}/status
- Community:
POST /v1/community/postsGET /v1/community/postsPOST /v1/community/posts/{post_id}/votePOST /v1/community/posts/{post_id}/commentsPOST /v1/community/comments/{comment_id}/vote
- Resources:
POST /v1/resourcesGET /v1/resourcesGET /v1/resources/{resource_id}
- Agent:
POST /v1/agent/chat
All protected routes require:
Authorization: Bearer <firebase_id_token>