Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚇 Bangalore Metro Simulation Dashboard

A comprehensive Python-based interactive dashboard for simulating the Bangalore Metro system with route planning, fare calculation, and admin management features.

🌟 Features

🗺️ Interactive Route Map

  • Visual representation of Green Line & Purple Line
  • All stations with interchange points (Majestic)
  • Interactive station selection
  • Real-time route highlighting

💰 Dynamic Fare Calculator

  • Automatic fare calculation based on distance
  • Pricing: ₹10 for first 2 stations, ₹2 per additional station
  • Displays:
    • Total fare
    • Number of stops
    • Estimated travel time (45 seconds per station)

🚉 Live Route Preview

  • Animated train movement along selected route
  • Station-by-station breakdown
  • Interchange station indicators
  • Journey progress visualization

⚙️ Admin Controls

  • Add/Edit/Delete stations
  • Update fare rules dynamically
  • View system analytics
  • Manage metro lines
  • Export/Import station data

📊 Analytics Dashboard

  • Most popular routes
  • Revenue tracking
  • Peak hours analysis
  • User journey statistics

🗂️ Project Structure

P4/
├── app.py                          # Main Streamlit application
├── metro_logic.py                  # Route finding & fare calculation (BFS)
├── admin.py                        # Admin control panel
├── data/
│   └── stations.json              # Station data (Green & Purple Lines)
├── pages/
│   ├── 1_Passenger_Portal.py      # Basic passenger interface
│   ├── 2_Admin_Dashboard.py       # Database admin interface
│   └── 8_Enhanced_Passenger_Portal.py  # Interactive route planner
├── utils/
│   ├── authentication.py          # User authentication
│   ├── helpers.py                 # Utility functions
│   └── query_helper.py           # Database queries
├── database/
│   ├── database_setup.py         # Database initialization
│   ├── unified_connector.py      # Database connector
│   └── metro.db                  # SQLite database
├── requirements.txt              # Python dependencies
└── README.md                     # This file

🚀 Quick Start

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)

Installation

  1. Navigate to the project folder:

    cd P4
  2. Install dependencies:

    pip install -r requirements.txt
  3. Run the application:

    streamlit run app.py
  4. Access the dashboard:

    • Open your browser to http://localhost:8501
    • Default admin credentials:
      • Username: admin
      • Password: admin123

🎮 Usage

For Passengers

  1. Login with your credentials (or register a new account)
  2. Navigate to "Enhanced Passenger Portal" from the sidebar
  3. Select Route:
    • Choose source station (e.g., "Yelachenahalli")
    • Choose destination station (e.g., "MG Road")
  4. View Route Details:
    • Number of stops
    • Total fare
    • Estimated travel time
    • Lines used
  5. Watch Live Preview: See animated train movement
  6. Book Ticket: Confirm and book your journey

For Administrators

  1. Login with admin credentials
  2. Navigate to "Admin Dashboard" or run streamlit run admin.py
  3. Manage Stations:
    • Add new stations with coordinates
    • Edit existing stations
    • Delete stations
  4. Update Fare Rules:
    • Modify base fare
    • Change per-station pricing
    • Update travel time settings
  5. View Analytics:
    • Popular routes
    • Revenue statistics
    • Peak hours data

🧮 Fare Calculation Logic

The system uses a simple, transparent fare structure:

if stops <= 2:
    fare =10
else:
    fare =10 + (stops - 2) × ₹2

Examples:

  • 1-2 stops: ₹10
  • 3 stops: ₹12
  • 5 stops: ₹16
  • 8 stops: ₹22
  • 10 stops: ₹26

🗺️ Metro Lines

🟢 Green Line

  • Route: Nagasandra → Yelachenahalli
  • Stations: 24
  • Color: #00A651

🟣 Purple Line

  • Route: Challaghatta → Mahalakshmi
  • Stations: 18
  • Color: #8B008B

🔄 Interchange Station

  • Majestic: Connects Green and Purple Lines

🔧 Technical Details

Route Finding Algorithm

  • Algorithm: Breadth-First Search (BFS)
  • Time Complexity: O(V + E) where V = stations, E = connections
  • Guarantees: Shortest path by number of stops

Data Storage

  • Format: JSON for station data
  • Database: SQLite for user/ticket management
  • Backup: Automatic database backups

Technologies Used

  • Frontend: Streamlit (Python)
  • Backend: Python 3.8+
  • Database: SQLite / MySQL (configurable)
  • Data Format: JSON
  • Algorithms: BFS for pathfinding

📊 Example Journeys

Journey 1: Yelachenahalli → MG Road

  • Stops: 8
  • Fare: ₹22
  • Time: ~6 minutes
  • Route: Green Line → Purple Line (via Majestic)

Journey 2: Nagasandra → Whitefield

  • Stops: 15
  • Fare: ₹36
  • Time: ~11 minutes
  • Route: Green Line → Purple Line (via Majestic)

Journey 3: Indiranagar → Cubbon Park

  • Stops: 3
  • Fare: ₹12
  • Time: ~2 minutes
  • Route: Purple Line only

🎨 UI Features

Metro-Themed Design

  • Purple and green color palette
  • Clean, modern interface
  • Responsive layout
  • Intuitive navigation

Interactive Elements

  • Dropdown station selectors
  • Animated route preview
  • Progress bars for journey simulation
  • Real-time fare calculation

User Experience

  • One-click booking
  • Journey history tracking
  • Achievement system
  • Helpful travel tips

🔐 Security Features

  • User authentication system
  • Role-based access control (Admin/Passenger)
  • Password protection
  • Session management

📈 Future Enhancements

  • Real-time train tracking
  • Mobile app integration
  • QR code ticket generation
  • Payment gateway integration
  • Multi-language support
  • Accessibility features
  • Route optimization with time preferences
  • Integration with Google Maps
  • Push notifications for delays
  • Loyalty rewards program

🐛 Troubleshooting

Issue: "Module not found"

Solution: Install dependencies

pip install -r requirements.txt

Issue: "Database not found"

Solution: Initialize database

python database/database_setup.py

Issue: "Port already in use"

Solution: Use a different port

streamlit run app.py --server.port 8502

📝 Configuration

Database Configuration

Edit database/db_config.py to switch between SQLite and MySQL:

USE_MYSQL = False  # Set to True for MySQL

Streamlit Configuration

Edit .streamlit/config.toml for custom settings:

[theme]
primaryColor = "#8B008B"
backgroundColor = "#FFFFFF"
secondaryBackgroundColor = "#F0F2F6"

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

📄 License

This project is for educational and demonstration purposes.

👥 Credits

  • Developer: Bangalore Metro Simulation Team
  • Data Source: Bangalore Metro Rail Corporation (BMRCL)
  • Framework: Streamlit

📞 Support

For issues or questions:

  • Check the troubleshooting section
  • Review the code documentation
  • Contact the development team

🎯 Version

Current Version: 1.0.0 Last Updated: November 13, 2025


🚇 Bangalore Metro Simulation Dashboard - Your Smart Travel Companion

Made with ❤️ using Python & Streamlit

About

Metro Management System is a Python Streamlit web application with MySQL database that enables passengers to book tickets, manage metro cards, and track trips, while administrators can manage stations, routes, and fares with automated fare calculation through database triggers.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages