Inspiration

Emergency vehicles lose critical minutes stuck at red lights while traffic signals stay indifferent to what's happening on the road. We wanted to build a system where a city's traffic infrastructure could think for itself — spotting an emergency, plotting the fastest real route, and clearing the path automatically, without a human ever touching a button.

What it does

CityOps Core is an AI-native traffic management dashboard that:

  • Autonomously detects and dispatches emergencies — a background AI service simulates real-world incidents (cardiac arrests, structure fires, collisions) and decides when and where to respond, no manual trigger required.
  • Calls Claude to make the dispatch decision — given the incident scenario and current city congestion, Claude (Haiku 4.5) chooses the right vehicle type (ambulance / fire truck / police) and gives a short human-readable justification for the decision.
  • Routes like real turn-by-turn directions — instead of a straight line between two points, routes are computed with Dijkstra's algorithm over a live road-network graph built from intersection coordinates, so vehicles travel along actual streets.
  • Turns the city green ahead of the vehicle — as soon as a route is chosen, intersections along the path flip to "approaching" and "corridor green" states in real time, visualized on a live city map.
  • Still supports manual override — a dispatcher can also manually select vehicle type, origin, and destination to trigger a corridor by hand, side by side with the autonomous AI.

How we built it

  • Frontend: React + Vite + TypeScript, TailwindCSS, shadcn/ui, and Recharts-style live data via TanStack Query polling. The map is rendered as SVG, with the road network, active corridors, and moving vehicle icons all derived live from backend state.
  • Backend: Express + TypeScript API server with a PostgreSQL database (via Drizzle ORM). Emergency events, intersections, and traffic logs are all persisted and served through a typed, OpenAPI-generated client.
  • AI Dispatcher service: A Node interval service that runs every 20 seconds, builds a road graph from intersection coordinates, computes a shortest path, and calls the Claude API to reason about vehicle type and priority — with a safe random fallback if the AI call fails, so the system never breaks demo continuity.
  • Pathfinding: A custom grid-adjacency + Dijkstra implementation shared conceptually between frontend (for manual routes) and backend (for AI-triggered routes), so every corridor — human or AI-triggered — follows the same real street logic.

Challenges we ran into

  • Getting the local dev environment fully wired (Vite dev server proxying to a separate Express API server) took some real debugging — the classic "frontend gets HTML instead of JSON" trap when a proxy isn't configured.
  • Designing a road network that "just works" for any set of intersection coordinates — not a hardcoded map — so the same pathfinding logic scales to any grid layout, including off-grid landmark nodes.
  • Making the AI dispatcher resilient: if the Claude API call fails (bad key, rate limit, network issue), the system still auto-triggers events with a graceful fallback instead of crashing the simulation.

Accomplishments that we're proud of

  • A fully autonomous emergency response loop — from incident simulation, to AI reasoning, to real road routing, to live traffic signal changes — with zero manual input required.
  • Real turn-by-turn-style routing instead of the "as the crow flies" shortcut most hackathon prototypes fall back on.
  • A system that gracefully degrades — it works, and still auto-triggers events, even without an AI key configured.

What we learned

  • How to structure an AI decision-making service as a background job rather than a chat-triggered response — designing prompts for structured JSON output that a backend can safely parse and act on.
  • Practical graph algorithms (Dijkstra) applied to a real UI problem instead of just theory.
  • The importance of designing for graceful AI failure — a hackathon demo can't depend on a network call always succeeding.

What's next for CityOps Core

  • Surface Claude's reasoning directly in the UI (not just server logs) so operators can see why the AI made each dispatch decision.
  • Multi-route candidate comparison, where Claude picks between 2-3 AI-computed paths based on live congestion, not just the shortest one.
  • Historical analytics on response-time savings across many AI-triggered events, to quantify real-world impact.

Built With

Share this project:

Updates

Submission history