Skip to content

ayushnagar123/ticketing-system

Repository files navigation

Heroku App Status Website GitHub language count

Ticketing-system

Ticketing System is a movie theater based ticket management system created for Zomentum placement hiering assignment.

Hosting link

https://ticketing-system-api.herokuapp.com

Features

  • Signup user with phone number.
  • Login with phone number and password in body.
  • Login with token if saved in cache and passed in header along with phone number in body.
  • Login with refresh token by assigning new token if refresh token is passed successfully in header along with phone number in body.
  • Unauthorize login if non of the token,refresh token and password is provided along with phone number for authentication.
  • Bycrypting password for secure storage of login credentials.
  • Forbidding login in case of unregistered phone number.
  • Bad request in case of input field validation are incorrect.
  • Create a ticket using name and phone number and timing.
  • Update a ticket using name and phone number and timing.
  • Delete a ticket using name and phone number and timing.
  • Not allowing more than 20 people to book ticket for a show.
  • Update ticket as used ticked on entry.
  • Display all ticket using name and phone number and timing.
  • Expire a ticket after 8 hours.
  • Create a theater hall authenticting admin rights.
  • Docker image created.

How to Setup?

Step 1:- Install nodejs

  • Download and follow the steps in the given link to install nodejs.

Step 2:- Install mongodb

  • Download and follow the steps in the given link to install mongodb.

Step 3:- Cloning project

  • Fork the repository on github.
  • Clone the repository by git clone https://github.com/<username>/ticketing-system.git replace the username with yours.

Step 4:- Installling modules

  • To install the nodejs modules which are required to run the project by running command npm install to install project dependencies and npm i -D to run dev dependencies.

Step 5:- Create environment variables file

  • Create a .env file in the root folder of your project and add you can refer .env.development file to refer its structure. Please change the port of the Database URL if not 27017 for mongodb.

Step 6:- Test the project

  • To test the project, you need to run the command npm run test

Step 7:- Run the project

  • To run the project, you need to run the command nodemon start

Step 8 :- Create docker image

  • build a docker image docker build -t ticketing-system
  • run the command docker run -p 49160:3000 -d ticketing-system
  • to setup environment variable docker run --env DATABASE_URL=mongodb://127.0.01:27017/ticket-system ticketing-system env | grep VAR
  • to test the commaand run curl -i localhost:49160
Content-Type: application/json; charset=utf-8
Content-Length: 80
ETag: W/"50-cZkIpDrRGFvyMRP9XYpr8LNxngE"
Date: Mon, 31 Aug 2020 03:16:19 GMT
Connection: keep-alive

{"status":200,"statusMessage":"OK","message":"Welcome to PVR Ticketing portal!"}

Means your setup is working.

Package Description

  • express :- Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
  • mongoose :- Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.
  • morgan :- HTTP request logger middleware for node.js.
  • nodemon :- nodemon will watch the files in the directory in which nodemon was started, and if any files change, nodemon will automatically restart your node application.
  • dotenv :- Dotenv module loads environment variables from a .env file into process.env
  • debug :- debug exposes a function; simply pass this function the name of your module, and it will return a decorated version of console.error for you to pass debug statements to.
  • moment-timezone :- Used in timezone based conversion.

Directory structure

After you have setup the project successfully, you shall have similar directory structure.

|- app/
    |- controllers/
        - tickets.js
        - users.js
    |- models/
        - tickets.js
        - users.js
    |- routes/
        - tickets.js
        - users.js
    |- utils/
        - error_handler.js
        - response_handler.js
        - status_handler.js
|- bin/
    - www
|- config/
    - mongoose.js
|- node_modules/
- .dockerignore
- .env
- .env.development
- .gitignore
- app.js
- Dockerfile
- LICENSE
- package.json
- package.lock.json
- README.md

Project structure details

  • app :- This app/ directory contains the main REST application functionality.
  • app/controllers :- These are controller files to validate the inputs from the user to control the flow of the project.
  • app/models :- This directory contains the data schema for all the collections used in the project.
  • app/routes :- This directory conatains all the routes and there workflow that are maintained for the project.
  • app/utils :- This directory contains the helper files for the project. This is made to maintain the uniform error and response structure throughout the project.
  • bin :- The bin/ directory serves as a location where you can define your various startup scripts. The www is an example to start the express app as a web server.
  • config :- The config/ folder contains the middleware file which are needed to setup before the application start.
  • node_modules :- The node_modules/ folder will be created when you will run the package installation command for the project. This will contain the dependencies modules that are used in the project.
  • .env :- This file is the environment variable file that is needed to be created by you by refering the .env.development file.
  • .env.development :- This file is the .env file schema that you need to follow while creating .env file.
  • .gitignore :- This file is used to ignore the files which are not to be pushed while creating commit at github.
  • app.js :- This is the main server file which do various middleware calls as per the request sent to the server.
  • LICENSE :- This file contains the MIT License for the project.
  • package.json :- It holds metadata relevant to the project and it is used for managing the project's dependencies, scripts, version and a whole lot more.
  • package.lock.json :- The package-lock.json sets your currently installed version of each package in stone, and npm will use those exact versions when running npm install.
  • README.md :- This file contains the documentation for the project.
  • app/controllers/tickets.js :- This is controller file to validate the inputs from the user to control the flow of the project for tickets.
  • app/controllers/users.js :- This is controller file to validate the inputs from the user to control the flow of the project for users.
  • app/models/tickets.js :- This is collection schema for the tickets.
  • app/models/users.js :- This is collection schema for the users.
  • app/routes/tickets.js :- This is route that will contain all the endpoint for /tickets route.
  • app/routes/users.js :- This is route that will contain all the endpoint for /users route.
  • app/utils/error_handler.js :- These is helper file that defines the schema of the response in case of any error.
  • app/utils/response_handler.js :- These is helper file that defines the schema of the response in case of no error occurs.
  • app/utils/status_handler.js :- These is helper file that will defines the standard status messages for the stattus codes.
  • config/mongoose.js :- These is middleware that will run before the the server start to connect the mongodb databse to the server.

