Skip to content

Dewick75/Smart-Que-System-with-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚌 Smart Queue Management System

πŸ“‹ Overview

An AI-powered bus queue management system that provides:

  • 🎫 Smart Seat Reservation with QR codes for contactless boarding
  • πŸ€– AI Queue Prediction to forecast busy stops and optimize schedules
  • πŸ“± Real-time Updates for passengers and operators
  • πŸ‘₯ Role-based Dashboards for staff, managers, and passengers
  • 🚨 Interactive Alert System for operational efficiency

image image image

πŸ—οΈ Project Structure

smart-queue-management/
β”œβ”€β”€ πŸ“ backend/
β”‚   └── enhanced_app.py            # Main Flask application
β”œβ”€β”€ πŸ“ frontend/
β”‚   β”œβ”€β”€ index.html                 # Public booking interface
β”‚   β”œβ”€β”€ staff.html                 # Staff operations interface
β”‚   β”œβ”€β”€ manager.html               # Manager dashboard
β”‚   β”œβ”€β”€ πŸ“ css/                    # Stylesheets
β”‚   └── πŸ“ js/                     # JavaScript applications
β”œβ”€β”€ πŸ“ database/
β”‚   └── init.sql                  # Database initialization
β”œβ”€β”€ πŸ“ tests/
β”‚   β”œβ”€β”€ test_live_system.py       # Live system testing
β”‚   └── demo_all_features.py      # Feature demonstration
β”œβ”€β”€ πŸ“„ requirements.txt            # Python dependencies
β”œβ”€β”€ πŸ“„ run_enhanced.py             # System launcher
└── πŸ“„ README.md                  # This documentation

πŸ”§ Technology Stack

Backend

  • Flask - Web framework and API server
  • SQLAlchemy - Database ORM
  • SQLite - Lightweight database
  • Scikit-learn - AI/ML predictions
  • NumPy - Data processing
  • qrcode + Pillow - QR code generation

Frontend

  • HTML5/CSS3 - Responsive web interfaces
  • JavaScript ES6+ - Interactive functionality
  • Chart.js - Data visualization
  • Font Awesome - Icons

Database

  • 6 Core Tables: Routes, Stops, Buses, Bookings, Queue Data, Alerts
  • Relationships: Foreign keys and proper constraints
  • Indexes: Optimized for performance

πŸš€ Quick Start

1. Install Dependencies

pip install -r requirements.txt

2. Start the System

python run_enhanced.py

3. Access Interfaces

πŸ€– AI System

How AI Works

The system uses Scikit-learn LinearRegression to predict queue lengths: image

Input Features

  • Historical queue patterns
  • Time of day and day of week
  • Weather conditions
  • Passenger satisfaction scores

Prediction Process

  1. Collect real-time queue data
  2. Extract time and environmental features
  3. Train model on historical patterns
  4. Generate next-hour predictions
  5. Provide smart travel recommendations

Smart Recommendations

  • "Good time to travel" - Queue ≀ 5 people
  • "Moderate wait expected" - Queue 6-10 people
  • "Consider alternative time" - Queue > 10 people

πŸ—„οΈ Database Architecture

Core Tables

-- Route Management
route (id, name, start_point, end_point, estimated_duration, price)
bus_stop (id, name, latitude, longitude, route_id, order_in_route)
bus (id, bus_number, route_name, capacity, current_location, status)

-- Booking System
booking (id, booking_id, passenger_info, bus_id, route_id,
         pickup_stop_id, dropoff_stop_id, seat_number, qr_code, status)

-- AI Training Data
queue_data (id, bus_stop_id, timestamp, queue_length, waiting_time,
           weather_condition, day_of_week, hour_of_day)

-- Operations Management
alert (id, alert_type, message, severity, bus_id, route_id,
       created_at, resolved_at, status)

Sample Data

  • 3 Routes: Downtown Express, Airport Shuttle, University Line
  • 11 Bus Stops: Strategic locations across routes
  • 6 Active Buses: Fleet capacity 35-45 seats each

🎯 Key Features

🎫 Seat Reservation System

  • Real-time seat availability
  • Enhanced QR code generation with passenger details
  • Automatic seat assignment
  • Email/phone validation

