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.
- Features
- Tech Stack
- Installation
- Quick Start
- Project Structure
- Database Schema
- User Roles
- Pages & Features
- Usage Guide
- Sample Data
- Security
- Future Enhancements
- Contributing
- π 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
- π’ 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
- βοΈ 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
- π§Ύ 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
- 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)
- Python 3.8 or higher
- uv
git clone <repository-url>
cd railxOr using uv :
uv syncpython database/init_db.pyThis will create the SQLite database (railx.db) with all required tables.
python database/populate_sample_data.pyThis will insert:
- 15+ railway stations
- 15+ trains with routes
- 50+ coaches
- 2000+ seats
- Travel classes, quotas, concessions, and add-ons
- Start the Streamlit application:
streamlit run main.py-
Open your browser and navigate to
http://localhost:8501 -
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)
-
Login and start exploring!
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
RailX uses a comprehensive relational database with 22 tables covering:
- 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
- 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
- Fare Slabs - Distance-based fare slabs
- Concessions - Discount rules
- Quotas - Booking quotas (General, Tatkal, Ladies, etc.)
- Add-ons - Additional services (meals, bedroll, insurance)
- 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.
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.
- 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
- 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
- Check seat availability by:
- Train number
- Journey date
- Travel class
- Quota
- Visual availability charts
- Fare Enquiry - Class-wise fare breakdown
- View all user bookings
- PNR status enquiry
- Passenger details
- Booking cancellation
- 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
- Quick train search
- Over-the-counter booking
- ID proof capture
- PNR enquiry
- Cancellation & refund processing
- Coach Management - Add coaches, configure seats
- Daily Inventory - Manage seat availability per date/quota
- Seat Allocation - Manual seat assignment
- Chart Preparation - Generate seat charts
-
Search for Trains:
- Go to "Plan Journey"
- Enter From/To station codes (e.g., MAS, NDLS)
- Select journey date
- Click "Search Trains"
-
Book a Ticket:
- Click "Book" on desired train
- Select class and quota
- Enter passenger details
- Review fare and confirm booking
- Receive PNR number
-
Check PNR Status:
- Go to "My Trips" β "PNR Status"
- Enter PNR number
-
Cancel Booking:
- Go to "My Trips"
- Find your booking
- Click "Cancel Booking"
-
Counter Booking:
- Go to "Staff Console" β "Quick Booking"
- Search train β Select β Enter passenger details
- Process payment β Generate PNR
-
PNR Enquiry:
- Go to "PNR Enquiry" tab
- Enter PNR to view booking details
-
Cancellation:
- Go to "Cancellations" tab
- Enter PNR β Process cancellation β Calculate refund
-
Add a Train:
- Go to "Admin Panel" β "Trains & Routes"
- Fill train details β Add route stations
-
Manage Stations:
- Go to "Stations" tab
- Add new stations with coordinates
-
Configure Fares:
- Go to "Travel Classes" β Add class with rates
- Go to "Fare Management" β Add fare slabs
The project includes a comprehensive sample data script:
cd database
python populate_sample_data.pyThis 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.
python populate_sample_data.py --clear- 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).
- Payment Gateway Integration (Stripe/UPI mock)
- Dynamic Fare Pricing (based on occupancy)
- Live Train Map View (ETA from delay minutes)
- API Endpoints (for mobile app)
- TTE Mobile Mode (QR scan, upgrades)
- Analytics Dashboard (revenue, occupancy)
RailX is designed as a modular, scalable simulation of a real reservation system. Contributions are welcome!
- Follow the architecture defined in
AGENTS.md - Maintain role-based access control
- Use parameterized SQL queries
- Follow Streamlit page conventions (see
AGENTS.mdSection 8) - Preserve referential integrity
- UI Logic:
pages/directory - Database Operations:
utils/db_utils.py - Authentication:
utils/auth_utils.py - Schema:
database/schema.sql
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
This project is designed for educational and prototyping purposes.
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.
For issues, questions, or contributions, please refer to the project documentation or create an issue in the repository.
Built with β€οΈ using Streamlit and SQLite