Inspiration

With the 2026 FIFA World Cup coming up, I was thinking about the sheer scale of the event—48 teams, 80+ matches, and stadiums packed with 80,000+ fans. Funneling that many people through limited gates creates some really scary bottlenecks. When you look at past tragedies like Hillsborough or even more recent ones, the root cause is almost always reactive crowd management. Operators are just watching CCTV and radioing each other, which means by the time they spot a dangerous surge, it’s often too late. I wanted to build something that could see those surges forming in the data and actually fix them before they turn into a crisis.

What it does

SafeFlow is basically an autonomous command center for stadium security. Instead of just showing alerts on a screen, it acts on them. I built a 5-stage response loop that handles everything from detection to mitigation. First, it pulls in real-time turnstile data. If it spots a spike in traffic, my Analysis Agent evaluates the capacities of all the other gates. Then, a Mitigation Agent jumps in to calculate the safest rerouting paths and instantly updates those paths in the database. But it doesn't stop there—it also automatically dispatches nearby security stewards (even matching their language skills to the fan demographics) and updates the stadium's digital signs with emergency instructions in multiple languages.

How I built it

I leaned heavily into the new Google Agent Development Kit (ADK) to build out the multi-agent orchestration. I used a Supervisor-Specialist architecture where a main Supervisor Agent delegates tasks to four specialists: Analysis, Mitigation, Communications, and Post-Mortem. All of this is powered by gemini-3.0-flash.

For the backend, I used FastAPI to manage all the database transactions with MongoDB Atlas, which handles the high-frequency crowd metrics. On the frontend, I wanted the dashboard to look like a real-life cybernetic command center, so I built a 3D WebGL stadium hologram using React Three Fiber, complete with Framer Motion spring physics for smooth steward animations. Finally, everything is containerized and deployed on Google Cloud Run for zero-cold-start performance, and I wired up Arize Phoenix to trace all the LLM executions.

Challenges I ran into

Getting multiple AI agents to work together reliably was definitely my biggest hurdle. Making sure the Supervisor Agent correctly piped data between the specialists without hallucinating or losing context required really strict tool definitions and relying hard on the ADK's structured orchestration.

Another huge challenge was the real-time synchronization. Syncing the agent's database write-backs (like calculating a new routing path) to the frontend's 3D WebGL rendering in real-time via WebSockets took a ton of fine-tuning to keep the UI smooth and accurate without crashing the browser.

Accomplishments that I'm proud of

I’m really proud of the "Self-Introspection" feature I built. My Analysis Agent actually queries past OpenTelemetry traces via Arize Phoenix to learn from past steward dispatch speeds, which allows it to optimize future decisions. I'm also incredibly proud of the frontend—I managed to build a React Three Fiber 3D UI that is genuinely gorgeous and responsive. Integrating MongoDB, Google Cloud Run, and the ADK into a pipeline that actually feels production-ready was a huge win for me.

What I learned

I learned just how powerful the Supervisor-Specialist pattern is for AI. Dividing complex incident response duties into single-responsibility agents made the system so much more reliable and easier to debug than trying to cram everything into one massive prompt. I also gained a deep appreciation for LLM observability—tracing tool calls isn't just a nice-to-have, it's absolutely critical when you're building systems that are supposed to handle real-world operations.

What's next for SafeFlow AI

The next step is integrating live computer vision feeds directly from stadium CCTV cameras using Gemini 1.5 Pro's multimodal capabilities. This would let SafeFlow visually confirm crowd density instead of just relying on turnstile data. Long term, I want to expand my simulation environments to handle city-wide crowd control for massive events like the Olympics, scaling from a single stadium to an entire transit grid.

Built With

  • arize-phoenix
  • fastapi
  • framer-motion
  • gemini-3.0-flash
  • google-agent-development-kit
  • google-cloud-run
  • mongodb-atlas
  • node.js
  • opentelemetry
  • python
  • react
  • react-three-fiber
  • websockets
Share this project:

Updates