Smart routing that calculates emissions in real-time and suggests the greenest travel options for Indian cities.
SROS is a full-stack web application that helps users plan eco-friendly trips by calculating COβ emissions for different vehicle types and routes, optimizing for speed, balance, or sustainability.
- Real-time Emission Calculation: Displays COβ emissions (in grams) for petrol, diesel, electric, CNG, and public transport options
- Multi-layer Route Optimization: Offers 3 route variantsβfastest, balanced, and greenestβusing OpenRouteService (ORS) API
- Intelligent Caching: Redis β SQLite β ORS API fallback for fast geocoding and directions
- User Authentication: JWT-based login/signup with secure password hashing (bcrypt)
- Achievement System: Gamification with badges for eco-friendly travel milestones
- Trip Tracking: Store and analyze historical trips with emission stats
- Rate Limiting & CORS: Production-ready API security with request throttling
- Admin Dashboard: Real-time user statistics and trip analytics
- Responsive UI: HTML templates for desktop and mobile browsers
- Framework: Flask 3.0+ with SQLAlchemy ORM
- Authentication: Flask-JWT-Extended (JWT tokens)
- Database: SQLite (development) / PostgreSQL (production)
- Caching: Redis with Celery for async tasks
- API: OpenRouteService for real routing & geocoding
- AI: Google Generative AI (Gemini) for insights
- Security: bcrypt (password hashing), Flask-Limiter (rate limiting), Flask-CORS
- Jinja2 templates (server-side rendering)
- HTML/CSS/JavaScript (no heavy JS frameworks)
- Responsive design for all devices
- NumPy, Pandas, SciPy for calculations
- NetworkX for graph optimization
- GeoPy for coordinate operations
- Custom geocoding cache (SQLite)
- Python 3.11+
- Gunicorn + Railway deployment (see
Procfileandrailway.toml) - Alembic for database migrations
- Python 3.11+ (check:
python --version) - pip (usually bundled with Python)
cd "C:\Users\YourUsername\path\to\SROS-main"# Create venv
python -m venv venv
# Activate (Windows)
venv\Scripts\activate
# Activate (macOS/Linux)
source venv/bin/activatepip install -r requirements.txtCopy .env.example to .env and configure:
# Generate a strong SECRET_KEY and JWT_SECRET_KEY
cp .env.example .env
# Edit .env with your settings:
# SECRET_KEY=your-secret-key-here
# JWT_SECRET_KEY=your-jwt-secret-here
# ORS_API_KEY=your-openrouteservice-key
# REDIS_URL=redis://localhost:6379/0
# DATABASE_URL=sqlite:///sros_dev.db # (dev default)set FLASK_APP=app.py
flask db upgradepython db_seed.pyAdds 10 sample Indian users and realistic trip data.
python app.py- App starts on
http://localhost:5000 - Debug mode auto-reloads on code changes
- Leave running in a terminalβopen the URL in your browser
curl http://localhost:5000/healthReturns database and Redis status.
- Auth:
POST /auth/signup,POST /auth/login,POST /auth/logout - Routes:
GET /api/trips,POST /api/trips,GET /api/stats - AI:
POST /api/insights(Gemini-powered trip insights) - Admin:
GET /api/admin/stats(requires JWT token)
pytestTests marked with @pytest.mark.unit, @pytest.mark.integration, @pytest.mark.slow.
SROS-main/
βββ app.py # Flask app factory; entry point
βββ config.py # Config for dev/test/production
βββ extensions.py # Flask extension initialization (db, jwt, cors, etc.)
βββ requirements.txt # Python dependencies
βββ .env.example # Example environment variables
βββ Procfile # Gunicorn deployment config (Railway)
βββ railway.toml # Railway platform config
βββ db_seed.py # Script to populate sample data
βββ models/
β βββ db_models.py # SQLAlchemy models (User, Trip, Achievement, etc.)
β βββ emission_calculator.py # COβ calculation logic for vehicle types
β βββ route_optimizer.py # Multi-layer geocoding & route optimization
β βββ achievements.py # Badge/achievement logic
βββ routes/
β βββ api.py # Core REST API endpoints
β βββ auth.py # Authentication (signup/login/logout)
β βββ pages.py # Web pages (dashboard, index)
β βββ ai_services.py # Google Gemini integration
βββ templates/
β βββ index.html # Landing page
β βββ dashboard.html # User dashboard & trip tracker
β βββ (other HTML templates)
βββ tests/
β βββ test_api.py # API endpoint tests
β βββ test_auth.py # Authentication tests
β βββ test_emission_calculator.py # Emission logic tests
β βββ test_route_optimizer.py # Route optimization tests
β βββ conftest.py # Pytest fixtures & config
β βββ smoke_test.py # Basic health checks
βββ migrations/ # Alembic migration scripts (auto-generated)
βββ instance/ # SQLite DB & runtime files (auto-created)
βββ __pycache__/ # Python bytecode (auto-generated, safe to ignore)
Required for local development (see .env.example):
| Variable | Example | Purpose |
|---|---|---|
SECRET_KEY |
abc123def456... |
Flask session encryption |
JWT_SECRET_KEY |
xyz789uvw012... |
JWT token signing |
FLASK_ENV |
development |
App mode (development/testing/production) |
DATABASE_URL |
sqlite:///sros_dev.db |
Database connection string |
REDIS_URL |
redis://localhost:6379/0 |
Redis for caching & JWT blacklist |
ORS_API_KEY |
your-key |
OpenRouteService API key (get free tier at openrouteservice.org) |
ALLOWED_ORIGINS |
http://localhost:5000 |
CORS allowed domains |
SROS is configured for Railway (see railway.toml and Procfile):
- Connect your GitHub repo to Railway
- Set environment variables in Railway dashboard
- Railway auto-deploys on git push
- Uses PostgreSQL (recommended) and Gunicorn server
For other platforms (Heroku, Render, AWS), update Procfile and database URL.
Run the test suite:
pytest -v # All tests
pytest -m unit # Unit tests only
pytest -m integration # Integration tests (touch DB)
pytest -m slow # Slow tests (network calls)Test coverage:
- Authentication flows
- Emission calculations (all vehicle types)
- Route optimization & caching
- API validation
- Database transactions
India generates ~200 million tonnes of COβ annually from transport, and most travelers are unaware of their environmental impact. SROS empowers users to:
- See real-time emissions for their journeys
- Choose greener alternatives without sacrificing speed
- Earn achievements for sustainable travel
- Track their carbon footprint over time
POST /api/trips
{
"start_location": "Mumbai, Maharashtra",
"end_location": "Pune, Maharashtra",
"vehicle_type": "car_petrol",
"route_preference": "greenest"
}Response:
{
"id": 1,
"distance_km": 155,
"co2_grams": 26505,
"duration_minutes": 165,
"cost_inr": 1007.5,
"route_type": "greenest",
"created_at": "2026-04-18T10:30:00Z"
}GET /api/stats (requires JWT token)
{
"total_trips": 5,
"total_distance_km": 650,
"total_co2_grams": 111225,
"avg_co2_per_trip": 22245,
"favorite_vehicle": "car_petrol",
"achievements": ["eco_warrior", "500km_milestone"]
}- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit changes:
git commit -m "Add feature" - Push:
git push origin feature/your-feature - Open a Pull Request
This project is open-source. See LICENSE for details (if applicable).
For issues, feature requests, or questions:
- Open a GitHub Issue
- Contact: [your-email@example.com]
- Check existing issues for solutions
- OpenRouteService: Real-world routing & geocoding
- Google Gemini: AI-powered trip insights
- Flask & SQLAlchemy: Backend framework stability
- Indian Environmental Data: ICCT & EEA emission factors
Happy sustainable routing! π±