πŸ€– AI Queue Prediction

  • Machine learning-based queue forecasting
  • Historical pattern analysis with weather factors
  • <100ms prediction generation
  • Smart travel recommendations

πŸ“± Real-time Updates

  • Live queue monitoring (30-second refresh)
  • WebSocket communication
  • Mobile-responsive design
  • Cross-platform compatibility

πŸ‘₯ Role-Based Interfaces

Passenger Interface

  • Intuitive booking flow
  • QR code display
  • Real-time queue status
  • AI predictions

Staff Interface

  • Interactive alert management
  • QR code scanning
  • Bus status monitoring
  • Passenger verification

Manager Dashboard

  • Analytics with Chart.js
  • Route performance metrics
  • System health monitoring
  • Alert resolution tracking

🚨 Alert System

  • Automatic alert classification
  • Severity-based routing (Low/Medium/High)
  • Role-based alert distribution
  • Acknowledge β†’ Resolve workflow

πŸ“Š System Architecture Diagrams

The system follows a three-tier architecture with AI integration. Interactive diagrams have been generated above showing:

  1. System Architecture - Frontend, Backend, and Database layers
  2. Database ERD - Table relationships and constraints
  3. AI Prediction Workflow - Machine learning pipeline
  4. User Journey - Complete interaction sequence

πŸ”„ How It Works

Passenger Journey

  1. Select route and stops
  2. Book seat with automatic assignment
  3. Receive enhanced QR code
  4. Check real-time queue status
  5. Get AI travel recommendations

Staff Operations

  1. Monitor real-time alerts
  2. Scan passenger QR codes
  3. Update bus status
  4. Manage incidents
  5. Track daily operations

Manager Analytics

  1. View system KPIs
  2. Analyze route performance
  3. Monitor alerts system-wide
  4. Generate operational reports
  5. Optimize resource allocation

πŸ§ͺ Testing

Run Tests

# Live system integration tests
python tests/test_live_system.py

# Feature demonstration
python tests/demo_all_features.py

What Gets Tested

  • βœ… API endpoints and database operations
  • βœ… Booking system end-to-end flow
  • βœ… QR code generation and validation
  • βœ… AI prediction accuracy
  • βœ… Alert system functionality
  • βœ… Real-time queue monitoring

Performance

  • API Response: <200ms average
  • AI Predictions: <100ms generation
  • Concurrent Users: 100+ supported
  • System Uptime: 99.9% during testing

πŸ”§ API Endpoints

Public APIs

  • GET /api/routes - Get all routes
  • POST /api/book-enhanced - Create booking with QR
  • GET /api/queue/{stop_id} - Get queue status + AI prediction
  • GET /api/dashboard/stats - System statistics

Staff APIs

  • GET /api/staff/alerts - Get staff alerts
  • POST /api/staff/scan-qr - Scan passenger QR code
  • GET /api/staff/my-bus - Get bus information

Manager APIs

  • GET /api/manager/overview - Dashboard overview
  • GET /api/manager/alerts - Manager alerts
  • GET /api/manager/route-analytics/{id} - Route analytics

⚑ Performance

  • API Response Time: <200ms for most calls
  • AI Predictions: <100ms generation time
  • Concurrent Users: Supports 100+ simultaneous bookings
  • Database: Optimized with indexes for fast queries
  • Real-time Updates: 30-second refresh cycle

πŸ› οΈ Development

Adding New Features

  1. Backend: Add routes in backend/enhanced_app.py
  2. Frontend: Update corresponding HTML/JS files
  3. Database: Modify models and run migrations
  4. Tests: Add test cases in tests/ directory

Code Structure

  • Backend: Single Flask app with all functionality
  • Frontend: Role-based interfaces (Public, Staff, Manager)
  • Database: SQLite with 6 core tables
  • Tests: Live system and feature demonstration tests

image image image image image image image

πŸ“ License

This project is for educational and demonstration purposes.

🀝 Contributing

  1. Fork the repository
  2. Create feature branch
  3. Add tests for new features
  4. Submit pull request

Built with ❀️Dewick75 for efficient public transportation

About

Smart Que System

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published