Inspiration
If you live in Nairobi, you lose an average of 57 minutes every day in traffic. The city loses KSh 120 Billion ($1B USD) annually in lost productivity. But the real victims are the Matatu (public van) drivers. They drive blind, burning expensive fuel hunting for passengers, only to end up stuck in the same jam as everyone else.
We asked: What if a Matatu driver had the same predictive intelligence as an Uber driver, but optimized for mass transit? We built Ma3Flow to stop the guessing game. By digitizing the heartbeat of Nairobi's transport—the Matatu—we aren't just saving time; we are modernizing the backbone of Kenya's economy.
What it does
Ma3Flow is a real-time logistics engine that connects Matatu drivers (via WhatsApp) to SACCO managers (via a Dashboard).
- Real-Time Demand Prediction: Instead of waiting at a stage hoping for passengers, the AI predicts demand surges (e.g., "Rain starting in Westlands = 500 people waiting").
- Dynamic Rerouting: When a major road like Thika Superhighway gridlocks, our system detects the anomaly instantly and pushes an alternative "rat run" route to drivers.
- Surge Pricing Advisor: Using Gemini, we analyze weather and traffic density to suggest fair, dynamic prices to drivers, helping them maximize revenue without exploiting passengers.
- The "Dere" (Driver) Chatbot: Drivers don't need a complex app. They text our bot on WhatsApp: "Iko wapi pesa?" (Where is the money?), and Gemini responds: "Go to Westlands Terminal. 20 pax waiting. Traffic is light. Estimated fare: 100 Bob."
How we built it
We architected a "High-Velocity, Low-Latency" pipeline to handle the chaos of Nairobi traffic:
- Ingestion (IoT): We simulated a fleet of 50 Matatus emitting MQTT signals (GPS, Speed, Pax Count) every 5 seconds.
- The Stream (Confluent Cloud):
- We used Confluent Cloud to ingest these high-throughput streams.
- Flink SQL was the game-changer here. We used Flink to create "Tumbling Windows" of 5 minutes, aggregating demand by geohash. This allowed us to filter out noise (stopped vehicles) and detect density spikes instantly.
- The Brain (Google Cloud Vertex AI):
- The aggregated stream data triggers a Vertex AI prediction model trained on historical Nairobi traffic patterns.
- We integrated Gemini Pro to act as the "Interpreter." It takes the raw numbers (Latency: High, Demand: 40) and converts them into natural Swahili text for the driver.
- The Interface: A Python backend connects the insights to the Twilio API for WhatsApp delivery.
Challenges we ran into
- "Dirty" Data: GPS signals in downtown Nairobi often "drift" due to tall buildings. We had to write a KSQL filter to smooth out jumpy location data.
- Latency vs. Cost: constantly querying the LLM for every driver update was too expensive. We solved this by caching predictions in Redis and only triggering Gemini when a significant anomaly (like a sudden rainstorm) occurred.
Accomplishments that we're proud of
- Simulating a City: We successfully built a simulator that mimics "Rush Hour" in Nairobi, proving our Flink pipeline can handle thousands of concurrent events without choking.
- Language Localization: Our Gemini prompt engineering successfully speaks "Sheng" (Nairobi slang). It doesn't sound like a robot; it sounds like a stage manager.
What's next for Ma3Flow
- M-Pesa Integration: Closing the loop by integrating mobile payments directly into the stream for real-time revenue assurance for vehicle owners.
- Hardware Pilot: Moving from simulation to installing cheap ESP32 trackers in 10 real Matatus along the Waiyaki Way route.
Built With
- confluent-cloud
- flink-sql
- gemini-pro
- google-cloud-vertex-ai
- mqtt
- typescript
- vite
Log in or sign up for Devpost to join the conversation.