AI-powered transit optimization for Accra’s public transport (Trotros) Built with a sleek Flutter app (Cupertino-style) + FastAPI backend + ML models for route and demand prediction.
accra-transit-optimizer/
│
├── backend/ # FastAPI backend
│ ├── api/ # API routes and logic
│ ├── models/ # Trained ML models
│ ├── utils/ # GTFS & preprocessing
│ ├── data/ # GTFS data & generated features
│ ├── main.py # API entry point
│ └── requirements.txt # Python deps
│
├── frontend/ # Flutter app
│ ├── lib/
│ │ ├── screens/ # Main UI (home, analytics, routes)
│ │ ├── services/ # API integration
│ │ ├── providers/ # State management
│ │ └── main.dart # App entry point
│ ├── pubspec.yaml
│ └── assets/ # Branding, splash
✅ GTFS stop parsing & mapping ✅ ML demand prediction model ✅ AI-suggested optimal routes ✅ Dynamic analytics dashboard ✅ Realtime GPS location detection ✅ Sleek Cupertino-inspired UI ✅ Auto-filled coordinates with override ✅ Toast-based error handling ✅ Hosted FastAPI backend (Render)
| Layer | Technology |
|---|---|
| Backend | FastAPI, Python, Scikit-learn, XGBoost |
| Frontend | Flutter 3.x (Cupertino), Provider |
| Mapping | flutter_map + OpenStreetMap |
| Data | GTFS Accra 2016 + synthetic GPS |
| ML Models | Route optimization, demand prediction |
cd backend/
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
python train_models.py
uvicorn main:app --reload- API: http://localhost:8000/docs
- Health:
/health
cd frontend/
flutter pub get
flutter run -d chrome # Or `-d android`| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/stops |
All stops (with optional demand) |
| POST | /api/v1/predict_demand |
Predict demand for stop & time |
| GET | /api/v1/suggest_routes |
AI-optimized route suggestions |
| GET | /api/v1/suggest_routes_from_to |
Suggest based on start → end |
| GET | /api/v1/analytics |
Returns analytics summary |
| POST | /api/v1/submit_gps |
Submit live GPS data |
📄 Docs: https://accra-transit-optimizer.onrender.com/docs
-
📍 GPS Location Detection
- Auto-prefills coordinates
- Toasts: e.g., “Location Detected: 5.6, -0.18”
-
🗺️ Flutter Map UI
- Displays GTFS stops & route markers
- Highlights viable paths with polylines
-
📊 Analytics Screen
- Fetches live analytics from
/analytics - Stylish cards: peak hours, high-traffic stops, etc.
- Fetches live analytics from
-
🔄 Route Suggestions
- From start → end (user input or GPS)
- Filters: demand threshold & viability
- 🍎 Cupertino-style (rounded, elegant)
- 🧭 Responsive layouts
- 🎨 Splash screen with minimal branding
- 🔔 Toast feedback for all actions
- 🔄 Live trotro tracking via real-time GPS
- 🧠 Model auto-retraining
- 📊 Admin dashboard (Web)
- 🚏 Stop clustering & demand heatmaps
- 📅 Schedule optimization (OR-Tools)
- Lead Developer: [Caleb Botchway / DEVKD.]
- Data Source: 2016 Accra GTFS
- Frameworks: Flutter, FastAPI, Scikit-learn, OSMnx, GTFS-Kit
MIT License — free to use, modify & contribute.
🚀 Optimizing Accra’s future, one route at a time.