Skip to content

Adityaat2810/IRCTC-backend

 
 

Repository files navigation

IRCTC Backend

🌟 Stars 🍴 Forks 🐛 Issues 🔔 Open PRs 🔕 Close PRs
Stars Forks Issues Open Pull Requests Close Pull Requests

Project Overview

Built using Node.js, Express, and Sequelize, this system supports functionalities for both regular users and administrators, ensuring efficient handling of train schedules, seat availability, and user bookings.

Youtube video : ↗️

💻 Tech Stacks

Node.js Express.js Sequelize PostgreSQL

-> Key Features <-

  • User Authentication: Secure login and registration functionality for users.
  • Train Management: Administrators can add trains and update seating capacities.
  • Seat Booking: Users can check seat availability and book seats on trains.

Getting Started

Prerequisites

To run this project locally, you will need Node.js and PostgreSQL installed on your machine. Optionally, you can use Docker for running PostgreSQL.

Installation

1. Clone the repository

git clone https://github.com/mayank2808sharma/IRCTC-backend
cd IRCTC-backend

2. Install Dependencies

npm i

3. Set Up Environment Variables

Create a .env file in the root directory and update it with your database and authentication configurations as follows:

PORT= 3000
DB_HOST = hostname 
DB_USER = username for the database
DB_PASSWORD = password for the database
DB_NAME = name of the database
JWT_SECRET = secret key used to sign and verify JSON Web Tokens

4. Database Setup

Make sure your PostgreSQL database is running and the credentials in .env match your database info. Run the following command to set up your database tables:

npm run setdb

5. Start the Server

npm start

This will start the server on http:https://localhost:3000.

API Endpoints

Public Endpoints

  • POST /register - Register a new user Body: { "username": "user1", "password": "password123", "role":"user" }

  • POST /login - Login a user Body: { "username": "user1", "password": "password123" }

User Endpoints

  • GET /trains/availability - Fetch available trains Query: source=CityA&destination=CityB
  • POST /book - Book ticket Body: { "train_id": 1 }
  • GET /booking/details - Get specific booking details Query: booking_id=1

Admin Endpoints

  • POST /admin/train - Add a new train Body: { "train_name": "Express", "source": "CityA", "destination": "CityB", "total_seats": 100 }
  • PATCH /admin/train/:trainId - Increase number of total seats Body: { "add_seats": 120 }

🤝 Our Contributors

Contributors

Thank you for contributing to our repository

Don't forget to give us a ⭐

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%