- User registration and authentication
- Train creation and management (admin only)
- Check train availability between source and destination
- Book seats on available trains (handled race conditions)
- View booking details
- Node.js
- Express.js
- MySQL
- JSON Web Tokens (JWT)
- bcrypt.js
- Clone the repository:
https://github.com/saikrishnasangu/IRCTC_Design.git
- Navigate to the project directory:
cd IRCTC_Design
- Install dependencies:
npm install
- Create a
.env
file and set the following environment variables:HOST
: MySQL database hostUSER
: MySQL database userPASSWORD
: MySQL database passwordNAME
: MySQL database nameJWT_SECRET
: Secret key for JWT token generationADMIN_KEY
: Admin key for protected routes
- Run (generatekeys.js) by using command
node generatekeys
- Then copy and paste generated
JWT_SECRET & ADMIN_KEY
in .env - Create the MySQL database and tables by running the SQL scripts (schema.sql) in the
database
directory. - Start the server:
npm start
POST /auth/register
: Register a new userPOST /auth/login
: Authenticate and obtain a JWT token
POST /trains/create
: Create a new train
GET /trains/availability?source=<source>&destination=<destination>
: Get available trains between source and destinationPOST /bookings/book
: Book seats on a trainGET /bookings/details?trainId=<trainId>
: Get booking details for a specific train
GET /users/me
: Get user details (requires authentication)