File size: 12,334 Bytes
42d88ae | 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 | ---
title: city_issue
emoji: ποΈ
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: false
---
# UrbanLens
```text
_ _ _ _
| | | | | | | |
| | | |_ __| |__ __ _ _ __ | | ___ _ __ ___
| | | | '__| '_ \ / _` | '_ \| | / _ \ '_ \/ __|
| |__| | | | |_) | (_| | | | | |___| __/ | | \__ \
\____/|_| |_.__/ \__,_|_| |_|______\___|_| |_|___/
```
<div align="center">




</div>
**"Governance at the Speed of Software."**
## β Idea Brief
UrbanLens 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, UrbanLens 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, UrbanLens ensures city-scale, self-healing infrastructure.
## β System Internals: The "Issue Packet"
Every interaction in UrbanLens starts with an **Issue Packet**βan immutable, atomic unit of civic data.
- **Evidence:** Primary visual proof (Image/Video) captured via mandatory live camera.
- **Context:** High-precision GPS (<10m accuracy), Compass Heading, and Device Metadata.
- **Intent:** User-provided description, enhanced by NLP.
### Anti-Fraud Enforcement
UrbanLens 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 practically 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: UrbanLens
UrbanLens 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 + PostGIS)]
M[(Supabase Storage)]
end
D -.-> M
E -.-> L
```
## β The Autonomous Pipeline (Deep Dive)
The systems 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 **YOLOv8** 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:** Queries the geospatial index for 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:** analyze 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 and send email notifications to respectives.
## β Project Showcase
<details>
<summary><b>User Mobile App Interface</b></summary>
<br>
<div align="center">
<img src="assets/android_app_interface.jpg" width="45%" alt="Mobile Interface">
<img src="assets/android_app_issue_interface.jpg" width="45%" alt="Reporting Interface">
</div>
</details>
<details>
<summary><b>Admin Command Center</b></summary>
<br>
<div align="center">
<table>
<tr>
<td align="center"><img src="assets/web_portal_admin.png" width="100%" alt="Admin Dashboard"><br><b>Admin Dashboard</b></td>
<td align="center"><img src="assets/web_portal_admin_heatmap.png" width="100%" alt="Heatmap"><br><b>Geospatial Heatmap</b></td>
</tr>
<tr>
<td align="center"><img src="assets/web_portal_admin_issuespage.png" width="100%" alt="Issues Management"><br><b>Issue Management</b></td>
<td align="center"><img src="assets/web_portal_admin_manualreview.png" width="100%" alt="Manual Review"><br><b>AI Manual Review</b></td>
</tr>
<tr>
<td align="center"><img src="assets/web_portal_admin_workforce_managepage.png" width="100%" alt="Workforce"><br><b>Workforce Management</b></td>
<td align="center"><img src="assets/web_portal_admin_department_managepage.png" width="100%" alt="Departments"><br><b>Department Control</b></td>
</tr>
<tr>
<td align="center" colspan="2"><img src="assets/web_portal_admin_workerrequest_manualapprove.png" width="100%" alt="Worker Approval"><br><b>Worker Requests</b></td>
</tr>
</table>
</div>
</details>
<details>
<summary><b>Worker & Resolution Portal</b></summary>
<br>
<div align="center">
<table>
<tr>
<td align="center"><img src="assets/web_portal_worker.png" width="100%" alt="Worker Home"><br><b>Worker Dashboard</b></td>
<td align="center"><img src="assets/web_portal_worker_issue_resolvereview.png" width="100%" alt="Resolution Review"><br><b>Resolution Protocol</b></td>
</tr>
<tr>
<td align="center"><img src="assets/web_portal_worker_issue_resolvesubmit.png" width="100%" alt="Resolution Submit"><br><b>Evidence Submission</b></td>
<td align="center"><img src="assets/web_portal_worker_issuecomplete.png" width="100%" alt="Task Complete"><br><b>Task Completion</b></td>
</tr>
</table>
</div>
</details>
<details>
<summary><b>Web Portal for Citizen</b></summary>
<br>
<div align="center">
<img src="assets/web_portal.png" width="100%" alt="Landing Page">
<br><br>
<img src="assets/web_portal_user.png" width="100%" alt="User Dashboard">
</div>
</details>
<details>
<summary><b>Autonomous Pipeline</b></summary>
<br>
<div align="center">
<img src="assets/pipeline_overview.png" width="100%" alt="Pipeline Overview">
</div>
</details>
## Client Ecosystem
### 1. Citizen Mobile App (The Sensors)
*Built with React Native + Expo (TypeScript)*
- **Offline-First:** (Experimental Beta) Caches reports locally and syncs when connection returns.
- **Real-Time Tracking:** Server-driven events update the "Processing" screen live as agents complete their tasks.
- **Gamification:** (Planned) Civic points for verified reports.
### 2. Admin Command Center (The Control)
*Built with Next.js 16 (App Router) + Tailwind CSS*
- **Role-Based Access Control (RBAC):**
- **Super Admin:** System config.
- **Worker Dashboard:** Submission of issues 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.
## β Modular Monolith Architecture
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, Geo, SLA, Priority, Routing, Notification, Escalation)
β βββ api/ # Stateless REST Endpoints (Routes)
β βββ core/ # Shared Infra (Event Bus, Config)
β βββ orchestration/ # Agent Base Classes & Workflow Managers
β βββ Database/ # Database Models & Schemas
β βββ services/ # Services (Email, Authentication, etc)
βββ User/ # π± Citizen Mobile App (Expo/React Native)
βββ Frontend/ # π» Admin & Worker Portals (Next.js 16)
βββ infra/ # βοΈ Docker & Deployment Config
βββ assets/ # Project Screenshots & Media
```
## β Tech Stack
- **Backend:** FastAPI, Python, SQLAlchemy, PostgreSQL (PostGIS)
- **AI/ML:** YOLOv8s (Fine-tuned for urban defects)
- **Frontend:** Next.js (User/Admin/Worker Web Dashboards), Tailwind CSS
- **Mobile:** React Native, Expo, TypeScript
- **Infrastructure:** Supabase (Auth, Storage), Docker
## β Key Features
- **Anti-Fraud Reporting:** Mandatory live camera and high-precision GPS lock to prevent fake reports.
- **Real-Time Tracking:** Server-driven progress visualization for citizens.
- **Proof of Resolution:** Workers must upload "After" photos to close tickets.
- **Heatmaps:** Data-driven insights for city administrators to identify systemic issues.
## β Agent Pipeline Details
**Stage 1: Input & Validation**
- **Vision Agent:** Scans images, detects objects (potholes, garbage, debris), rejects spam, classifies issues.
- **Geo-Temporal Deduplication Agent:** Checks for duplicate issues in space/time, merges reports, increases urgency for repeated reports.
**Stage 2: Decision Making**
- **Priority Agent:** Assigns severity (CRITICAL, HIGH, MEDIUM, LOW) and SLA deadlines based on context.
- **Routing Agent:** Assigns issues to correct department and worker, optimizes resource allocation.
**Stage 3: Execution & Follow-up**
- **SLA Watchdog Agent:** Monitors deadlines, triggers escalation if breached.
- **Escalation Agent:** Handles overdue issues, reassigns to supervisors, flags for transparency.
- **Notification Agent:** Sends updates to citizens and workers via multiple channels.
## β 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).
### Phase 2: Predictive Governance
- **Predictive Maintenance:** Using historical data to predict potholes before they form (e.g., "Road X cracks every March").
- **IoT Fusion:** Integrating direct feeds from smart bins and streetlights.
### Phase 3: Gamification
- **Civic Reputation:** Leaderboards for top contributing citizens.
- **Incentives:** Tax credits or transit passes for verified infrastructure reporting.
---
*Built by BitBots for a smarter, more responsive city.*
|