Skip to content

rishabh0510rishabh/railway-booking-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

56 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Railway_Booking_System.md

πŸš‚ Railway Booking System

A robust, full-stack web application for searching, booking, and managing train tickets.
Built with Flask and MongoDB, this project features a modular architecture, real-time seat availability calculation, and automated e-ticket generation.


🌟 Key Features

πŸ‘€ User & Profile Management

  • Secure Authentication: User registration and login with password hashing
  • Profile Management: Update personal details and manage saved passengers for faster bookings
  • Booking History: View past and upcoming journeys with status updates

πŸš† Train Search & Booking

  • Smart Search: Filter trains by source, destination, and departure time (Morning, Afternoon, Evening)
  • Real-time Availability: Dynamic calculation of Confirmed, RAC, and Waitlisted seats using MongoDB aggregation pipelines
  • Seat Allocation: Automated logic for assigning seat numbers and berths based on class and preference
  • Waitlist Logic: Automatically handles Confirmed vs. RAC vs. Waitlist status based on capacity

🎫 Ticketing System

  • PDF Generation: Instantly download professional PDF tickets with unique PNRs
  • QR Code Integration: Embedded QR codes on tickets for easy validation
  • Email Notifications: Booking confirmations sent directly to the user's email via SMTP
  • PNR Status: Publicly accessible PNR status checker

πŸ›  Admin Dashboard

  • Manage Trains: Add new trains, routes, and schedules
  • Booking Overview: View all bookings across the system with search functionality
  • Route Visualization: View detailed route stops and timings

πŸ’» Tech Stack

Backend

  • Python
  • Flask (Blueprints, Application Factory Pattern)

Database

  • MongoDB (MongoEngine ODM)

Frontend

  • Jinja2 Templates
  • Bootstrap 5
  • CSS3

Utilities

  • FPDF (PDF Generation)
  • QRCode (Ticket Validation)
  • Flask-Mail (Email Services)
  • Flask-WTF (Form Handling & CSRF Protection)

πŸš€ Installation & Setup

Prerequisites

  • Python 3.10+
  • MongoDB (Local or Atlas)
  • Gmail Account (for email notifications – App Password required)

Steps

Clone the Repository

git clone https://github.com/yourusername/railway-booking-system.git
cd railway-booking-system

Create Virtual Environment

python -m venv venv
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activate

Install Dependencies

pip install -r requirements.txt

Environment Configuration

Create a .env file in the root directory:

SECRET_KEY=your_secure_secret_key
MONGODB_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/railway_db
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_app_password

Initialize Database

Run the script to populate the database with sample trains and users:

python init_db.py

Run the Application

python app.py

Visit: http://127.0.0.1:5000


πŸ“‚ Project Structure

railway-booking-system/
β”œβ”€β”€ app.py                  # Entry point
β”œβ”€β”€ config.py               # App configuration
β”œβ”€β”€ init_db.py              # Database seeder script
β”œβ”€β”€ models.py               # Database schemas (User, Train, Booking)
β”œβ”€β”€ requirements.txt        # Dependencies
└── railway_app/            # Main Application Package
    β”œβ”€β”€ __init__.py         # App factory & extension init
    β”œβ”€β”€ utils.py            # Helper functions (PDF, Email, Logic)
    β”œβ”€β”€ routes/             # Blueprints
    β”‚   β”œβ”€β”€ admin.py
    β”‚   β”œβ”€β”€ auth.py
    β”‚   β”œβ”€β”€ booking.py
    β”‚   └── main.py
    β”œβ”€β”€ static/             # CSS, Images
    └── templates/          # HTML Templates

🀝 Contributing

Contributions are welcome!
Please follow these steps:

  1. Fork the project
  2. Create your feature branch
    git checkout -b feature/AmazingFeature
  3. Commit your changes
    git commit -m "Add some AmazingFeature"
  4. Push to the branch
    git push origin feature/AmazingFeature
  5. Open a Pull Request

πŸ“œ License

Distributed under the MIT License.
See LICENSE for more information.

About

A modular Flask & MongoDB railway booking engine. Features real-time seat availability (Confirmed/RAC/Waitlist), smart berth allocation, PDF ticketing with QR codes, and email automation. Built with a scalable Blueprint architecture for high performance.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors