Skip to content
Mounika-2604Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš† RailX - Railway Enquiry & Reservation System

Python Streamlit SQLite

RailX is a full-stack, database-driven Railway Enquiry and Reservation System, designed to simulate or power a real-world railway ticketing ecosystem similar to IRCTC, Amtrak, or European rail systems.


πŸ“‹ Table of Contents


✨ Features

For Passengers

  • πŸ” Plan Journey - Search trains by origin, destination, and date
  • πŸš† Train Details - View complete route information, timings, and halts
  • πŸ’Ί Seat Availability - Check real-time availability by class and quota
  • πŸ’° Fare Enquiry - Get class-wise fare breakdown
  • πŸ’³ My Trips - View bookings, check PNR status, and cancel tickets
  • 🎫 Online Booking - Complete booking flow with payment integration

For Staff

  • 🏒 Staff Console - Over-the-counter ticket booking
  • πŸ” PNR Enquiry - Quick passenger and booking lookup
  • ❌ Cancellations - Process cancellations and refunds
  • πŸ†” ID Verification - Capture passenger ID proofs

For Inventory Managers

  • βš™οΈ Inventory Management - Manage daily coach inventory and quotas
  • πŸš‚ Coach Management - Add coaches and configure seats
  • πŸ’Ί Seat Allocation - Manual seat assignment for bookings
  • πŸ“Š Chart Preparation - Generate seat charts by coach

For Administrators

  • 🧾 Admin Panel - Comprehensive system management
  • πŸš† Train Management - Add/update trains and routes
  • πŸ“ Station Management - Manage station database
  • πŸ’Ί Class Management - Configure travel classes and fare slabs
  • 🎫 Concessions - Define discount rules
  • πŸ›οΈ Add-ons - Manage additional services
  • πŸ“Š System Stats - View analytics and audit logs

πŸ› οΈ Tech Stack

  • Frontend/UI: Streamlit (multi-page web application)
  • Database: SQLite3 (relational, file-based)
  • Backend: Python 3.8+
  • Authentication: SHA-256 password hashing
  • Architecture: Role-based access control (RBAC)

πŸ“¦ Installation

Prerequisites

  • Python 3.8 or higher
  • uv

Step 1: Clone the Repository

git clone <repository-url>
cd railx

Step 2: Install Dependencies

Or using uv :

uv sync

Step 3: Initialize Database

python database/init_db.py

This will create the SQLite database (railx.db) with all required tables.

Step 4: Populate Sample Data (Optional)

python database/populate_sample_data.py

This will insert:

  • 15+ railway stations
  • 15+ trains with routes
  • 50+ coaches
  • 2000+ seats
  • Travel classes, quotas, concessions, and add-ons

πŸš€ Quick Start

  1. Start the Streamlit application:
streamlit run main.py
  1. Open your browser and navigate to http://localhost:8501

  2. Register a new account:

    • Click "Register here"
    • Fill in your details
    • For Passenger role: No key required
    • For Staff/Admin/Inventory Manager: Use respective role keys (see User Roles)
  3. Login and start exploring!


πŸ“ Project Structure

railx/
β”‚
β”œβ”€β”€ main.py                       # Main entry: login, registration, role-based routing
β”‚
β”œβ”€β”€ database/
β”‚   β”œβ”€β”€ schema.sql               # Full relational schema (22 tables)
β”‚   β”œβ”€β”€ init_db.py               # Initializes SQLite DB from schema
β”‚   β”œβ”€β”€ sample_data.sql          # Sample data SQL script
β”‚   β”œβ”€β”€ populate_sample_data.py  # Python script to populate sample data
β”‚   └── railx.db                 # SQLite database file (created after init)
β”‚
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ db_utils.py              # DB connection & query utilities
β”‚   β”œβ”€β”€ auth_utils.py            # Authentication, password hashing, role handling
β”‚   └── role_keys.json           # Secret keys for privileged role registration
β”‚
β”œβ”€β”€ pages/
β”‚   β”œβ”€β”€ 1_πŸ”_Plan_Journey.py     # Train search & booking page
β”‚   β”œβ”€β”€ 2_πŸš†_Train_Details.py    # Route & station order view
β”‚   β”œβ”€β”€ 3_πŸ’Ί_Availability.py     # Seat availability matrix & fare enquiry
β”‚   β”œβ”€β”€ 4_πŸ’³_My_Trips.py         # User trips (PNR list) & cancellation
β”‚   β”œβ”€β”€ 5_🧾_Admin_Panel.py     # Admin controls (train/class/fare management)
β”‚   β”œβ”€β”€ 6_🏒_Staff_Console.py    # Station staff / counter interface
β”‚   └── 7_βš™οΈ_Inventory_Manager.py # Coach/class inventory & quota management
β”‚
β”œβ”€β”€ AGENTS.md                    # Detailed technical documentation
β”œβ”€β”€ README.md                    # This file
└── requirements.txt             # Python dependencies

