/AI ENGINEERING
Musafir AI — Karachi Transit Planner
AI-powered Karachi transit planner using RAG, Gemini, and Supabase pgvector to match natural-language travel queries with 140+ local bus routes.

- My role
- Full-Stack AI Developer — Hackathon Project
- Tools & technologies
- React, Vite, FastAPI, Python, Gemini 1.5 Flash, Google Gen AI SDK, Supabase, PostgreSQL, pgvector, RAG, Semantic Search, Google Maps JS API, Context API, Transit Planning, Vector Search
- Data
- historical
- Explore
- View GitHub
Overview
Musafir AI is an AI-powered transit planning application built specifically for Karachi's public transport ecosystem.
The project was created to address a major local challenge: many Karachi bus, minibus, coach, and BRT routes are difficult to discover digitally, and commuters often rely on word-of-mouth knowledge to figure out which route to take.
Musafir combines a local transit knowledge base with Retrieval-Augmented Generation, semantic search, Google Gemini, Supabase pgvector, and Google Maps to provide context-aware public transport guidance.
The Problem
Karachi has a large and complex public transport network, but much of the route information is not consistently represented in mainstream navigation applications.
For many commuters, finding the correct bus or stop may require asking other passengers or relying on local familiarity.
Traditional navigation platforms may default to driving directions because the underlying local bus-route data is incomplete.
Musafir was designed to make this local transit knowledge searchable through natural language.
Transit Knowledge Base
The project digitizes more than 140 local bus routes.
This data forms the core knowledge base used by the application for route discovery and transit recommendations.
Instead of relying only on keyword matching, Musafir uses semantic search to retrieve routes that are relevant to the user's journey.
Retrieval-Augmented Generation
Musafir uses a RAG architecture built on Supabase PostgreSQL and pgvector.
The workflow allows the system to:
- Receive a natural-language origin and destination.
- Search the local transit knowledge base semantically.
- Retrieve relevant bus-route information.
- Provide that context to the AI model.
- Generate a transit recommendation grounded in the available route data.
This helps reduce the likelihood of the AI inventing transit routes that do not exist in the local dataset.
AI Transit Guide
Google Gemini 1.5 Flash powers the AI transit guidance layer.
The assistant can provide more conversational travel advice around the retrieved transit information, including context such as:
- Which bus route may be suitable
- Where to board
- Important landmarks
- Approximate fare guidance
- Peak-hour considerations
- Practical local transit tips
The goal is to make the experience closer to asking a knowledgeable local commuter rather than interacting with a generic route search interface.
Semantic Search with pgvector
Supabase pgvector is used to store and retrieve vectorized transit information.
This allows Musafir to match user intent with relevant routes even when the wording of a query does not exactly match the route descriptions stored in the database.
For example, a user can ask for travel between two areas in natural language rather than needing to know a specific bus number beforehand.
Map Integration
Google Maps JavaScript API provides the geographic layer of the application.
Maps are used to visualize journey locations and help users understand the relationship between their origin, destination, and suggested transit path.
The map interface complements the AI response rather than replacing the locally curated transit knowledge base.
Frontend
The frontend is built using:
- React
- Vite
- Google Maps JavaScript API
- Material Symbols
- Context API
Context API manages journey-related state across the application so origin, destination, and route information remain synchronized between components.
Backend
The backend is built with FastAPI and Python.
It handles:
- Transit search requests
- Supabase interaction
- Vector retrieval
- RAG context preparation
- Gemini integration
- AI-generated transit guidance
This separation keeps the transit retrieval and AI logic outside the frontend.
Typical User Flow
A user enters an origin and destination, for example:
Saddar → Clifton
Musafir then:
- Searches the local transit knowledge base.
- Retrieves relevant bus-route information.
- Uses the retrieved data as context for Gemini.
- Generates a transit recommendation.
- Displays journey information alongside the map.
- Provides additional local guidance through the AI Transit Guide.
Hackathon Context
Musafir AI was built for the National AI Hackathon 2026 in Karachi.
The project focused on solving a strongly local problem using generative AI, vector search, and structured transit data rather than building a generic chatbot.
What I Learned
Musafir gave me hands-on experience building a Retrieval-Augmented Generation application around a domain-specific dataset.
The project strengthened my experience in:
- RAG system design
- Vector databases
- Semantic search
- Prompt grounding
- FastAPI backend development
- Supabase and pgvector
- Gemini integration
- Google Maps integration
- Full-stack React development
It also demonstrated how AI can become more useful when it is grounded in locally relevant data that general-purpose navigation systems may not contain.
Limitations & context
Musafir's recommendations depend on the transit routes available in its local knowledge base.
Although the system includes more than 140 Karachi bus routes, it does not represent every public transport route, temporary route change, service disruption, or newly introduced service in the city.
The system does not currently consume real-time vehicle GPS feeds or official live transit schedules, so arrival times and current vehicle positions are not guaranteed.
Fare information and local operating conditions may also change over time.
AI-generated guidance is grounded using retrieved route data, but users should still verify critical route or fare information when necessary.
The project was developed as a hackathon solution and demonstrates how RAG and locally curated transit data can improve public-transport discovery in Karachi.





