How sajawalkhan01/civicpulse works
CivicPulse accepts free-text municipal complaints, classifies and prioritizes them, stores them for municipal follow-up, and exposes operational views. The main workflow runs from citizen intake through the frontend API client, complaint route, service, triage and persistence; separate branches cover status transitions, statistics, health/readiness, and provider observability. The graph uses source excerpts and the source index for backend relationships, plus README-documented product capabilities; some frontend internals and unsampled route wiring are therefore shown only at a broad level.
Main entry points: main.py FastAPI App · triage_service.py Triage Orchestrator · complaints.py Complaint Service · factory.py Provider Selection
Components 34
Citizen and Operator UI
- Web Application
frontend/src/App.tsx - Complaint Intake
frontend/src/pages/submit-page.tsx - Complaint Dashboard
frontend/src/pages/dashboard-page.tsx - Statistics View
frontend/src/pages/stats-page.tsx - Frontend API Client
frontend/src/api/complaints.ts
Complaint API
- Complaint Routes
backend/app/routes/complaints.py - Complaint Service
backend/app/services/complaints.py - Complaint and Triage Models
backend/app/domain/models.py - Status State Machine
backend/app/domain/state_machine.py
Triage Providers
- Triage Orchestrator
backend/app/services/triage_service.py - Provider Selection
backend/app/providers/triage/factory.py - Triage Provider Contract
backend/app/domain/protocols.py - Groq LLM Provider
backend/app/providers/triage/llm.py - Ollama Provider
backend/app/providers/triage/ollama.py - Rules and Fallback
backend/app/providers/triage/rules.py
Persistence and Cache
- Complaint Repository
backend/app/repositories/complaints.py - Complaint ORM Model
backend/app/models.py - PostgreSQL
- Cache Selection
backend/app/providers/cache/factory.py - Redis Cache
backend/app/providers/cache/redis_cache.py - In-Memory Cache
backend/app/providers/cache/in_memory_cache.py - Redis
Operations
- FastAPI App
backend/app/main.py - Statistics Route
backend/app/routes/stats.py - Provider Metadata Route
backend/app/routes/meta.py - Health and Readiness
backend/app/routes/readiness.py - Readiness Checks
backend/app/services/readiness.py - Metrics Middleware
backend/app/middleware/metrics.py - Rate Limit Middleware
backend/app/middleware/rate_limit.py - Rate Limiter
backend/app/providers/rate_limiter.py - Metrics Endpoint
backend/app/routes/observability.py
Other components
- Citizen / Operator
- Groq Cloud
- Ollama Runtime
Connections 34
- Citizen / Operator → Web Application: uses
README.md - Web Application → Complaint Routes: submits HTTP
README.md - Complaint Intake → Frontend API Client: submits through
- Complaint Dashboard → Frontend API Client: loads records
- Statistics View → Frontend API Client: loads statistics
- Complaint Routes → Complaint Service: delegates
backend/app/routes/complaints.py - Complaint Service → Triage Orchestrator: requests triage
backend/app/services/complaints.py - Complaint Service → Complaint Repository: persists and queries
backend/app/services/complaints.py - Complaint Service → Status State Machine: validates transitions
backend/app/services/complaints.py - Complaint Routes → Complaint and Triage Models: validates payloads
backend/app/routes/complaints.py - Triage Orchestrator → Provider Selection: selects provider
backend/app/services/triage_service.py - Triage Orchestrator → Rules and Fallback: falls back to
backend/app/services/triage_service.py - Triage Orchestrator → Cache Selection: gets cache
backend/app/services/triage_service.py - Provider Selection → Groq LLM Provider: selects
backend/app/providers/triage/factory.py - Provider Selection → Ollama Provider: selects
backend/app/providers/triage/factory.py - Provider Selection → Rules and Fallback: selects
backend/app/providers/triage/factory.py - Groq LLM Provider → Groq Cloud: calls API
backend/app/providers/triage/llm.py - Ollama Provider → Ollama Runtime: calls model
- Complaint Repository → Complaint ORM Model: queries
backend/app/repositories/complaints.py - Complaint ORM Model → PostgreSQL: stores complaints
README.md - Cache Selection → Redis Cache: chooses
backend/app/providers/cache/factory.py - Cache Selection → In-Memory Cache: chooses
backend/app/providers/cache/factory.py - Redis Cache → Redis: reads and writes
backend/app/providers/cache/redis_cache.py - FastAPI App → Complaint Routes: registers
backend/app/main.py - FastAPI App → Statistics Route: registers
backend/app/main.py - FastAPI App → Provider Metadata Route: registers
backend/app/main.py - FastAPI App → Health and Readiness: registers
backend/app/main.py - FastAPI App → Metrics Middleware: installs
backend/app/main.py - FastAPI App → Rate Limit Middleware: installs
backend/app/main.py - Rate Limit Middleware → Rate Limiter: uses
backend/app/middleware/rate_limit.py - Health and Readiness → Readiness Checks: checks readiness
backend/app/routes/readiness.py - Provider Metadata Route → Triage Orchestrator: reads provider status
backend/app/routes/meta.py - Statistics Route → Complaint Repository: aggregates records
- Metrics Endpoint → Metrics Middleware: exposes metrics