Giter Site home page Giter Site logo

irctc-backend's Introduction

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://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 โญ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.