Railway Reservation System in Python with Source Code

Railway Reservation System in Python
Get Source Code Watch Demo

Looking for a railway reservation system in Python that feels like a real booking website and not a console menu? YatraOne is a full web application built with Django. Passengers search trains, pick their own berth on a live seat map, pay, and get a QR e-ticket. Station staff and an administrator keep the whole network running behind the scenes.

It also handles the hard parts most student projects skip: stuck payments, class upgrades, platform and unreserved tickets, and a proper complaint workflow. Below you will find every module, real screenshots, the tech stack, the exact steps to run it, and the viva questions you should prepare for.

DetailInformation
Project NameYatraOne – Railway Reservation System in Python
LanguagePython 3.10 or newer
FrameworkDjango 5.2
DatabaseSQLite (PostgreSQL supported)
Project TypeWeb Application
CategoryBooking and Reservation System
User RolesPassenger, Station Staff, Administrator
Modules11
DifficultyIntermediate to Advanced
Best ForBCA, MCA, B.Tech CS/IT, M.Tech final year projects
DeveloperUpdategadh

What Is a Railway Reservation System?

A railway reservation system is software that lets passengers check seat availability, book a seat on a specific train and date, pay online, and receive a ticket with a unique PNR. Behind the scenes it stops the same seat from being sold twice, tracks payments and refunds, and gives railway staff tools to verify tickets and manage trains. YatraOne builds all of this in Python with the Django framework.

About This Railway Reservation System in Python

Booking a train ticket sounds simple until something goes wrong: two people grab the same berth, money is debited but no ticket appears, or a complaint is never answered. Most student projects ignore these cases, and that is exactly where viva examiners ask their toughest questions.

YatraOne answers them in working code. A berth can never be sold twice for the same journey segment, every payment is verified before confirmation, late or mismatched payments are recovered or refunded automatically, and complaints follow a fixed five-stage lifecycle. We set it up on a clean Windows computer from the download ZIP and ran all 52 automated tests before writing this post, so the steps below are the ones that actually work.

Key Features of the Railway Reservation System in Python

Passenger Module

  • Secure Sign-Up: e-mail OTP verification, account lock after repeated failed logins, password reset and saved passengers.
  • Train Search: search by route and date, filter by class and time, and compare trains side by side.
  • Live Seat Map: see AVL, RAC and waiting-list status, then auto-allocate or pick your own berth.
  • Reserved Tickets: up to 6 passengers, full fare breakdown, a 10-digit PNR, QR e-ticket and PDF receipt.
  • Platform and Unreserved Tickets: separate flows, each with its own QR reference.
  • Class Upgrade: move a confirmed ticket to a higher class on the same train and pay only the fare difference.
  • Cancellation and Refunds: cancel all or one passenger and track the refund.
  • Complaints: linked to a PNR or transaction, tracked from Submitted to Closed.

Payment and Recovery

  • Verified Payments: orders are confirmed only after verification, with Success, Pending and Failed outcomes.
  • Duplicate Protection: no double charges; an extra successful payment is refunded.
  • Automatic Recovery: late payments re-check seats and refund in full if they are gone.
  • Safe Upgrades: if an upgrade fails, the original booking stays untouched and the money is returned.

Staff Module

  • Ticket Verification: check a PNR, QR link, PLT or UTS reference in seconds.
  • Recovery Desk: take a stuck case, verify it with the gateway, refund it, add notes and close it.
  • Investigation Records: every action is logged with the staff member and time.
  • Train Operations: delays, reschedules, cancellations, platform changes and passenger lists.

Admin Module

  • Master Data: manage stations, trains, routes, stops, coaches, seats, classes, fares, schedules and platforms.
  • Analytics Dashboard: revenue, bookings, 30-day trends and CSV reports, plus user and staff management.

YatraOne vs a Typical Student Railway Project