Important Points

  • Refresh token is used to get new token with which user can have access to the data once he logs in and has valid token and refresh token.
  • Only Admin can create a new show.
  • Tickets get expired automatically after 8 hours of show start time using cron jobs which runs in every 30 minutes.
  • Users can update delete the token.
  • If user does not have non of the refresh token and token the user will need to login again.
  • User can see the ticket details using ticket id.
  • User can see all the ticket for the show.

Api Documentation

Method API Header Request Response
POST /users/signup {
    "Content-type":"application/json",
    "Access-Control-Allow-Origin":"*",
}
{
    "name":String,
    "phoneNumber":String,
    "password":String
}
{
    "status":201,
    "statusMessage":"Created",
    "message":"User created successfully",
    "data":{
        "token":String,
        "refreshToken":String,
    }
}
POST /users/login {
    "Content-type":"application/json",
    "Access-Control-Allow-Origin":"*",
    "token":String,
    "refreshtoken":String
}
{
    "phoneNumber":String,
    "password":String
}
{
    "status":200,
    "statusMessage":"Ok",
    "message":"Loged in successfully",
    "data":{
        "phoneNumber":String,
        "name":String,
        "token":String,
        "refreshToken":String,
    }
}
POST /shows/create {
    "Content-type":"application/json",
    "Access-Control-Allow-Origin":"*",
    "token":String,
    "refreshtoken":String
}
{
    "date":Date,
    "hallNumber":Number

}
{
    "status":200,
    "statusMessage":"Ok",
    "message":"Loged in successfully",
    "data":{[
        "showNumber":Number,
        "hallNumber":Number,
        "timing":Date,
    ]}
}
POST /tickets/create {
    "Content-type":"application/json",
    "Access-Control-Allow-Origin":"*",
    "token":String,
    "refreshtoken":String
}
{
    "name":String
    "phoneNumber":String
    "date":{
        "day":Number,
        "month":Number,
        "year":Number,
        "hours":Number,
        "minutes":Number
    }
    "people":Number
    "hallNumber":Number
    "showNumber":Number

}
{
    "status":200,
    "statusMessage":"Ok",
    "message":"Loged in successfully",
    "data":{[
        "hallNumber":Number,
        "showNumber":Number,
        "timing":Date,
        "people":Number
    ]}
}
PATCH /tickets {
    "Content-type":"application/json",
    "Access-Control-Allow-Origin":"*",
    "token":String,
    "refreshtoken":String
}
{
    "ticketId":Number
    "phoneNumber":String
    "date":{
        "day":Number,
        "month":Number,
        "year":Number,
        "hours":Number,
        "minutes":Number
    }
    "people":Number
    "hallNumber":Number
    "showNumber":Number

}
{
    "status":200,
    "statusMessage":"Ok",
    "message":"Loged in successfully",
    "data":{[
        "hallNumber":Number,
        "timing":Date,
        "people":Number,
    ]}
}
DELETE /tickets {
    "Content-type":"application/json",
    "Access-Control-Allow-Origin":"*",
    "token":String,
    "refreshtoken":String
}
{
    "ticketId":Number
    "phoneNumber":String
}
{
    "status":200,
    "statusMessage":"Ok",
    "message":"Loged in successfully",
    "data":{[
        "hallNumber":Number,
        "timing":Date,
        "people":Number,
    ]}
}
GET /tickets {
    "Content-type":"application/json",
    "Access-Control-Allow-Origin":"*",
    "token":String,
    "refreshtoken":String
}
{
    "ticketId":Number
}
{
    "status":200,
    "statusMessage":"Ok",
    "message":"Loged in successfully",
    "data":{[
        "hallNumber":Number,
        "timing":Date,
        "people":Number,
    ]}
}

API Screenshots

1. Create Ticket

Create ticket

2. Update Ticket update link

3. Get all tickets of a show get all show images

4. Get ticket by id get all show images

5. Create show get all show images

6. Get upcomming Shows get all show images

About

Ticketing System is a movie theater based ticket management system created for Zomentum placement hiering assignment.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published