A full-stack Railway Reservation System built with React, Tailwind CSS, Node.js, Express, MongoDB, and JWT authentication.
- User signup, login, logout, and protected dashboard
- Train search by source, destination, date, and exact stop-count filters
- Route-aware train details with timings, duration, and seat availability
- Smart seat allocation with
window,lower, andaislepreferences - Segment-based seat booking so seats can be reused across non-overlapping route segments
- Mock payment lifecycle with success, failure, and refund statuses
- PNR generation, ticket records, booking history, waitlist promotion, and cancellations
- Seed scripts for stations, trains, seats, and demo users
client/ React + Tailwind frontend
server/ Express + MongoDB backend
-
Install dependencies:
npm install
-
Create environment files:
- Copy
server/.env.exampletoserver/.env - Copy
client/.env.exampletoclient/.env
- Copy
-
Start MongoDB locally or provide a MongoDB Atlas connection string.
-
Seed the database:
npm run seed
-
Run the backend:
npm run server:dev
-
Run the frontend in a second terminal:
npm run client:dev
- User:
aarav@example.com/Password123! - User:
priya@example.com/Password123! - Admin seed (future use):
admin@railway.com/Password123!
- The frontend expects the backend at
http://localhost:5000. - Payments are mocked and do not connect to a real payment gateway.
- Waitlist promotion runs automatically after confirmed ticket cancellation.
POST /api/auth/signupPOST /api/auth/loginGET /api/auth/meGET /api/trains/searchGET /api/trains/:idPOST /api/bookings/quotePOST /api/bookingsGET /api/bookings/meGET /api/bookings/:pnrPATCH /api/bookings/:id/cancelPOST /api/payments/mock-checkoutPATCH /api/payments/:id/mock-complete