File size: 18,924 Bytes
15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 15cfc64 53be399 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | ---
title: CityTrack
emoji: ποΈ
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: true
---
# CityTrack
```text
______ _ _ _______ _
/ _____(_) | |__ __| | |
| | _| |_ _ _ | |_ __ __ _ ___ | | _____ _ __
| | | | __| | | | | | '__/ _` |/ __|| |/ / _ \ '__|
| |_____ | | |_| |_| | | | | | (_| | (__ | < __/ |
\______||_|\__|\__, | |_|_| \__,_|\___||_|\_\___|_|
_/ |
|___/
```
<div align="center">




</div>
**"Governance at the Speed of Software."**
## β Overview
CityTrack is an autonomous, event-driven operating system for smart cities that transforms civil infrastructure maintenance from reactive to proactive. Unlike traditional 311 systems that rely on manual triage, CityTrack leverages AI agents to instantly detect, validate, and route urban issues - such as potholes, illegal dumping, and damaged signage - without human fatigue or bias. By using citizens as real-time sensors and autonomous agents as the nervous system, CityTrack ensures city-scale, self-healing infrastructure.
## β System Internals: The "Issue Packet"
Every interaction in CityTrack starts with an **Issue Packet** - an immutable, atomic unit of civic data.
**Components:**
- **Evidence:** Primary visual proof (Image/Video) captured via mandatory live camera
- **Context:** High-precision GPS (less than 10m accuracy), Compass Heading, and Device Metadata
- **Intent:** User-provided description, enhanced by NLP
### Anti-Fraud Enforcement
CityTrack implements a "Spot-Check" protocol to ensure data integrity at the source:
1. **Live Camera Only:** The mobile app restricts gallery access. Users MUST capture photos live, preventing the repurposing of old or internet images.
2. **GPS Precision Lock:** Submission is blocked unless GPS accuracy is better than 10 meters.
3. **Identity Binding:** All reports are cryptographically linked to a verified Google Identity (Supabase Auth).
## β The Problem
Traditional urban governance is plagued by:
- **Manual Bottlenecks:** Every report sits in a queue waiting for human categorization
- **Redundancy:** Multiple citizens report the same issue, creating duplicate tickets and wasting resources
- **Data Black Holes:** Citizens rarely receive feedback on their reports, leading to civic frustration
- **Subjective Prioritization:** Urgent issues on main roads are often treated the same as minor issues in quiet alleys
## β The Solution: CityTrack
CityTrack introduces the **"Issue Packet"** - an immutable unit of data containing visual evidence, GPS metadata, and intent. This packet triggers an autonomous chain reaction across a specialized agent pipeline.
### System Architecture
```mermaid
graph TD
A[Citizen Mobile App] -->|Issue Packet| B[FastAPI Backend]
B --> C[Event Bus]
subgraph "Autonomous Agent Pipeline"
C --> D[Vision Agent]
D -->|Annotated Data| E[Geo-Deduplicate Agent]
E -->|Clustered Info| F[Priority Agent]
F -->|Urgency Level| G[Routing Agent]
G -->|Assignment| H[Notification Agent]
end
H --> I[Worker Dashboard]
H --> J[Admin Portal]
H --> K[Citizen Updates]
subgraph "Data Layer"
L[(PostgreSQL)]
M[(Supabase Storage)]
end
D -.-> M
E -.-> L
```
## β The Autonomous Pipeline
The system acts as a nervous system where agents react to the "Issue Packet" in real-time.
### Stage 1: The Senses (Input & Validation)
**Vision Agent: The "Eyes"**
- Uses a fine-tuned YOLOv8s model to scan incoming images
- **Rejection:** Automatically discards irrelevant images (e.g., selfies, blurry photos)
- **Classification:** Identifies defects (Pothole, Debris, Graffiti) with confidence scores
**Geo-Temporal Deduplication Agent: The "Memory"**
- **Clustering:** Uses bounding box queries and haversine distance calculation to find similar reports within X meters and Y hours
- **Merging:** Instead of creating duplicates, it merges reports into a single "Cluster", increasing its urgency score
### Stage 2: The Brain (Decision Making)
**Priority Agent: The "Judge"**
- **Context Awareness:** Combines Vision Confidence + Location Context (e.g., "Near School") + Repeat Count
- **SLA Setting:** Assigns dynamic deadlines (e.g., 4 hours for Critical)
**Routing Agent: The "Dispatcher"**
- **Logic:** Matches issue category to Department (Roads vs Sanitation) and assigns to specific workers based on geolocation and load
### Stage 3: The Enforcers (Execution)
**SLA Watchdog Agent: The "Timekeeper"**
- **AI Monitoring:** Analyzes the context of delayed issues, not just the timer
- **Escalation:** Triggers warnings at 50% and 20% remaining time
**Notification Agent: The "Messenger"**
- **Omnichannel:** Pushes updates to the Citizen (App) and Worker (Task List) simultaneously
- **Email Notifications:** Sends email notifications to respective stakeholders
## β Client Ecosystem
### 1. Citizen Mobile App (The Sensors)
*Built with React Native + Expo (TypeScript)*
- **Offline-First:** Caches reports locally and syncs when connection returns (Beta)
- **Real-Time Tracking:** Server-driven events update the "Processing" screen live as agents complete their tasks
- **Gamification:** Civic points for verified reports (Planned)
### 2. Admin Command Center (The Control)
*Built with Next.js 16 (App Router) + Tailwind CSS*
- **Role-Based Access Control (RBAC):**
- Super Admin: System configuration
- Department Admin: Department-level oversight
- Worker Dashboard: Task submission and resolution
- **Visual Intelligence:** Heatmaps and density plots to identify crumbling infrastructure zones
### 3. Worker Interface (The Hands)
*Mobile-First Web View*
- **Task List:** Simple, priority-sorted list of jobs
- **Navigation:** One-tap deep link to Google Maps
- **Proof of Resolution:** Workers cannot close a ticket without uploading a photo. The Vision Agent verifies this photo against the original to confirm the fix.
## β Technical Architecture
### Modular Monolith Structure
The codebase is structured to scale from a Monolith to Microservices easily.
```text
/
βββ Backend/ # The Core Logic (FastAPI + Async SQLAlchemy)
β βββ agents/ # The Brain: 7 Autonomous Agents
β β βββ vision/ # Vision Agent (YOLOv8)
β β βββ geoDeduplicate/ # Geo-Temporal Deduplication
β β βββ priority/ # Priority Assignment
β β βββ routing/ # Department & Worker Routing
β β βββ sla/ # SLA Monitoring & Watchdog
β β βββ escalation/ # Escalation Management
β β βββ notification/ # Omnichannel Notifications
β βββ api/ # Stateless REST Endpoints
β β βββ routes/ # Admin, Worker, Issue Routes
β βββ core/ # Shared Infrastructure
β β βββ config.py # Configuration Management
β β βββ events.py # Event Bus System
β β βββ flow_tracker.py # Pipeline Orchestration
β β βββ schemas.py # Pydantic Models
β βββ database/ # Database Layer
β β βββ models.py # SQLAlchemy Models
β β βββ connection.py # DB Connection Pool
β β βββ migrations/ # SQL Migrations
β βββ orchestration/ # Agent Base Classes & Workflow Managers
β βββ services/ # External Services
β βββ email.py # Email Service
β βββ geocoding.py # Geocoding Service
β βββ vision.py # Vision Processing
βββ User/ # Citizen Mobile App (Expo/React Native)
β βββ src/
β β βββ screens/ # App Screens
β β βββ components/ # Reusable Components
β β βββ services/ # API Services
β β βββ navigation/ # Navigation Setup
β βββ android/ # Android Build Configuration
βββ Frontend/ # Admin & Worker Portals (Next.js 16)
β βββ app/ # App Router Pages
β β βββ admin/ # Admin Dashboard
β β βββ worker/ # Worker Dashboard
β β βββ user/ # Citizen Portal
β βββ components/ # Shared Components
βββ static/ # Static page for agentic pipeline preview
βββ requestly/ # Requestly export file for requestly api testing
```
## β Technology Stack
### Backend
- **Framework:** FastAPI (Python 3.11+)
- **ORM:** SQLAlchemy 2.0 (Async)
- **Database:** PostgreSQL 18
- **Geospatial:** Haversine distance calculation for coordinate-based queries
- **Task Queue:** Background tasks with FastAPI BackgroundTasks
- **Authentication:** Supabase Auth
### AI/ML
- **Vision Model:** YOLOv8s (Fine-tuned for urban defects)
- **Training:** Custom dataset of 2000+ labeled urban issue images
- **Inference:** Real-time on CPU with optimized preprocessing
### Frontend
- **Web Framework:** Next.js 16 (App Router)
- **Styling:** Tailwind CSS
- **State Management:** React Hooks + Context API
- **Data Fetching:** Native Fetch API with caching
### Mobile
- **Framework:** React Native with Expo SDK 54
- **Language:** TypeScript
- **Navigation:** React Navigation
- **Storage:** Async Storage + Expo Secure Store
### Infrastructure
- **Authentication:** Supabase Auth (Google OAuth)
- **Storage:** Supabase Storage (Image uploads)
- **Deployment:** Docker + Docker Compose
- **CI/CD:** GitHub Actions
- **Container Registry:** GitHub Container Registry (GHCR)
## β Getting Started
### Prerequisites
- Node.js 20+
- Python 3.11+
- Docker & Docker Compose
- PostgreSQL 15+
- Android SDK (for mobile development)
### Installation
```bash
# Clone the repository
git clone https://github.com/0xarchit/CityTrack.git
cd CityTrack
# Backend Setup
cd Backend
pip install -r requirements.txt
# Frontend Setup
cd ../Frontend
npm install
# Mobile App Setup
cd ../User
npm install
```
### Environment Configuration
Create `.env` files in respective directories:
**Backend/.env**
```env
# Database Configuration
DATABASE_URL=postgresql://user:password@localhost:5432/citytrack
# Supabase Configuration
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_service_role_key
SUPABASE_BUCKET=your_bucket_name
SUPABASE_JWT_SECRET=your_jwt_secret
# Supabase S3 Storage Configuration
SUPABASE_S3_ENDPOINT=your_s3_endpoint
SUPABASE_S3_REGION=your_s3_region
SUPABASE_S3_ACCESS_KEY=your_s3_access_key
SUPABASE_S3_SECRET_KEY=your_s3_secret_key
# Google OAuth Configuration
GOOGLE_CLIENT_ID=your_google_client_id
PROJECT_ID=your_google_project_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# Email Configuration
SENDER_EMAIL=noreply@yourdomain.com
ADMIN_EMAIL=admin@yourdomain.com
RESEND_API_KEY=your_resend_api_key
# AI/ML Configuration
GEMINI_API_KEY=your_gemini_api_key
```
**Frontend/.env.local**
```env
# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:8000
# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
```
**User/.env**
```env
# API Configuration
EXPO_PUBLIC_API_BASE_URL=http://localhost:8000
# Supabase Configuration
EXPO_PUBLIC_SUPABASE_URL=your_supabase_url
EXPO_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
# Google OAuth Configuration
EXPO_PUBLIC_GOOGLE_CLIENT_ID=your_google_client_id
```
### Running the Project
**Using Docker (Recommended):**
```bash
docker compose up
```
**Manual Setup:**
```bash
# Terminal 1 - Backend
cd Backend
uvicorn api.app:app --host 0.0.0.0 --port 8000 --reload
# Terminal 2 - Frontend
cd Frontend
npm run dev
# Terminal 3 - Mobile App
cd User
npm start
```
### Building for Production
**Backend Docker Image:**
```bash
docker build -t citytrack-backend .
```
**Frontend:**
```bash
cd Frontend
npm run build
npm start
```
**Mobile App (Android):**
```bash
cd User/android
./gradlew assembleRelease
```
## β Key Features
### Core Functionality
- β **Anti-Fraud Reporting:** Mandatory live camera and high-precision GPS lock to prevent fake reports
- β **AI-Powered Validation:** Automatic classification and spam detection using YOLOv8
- β **Smart Deduplication:** Geospatial clustering to merge similar reports
- β **Dynamic Priority Assignment:** Context-aware urgency levels with SLA enforcement
- β **Intelligent Routing:** Automatic department and worker assignment
- β **Real-Time Tracking:** Live progress updates for citizens
- β **Proof of Resolution:** Workers must upload "After" photos to close tickets
### Admin Features
- β **Geospatial Heatmaps:** Visual density plots to identify problem areas
- β **Department Management:** Create and manage city departments
- β **Worker Administration:** Onboard and assign workers to departments
- β **Manual Review Queue:** Review AI decisions and provide feedback
- β **Analytics Dashboard:** Real-time metrics and historical trends
### Worker Features
- β **Priority Task List:** Auto-sorted by urgency and proximity
- β **One-Tap Navigation:** Direct integration with Google Maps
- β **Evidence Upload:** Mandatory before-and-after photo comparison
- β **Task History:** Complete audit trail of resolved issues
## β Agent Pipeline Details
### Input & Validation Layer
**Vision Agent**
- Scans images using fine-tuned YOLOv8 model
- Detects objects: potholes, garbage, debris, damaged infrastructure
- Rejects spam: selfies, irrelevant content, low-quality images
- Classifies issues with confidence scores
- Annotates images with bounding boxes
**Geo-Temporal Deduplication Agent**
- Uses bounding box queries on indexed latitude/longitude columns
- Applies haversine distance calculation to find nearby reports
- Checks for duplicates within configurable radius and time window
- Merges duplicate reports into clusters
- Increases urgency score for repeated reports
- Maintains report history and relationships
### Decision Making Layer
**Priority Agent**
- Assigns severity levels: CRITICAL, HIGH, MEDIUM, LOW
- Considers multiple factors:
- AI confidence score
- Location context (near schools, hospitals, main roads)
- Report clustering (multiple reports = higher priority)
- Historical data (recurring issues in same location)
- Sets dynamic SLA deadlines based on severity
- Provides justification for priority assignment
**Routing Agent**
- Matches issue category to correct department
- Selects optimal worker based on:
- Geographic proximity
- Current workload
- Specialization
- Availability
- Balances resource allocation across the city
- Handles department-specific routing rules
### Execution & Follow-up Layer
**SLA Watchdog Agent**
- Monitors all active issues against SLA deadlines
- Triggers warnings at 50% and 20% remaining time
- Analyzes context of delays (holidays, weather, resource constraints)
- Provides early warning system for potential SLA breaches
**Escalation Agent**
- Handles overdue issues automatically
- Reassigns to supervisors or alternate workers
- Increases issue priority
- Flags for administrative review
- Maintains transparency in escalation chain
**Notification Agent**
- Sends real-time updates via multiple channels:
- In-app push notifications
- Email notifications
- SMS (planned)
- Notifies citizens of status changes
- Alerts workers of new assignments
- Informs admins of escalations
- Supports templated messages with dynamic content
## β Deployment
### Docker Deployment
The project includes a complete Docker setup for production deployment:
```bash
# Build and run with Docker Compose
docker compose up -d
# View logs
docker compose logs -f
# Stop services
docker compose down
```
### GitHub Actions CI/CD
Automated workflows for:
- Docker image building and pushing to GHCR
- Deployment to production (completed)
- Automated testing (planned)
## β Roadmap & Future Vision
### Phase 1: The Foundation (Completed)
- β Autonomous Agent Pipeline (Vision, Geo, Priority, Routing, etc.)
- β Cross-Platform Ecosystem (Citizen App, Admin Portal, Worker View)
- β Real-time notifications and tracking
- β Anti-fraud mechanisms
### Phase 2: Intelligence Enhancement (In Progress)
- β Predictive Maintenance: Using historical data to predict infrastructure failures
- β Automated Testing: Comprehensive test suite
- β Multi-City Support: Tenant-based architecture
- β Civic Reputation System: Leaderboards for top contributors
### Phase 3: Scale & Gamification (Planned)
- β Advanced Analytics: ML models for pattern recognition
- β Incentive Programs: Tax credits or transit passes for verified reporting
- β Public API: Third-party integrations
- β Mobile SDK: White-label solution for other cities
- β IoT Integration: Direct feeds from smart bins, streetlights, and sensors
## β Contributing
We welcome contributions! Please read our contributing guidelines:
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
### Development Guidelines
- Follow PEP 8 for Python code
- Use TypeScript for all new frontend code
- Write descriptive commit messages
- Add tests for new features
- Update documentation as needed
## β Team
Built by **BitBots** at IIIT Una, HackTheThrone 2026
| Role | Name | GitHub |
|------|------|--------|
| Lead Developer | Archit Jain | [@0xarchit](https://github.com/0xarchit) |
| Developer | Rachit Verma | [@vxrachit](https://github.com/vxrachit) |
| Developer | Pushpendra Sharma | [@synapticpush](https://github.com/synapticpush) |
| Developer | Deepti Yadav | [@DeeptiYadav10648](https://github.com/DeeptiYadav10648) |
## β License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## β Acknowledgments
- YOLOv8 by Ultralytics for object detection
- Supabase for authentication and storage
- FastAPI for the robust backend framework
- Next.js and React Native teams for excellent frameworks
---
**CityTrack** - Transforming urban governance through autonomous AI agents. |