πŸ—„οΈ Database Schema

RailX uses a comprehensive relational database with 22 tables covering:

Core Entities

  • Stations - Railway station information
  • Trains - Train details (number, name, type, days of run)
  • Train Routes - Station order, timings, distances, halts
  • Travel Classes - Class codes, rates, charges
  • Coaches - Coach composition per train
  • Seats - Individual seat details with berth types

Booking & Operations

  • Users - User accounts with role-based access
  • Bookings - PNR-level booking records
  • Booking Passengers - Passenger details per booking
  • Payments - Payment transactions
  • Cancellations - Cancellation and refund records
  • Daily Coach Inventory - Real-time seat availability

Configuration & Management

  • Fare Slabs - Distance-based fare slabs
  • Concessions - Discount rules
  • Quotas - Booking quotas (General, Tatkal, Ladies, etc.)
  • Add-ons - Additional services (meals, bedroll, insurance)

Operational

  • Seat Allocation Log - Audit trail for seat changes
  • Train Status - Live train tracking
  • Train Announcements - System announcements
  • User Logins - Login history
  • System Audit Log - Administrative actions

For complete schema details, see database/schema.sql or AGENTS.md.


πŸ‘₯ User Roles

RailX implements role-based access control with secure registration keys:

Role Capabilities Registration Key
Passenger Search, book, pay, manage trips None (public)
Staff Over-the-counter booking, cancellations, modifications, passenger enquiry STAFF-ACCESS-2025
Inventory Manager Manage daily coach inventory, quotas, seat allocation INV-ACCESS-2025
Admin Full control: trains, fares, concessions, users, audit logs ADMIN-ACCESS-2025

Role keys are stored in utils/role_keys.json and can be modified for security.


πŸ“„ Pages & Features

1. πŸ” Plan Journey

  • Search trains by origin, destination, and date
  • View train results with departure/arrival times and duration
  • Complete booking flow:
    • Select train and class
    • Add passenger details
    • Calculate fare
    • Process payment
    • Generate PNR

2. πŸš† Train Details

  • View train information by train number
  • Display complete route with:
    • Station order and sequence
    • Arrival/departure times
    • Halt durations
    • Distance between stations
    • Day offsets
    • Technical halts

3. πŸ’Ί Availability

  • Check seat availability by:
    • Train number
    • Journey date
    • Travel class
    • Quota
  • Visual availability charts
  • Fare Enquiry - Class-wise fare breakdown

4. πŸ’³ My Trips

  • View all user bookings
  • PNR status enquiry
  • Passenger details
  • Booking cancellation

5. 🧾 Admin Panel

  • Train & Route Management - Add trains, define routes
  • Station Management - Add/update stations
  • Travel Classes - Configure classes and rates
  • Fare Slabs - Distance-based pricing
  • Concessions - Discount rules
  • Add-ons - Additional services
  • Users & Audit - User management and audit logs
  • System Stats - Analytics dashboard

6. 🏒 Staff Console

  • Quick train search
  • Over-the-counter booking
  • ID proof capture
  • PNR enquiry
  • Cancellation & refund processing

7. βš™οΈ Inventory Manager

  • Coach Management - Add coaches, configure seats
  • Daily Inventory - Manage seat availability per date/quota
  • Seat Allocation - Manual seat assignment
  • Chart Preparation - Generate seat charts

πŸ“– Usage Guide