FeatureTypical Student ProjectYatraOne
InterfaceConsole menu or single formFull website with three role dashboards
Seat bookingSeat count onlyCoach-wise seat map with RAC and waiting list
PaymentsNot handledVerified payments, pending and failed cases, refunds
TicketsPrinted textPNR, QR e-ticket and PDF receipt
Ticket typesReserved onlyReserved, platform and unreserved
TestingManual only52 automated test cases

Technologies Used

LayerTechnologyPurpose
FrontendHTML, CSS, JavaScript, Django TemplatesPages, forms and the interactive seat map
ChartsChart.jsRevenue and booking graphs on the admin dashboard
BackendPython 3, Django 5.2Booking engine, payments, roles and business rules
DatabaseSQLite (PostgreSQL ready)Trains, seats, bookings, payments and logs
Ticketsqrcode, Pillow, ReportLabQR codes, PDF tickets and payment receipts
PaymentsBuilt-in simulated gatewayTest Success, Pending, Failed and mismatch cases safely
E-mailDjango console backend (SMTP ready)OTP codes, notifications and password reset

New to the framework? The official Django 5.2 documentation explains models, views and templates, the three ideas this project is built on.

How It Works

  1. A passenger signs up, enters the OTP sent by e-mail and adds saved passengers to the profile.
  2. The passenger searches a route and date, compares trains and opens the seat map for the chosen class.
  3. Seats are chosen or auto-allocated, the payment is verified, and only then is the booking confirmed with a PNR and QR e-ticket.
  4. If a payment is stuck or mismatched, the recovery engine confirms the booking or refunds the money, and unresolved cases reach the staff Recovery desk.
  5. Staff verify tickets, investigate payments, update train status and resolve complaints stage by stage.
  6. The administrator manages the network and watches revenue and booking trends on the analytics dashboard.
How the railway reservation system in Python works from train search to QR e-ticket
The booking flow: search, pick seats, verified payment, QR e-ticket

This end-to-end flow is what makes YatraOne a complete railway reservation system in Python rather than a single booking form.

How to Run the Railway Reservation System in Python

Step 1: Prerequisites

Install Python 3.10 or newer from python.org and tick “Add python.exe to PATH”. No MySQL or XAMPP is needed.

Step 2: Download and Open the Project

Extract the ZIP and open a terminal in the folder that contains manage.py.

Step 3: Create a Virtual Environment and Install Dependencies

python -m venv venv
venv\Scripts\activate
python -m pip install -r requirements.txt

On macOS or Linux, activate with source venv/bin/activate.

Step 4: Configure the Environment and Database

copy .env.example .env
python manage.py migrate

The included database already holds demo data. To start fresh, delete db.sqlite3, then run the two commands above again followed by:

python manage.py seed_data --with-bookings

Step 5: Run the App

python manage.py runserver localhost:8001

Open http://localhost:8001 and sign in with the demo accounts from the README. A PDF setup guide is included.

Railway Reservation System in Python: Demo Video

Watch the full walkthrough: a passenger books a ticket on the seat map, a payment gets stuck and is recovered, and the staff desk and admin dashboard handle the rest.

Train Ticket Reservation System in Python and Django – full demo

Railway Reservation System in Python: Project Screenshots

Passenger Screens

Home page of the railway reservation system in Python with train search form
Home page with the train search form and today’s departures
YatraOne sign-up page with e-mail OTP registration
Create account page (an e-mail OTP verifies every new user)
Train search results with class-wise availability and fares
Search results with class-wise availability, fares and filters
Train details page with route, timetable and rake composition
Train details: route, timetable, platforms and coaches
Live coach and berth seat map in the railway reservation system in Python
Choosing berths on the live coach seat map
Booking details page with passengers, fare summary and payment
Booking details with passengers, fare summary and payment record
QR e-ticket with PNR generated by the railway reservation system in Python
QR e-ticket with PNR, seat numbers and a VALID stamp
Class upgrade page showing the fare difference per passenger
Class upgrade: pay only the fare difference
Platform ticket booking page with station-wise platform fares
Platform ticket booking with station-wise fares
Unreserved general ticket booking form with fare classes
Unreserved (general) ticket booking
Register a complaint form linked to a PNR or transaction
Raising a complaint linked to a PNR or transaction
Passenger dashboard with upcoming journeys and notifications
Passenger dashboard with upcoming journeys and alerts

Staff Screens

Station staff desk with today's trains and open cases
Station desk: today’s trains, recovery cases and complaints
Staff ticket verification showing a valid PNR with passenger list
Ticket verification by PNR or QR link

Admin Screens

Admin analytics dashboard of the railway reservation system in Python
Admin operations dashboard with revenue and booking charts
Admin train management list with routes and train types
Managing trains, routes and train types

Why This Is a Great Final Year Project

  • Viva-ready logic: seat locking, payment verification and refund safety give you strong answers to “what happens if…” questions.
  • Three real user roles: passenger, staff and admin show you understand access control and workflows.
  • Placement-relevant stack: Python and Django are widely used in product companies and start-ups.
  • Tested code: 52 automated test cases prove the features work, which very few student projects can claim.
  • Resume-worthy scope: 11 modules, PDF and QR generation, and an analytics dashboard look impressive on a CV.
  • Easy to demo: show every payment outcome live without real money.

Viva Questions on the Railway Reservation System in Python

How do you stop the same seat being booked twice?

Each seat is allocated per journey segment inside a database transaction, so a berth already taken for any part of the trip cannot be given to another passenger.

What happens if money is debited but the booking fails?

The payment is marked as a mismatch. The recovery engine verifies it with the gateway, then confirms the booking if seats are still available or issues a full refund, and staff can follow up on the Recovery desk.

Why did you choose Django?

Django gives a secure login system, an ORM for the database, form validation and an admin site out of the box, so more time goes into the booking logic instead of boilerplate.

How to Download / Get This Project

The YatraOne package includes:

  • Complete Source Code (Python, Django, templates and static files)
  • Ready-to-use demo database with stations, trains and sample bookings
  • Step-by-step “How to Run” PDF guide

Comparing options?
See the railway reservation system in Java, the online railway reservation system in PHP and MySQL, or the bus ticket booking system in Django. For more ideas, browse our Python projects with source code and the top Python final year projects. If you like Django, the employee management system using Django, the pharmacy management system in Django and the online banking system in Python and Django follow the same structure.

Possible Extensions / Future Enhancements

  • Connect a real payment gateway such as Razorpay or a UPI provider in place of the simulated one.
  • Add live train running status using a public railway data source.
  • Build a Tatkal booking window with time-based quotas.
  • Add a REST API with Django REST Framework for a mobile app.
  • Use machine learning to predict waiting-list confirmation chances.

Watch full project walkthroughs, setup videos and new final year ideas every week on our channel.

Subscribe to DecodeIT2 on YouTube

Frequently Asked Questions

Which technologies are used in this railway reservation system in Python?

The backend uses Python 3 and Django 5.2, the database is SQLite (PostgreSQL is supported), and the frontend uses HTML, CSS, JavaScript and Chart.js. ReportLab, qrcode and Pillow create the PDF tickets and QR codes.

Is this project suitable for BCA, MCA and B.Tech students?

Yes. It suits BCA, MCA, B.Tech CS/IT and M.Tech submissions. It is intermediate to advanced, but the code is organised by module, so each part is easy to explain in a viva.

Does it need MySQL or real payments to run?

No. It runs on SQLite and a built-in simulated gateway, so you can demo every payment and refund case without real money.

Can I customise the project and deploy it online?

Yes. Add your own stations, trains and fares from the admin panel, switch to PostgreSQL in the settings, and deploy on any Django-ready host.

Want the complete, ready-to-run project?

Get Source Code
This project Get Source Code
Written by Rishabh Saini Founder, UpdateGadh

Rishabh Saini is the founder of UpdateGadh. He has 5 years of experience building PHP, Python, Java, AI and ML projects, and works on projects with the latest and trending technologies. He has helped 2,000+ BCA, MCA and B.Tech students with final year projects. Every project on UpdateGadh is built and tested by him before it is published.

Leave a Reply

Your email address will not be published. Required fields are marked *