For Passengers

  1. Search for Trains:

    • Go to "Plan Journey"
    • Enter From/To station codes (e.g., MAS, NDLS)
    • Select journey date
    • Click "Search Trains"
  2. Book a Ticket:

    • Click "Book" on desired train
    • Select class and quota
    • Enter passenger details
    • Review fare and confirm booking
    • Receive PNR number
  3. Check PNR Status:

    • Go to "My Trips" β†’ "PNR Status"
    • Enter PNR number
  4. Cancel Booking:

    • Go to "My Trips"
    • Find your booking
    • Click "Cancel Booking"

For Staff

  1. Counter Booking:

    • Go to "Staff Console" β†’ "Quick Booking"
    • Search train β†’ Select β†’ Enter passenger details
    • Process payment β†’ Generate PNR
  2. PNR Enquiry:

    • Go to "PNR Enquiry" tab
    • Enter PNR to view booking details
  3. Cancellation:

    • Go to "Cancellations" tab
    • Enter PNR β†’ Process cancellation β†’ Calculate refund

For Administrators

  1. Add a Train:

    • Go to "Admin Panel" β†’ "Trains & Routes"
    • Fill train details β†’ Add route stations
  2. Manage Stations:

    • Go to "Stations" tab
    • Add new stations with coordinates
  3. Configure Fares:

    • Go to "Travel Classes" β†’ Add class with rates
    • Go to "Fare Management" β†’ Add fare slabs

🎲 Sample Data

The project includes a comprehensive sample data script:

Populate Sample Data

cd database
python populate_sample_data.py

This will insert:

  • 15 Stations - Major Indian railway stations (MAS, NDLS, BCT, HWH, etc.)
  • 15 Trains - Including Tamil Nadu Express, Rajdhani, Karnataka Express, etc.
  • 50+ Coaches - Across multiple trains and classes
  • 2000+ Seats - Automatically generated with proper berth types
  • Travel Classes - 1A, 2A, 3A, SL, CC, 2S
  • Quotas - GENERAL, TATKAL, LADIES, SENIOR_CITIZEN, DEFENCE
  • Concessions - Senior Citizen, Child, Student, Disabled, War Widow
  • Add-ons - Meals, Bedroll, Insurance, etc.

Clear Sample Data

python populate_sample_data.py --clear

πŸ”’ Security

  • Password Hashing: SHA-256
  • SQL Injection Prevention: Parameterized queries
  • Role-based Access: Secure registration keys
  • Session Management: Streamlit session state
  • Data Integrity: Foreign key constraints enabled
  • Audit Logging: System audit log for critical actions

All role keys are stored in utils/role_keys.json (not hardcoded).


🚧 Future Enhancements

  1. Payment Gateway Integration (Stripe/UPI mock)
  2. Dynamic Fare Pricing (based on occupancy)
  3. Live Train Map View (ETA from delay minutes)
  4. API Endpoints (for mobile app)
  5. TTE Mobile Mode (QR scan, upgrades)
  6. Analytics Dashboard (revenue, occupancy)

🀝 Contributing

RailX is designed as a modular, scalable simulation of a real reservation system. Contributions are welcome!

Development Guidelines

  1. Follow the architecture defined in AGENTS.md
  2. Maintain role-based access control
  3. Use parameterized SQL queries
  4. Follow Streamlit page conventions (see AGENTS.md Section 8)
  5. Preserve referential integrity

Code Structure

  • UI Logic: pages/ directory
  • Database Operations: utils/db_utils.py
  • Authentication: utils/auth_utils.py
  • Schema: database/schema.sql

πŸ“š Documentation

For detailed technical documentation, see:

  • AGENTS.md - Complete system architecture, schema, and agent guidelines
  • database/schema.sql - Full database schema with all tables
  • database/init_db.py - Database initialization script

πŸ“ License

This project is designed for educational and prototyping purposes.


🎯 Mission Summary

RailX is not just a database or UI β€” it's a complete railway ecosystem that models:

  • Train scheduling & halts
  • Passenger booking life-cycle
  • Real-time seat management
  • Fare computation
  • Multi-role operational control

Its goal is to create a modular, scalable simulation of a real reservation system β€” perfect for academic projects, prototyping, or AI-driven agent collaboration.


πŸ’¬ Support

For issues, questions, or contributions, please refer to the project documentation or create an issue in the repository.


Built with ❀️ using Streamlit and SQLite

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages