Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9de8cc0
template files - old project
aashutoshPanda May 19, 2023
004bfa1
SQL commands to be used in Sequelize
aashutoshPanda May 21, 2023
a9d6cc1
env update
aashutoshPanda May 24, 2023
1fce9ac
REM : redundant middlewares
aashutoshPanda May 24, 2023
ad59eee
UPDATE: packages
aashutoshPanda May 24, 2023
a93529e
ADD: controllers
aashutoshPanda May 24, 2023
b830de9
ADD: models
aashutoshPanda May 24, 2023
cdb9498
REM: old services
aashutoshPanda May 24, 2023
af82532
ADD: routes
aashutoshPanda May 24, 2023
bb9afde
EDIT: fix schema
aashutoshPanda May 24, 2023
f952768
Add: login and signup
aashutoshPanda May 24, 2023
f9a79e4
ADD: example query in readme
aashutoshPanda May 24, 2023
724330c
ADD: get shows for a cinema & day
aashutoshPanda May 24, 2023
bf79ba6
ADD: get available seats
aashutoshPanda May 24, 2023
795c6f1
ADD: ticket booking route with transaction
aashutoshPanda May 24, 2023
713a583
update readme
aashutoshPanda May 24, 2023
0d7baee
update readme
aashutoshPanda May 24, 2023
342e536
update readme
aashutoshPanda May 24, 2023
d174f45
Merge pull request #1 from aashutoshPanda/develop
aashutoshPanda May 24, 2023
0ac2ca8
update readme
aashutoshPanda May 24, 2023
ec27531
update readme
aashutoshPanda May 24, 2023
1e141fb
update readme
aashutoshPanda May 24, 2023
02d0022
update transaction
aashutoshPanda May 27, 2023
f85d856
Merge branch 'main' into develop
aashutoshPanda May 27, 2023
40af5cc
Add transaction & check for seat range
aashutoshPanda May 28, 2023
f14a8fa
Merge branch 'main' into develop
aashutoshPanda May 28, 2023
ac3e429
Merge pull request #2 from aashutoshPanda/develop
aashutoshPanda May 28, 2023
98ae096
Add comments about indexing
aashutoshPanda May 28, 2023
c42f7f3
typo fix
aashutoshPanda May 28, 2023
642eb5f
typo fix
aashutoshPanda May 28, 2023
5b6754e
added caching layer for static movie details
aashutoshPanda Jun 10, 2023
4bebef6
add elastic search endpoint for query
aashutoshPanda Jun 11, 2023
b79c64f
Add comments for a movie
aashutoshPanda Jun 11, 2023
21c84db
update schema leastic search and diagrams
aashutoshPanda Jun 11, 2023
b7bf923
update readme
aashutoshPanda Jun 11, 2023
70c842b
update readme
aashutoshPanda Jun 11, 2023
59ba22b
Merge branch 'main' into develop
aashutoshPanda Jun 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
DB_HOST='localhost'
DB_NAME='bookmyshow'
DB_USER_NAME='panda'
DB_PASSWORD=''

JWT_SECRET='secret'


REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_DEFAULT_TIMEOUT_SECONDS=60

ELASTIC_SEARCH_PORT=9200

MONGODB_URI=mongodb+srv://iamashutoshpanda:hGEvTJ8tHUa3Hxgd@cluster0.cgcoqnr.mongodb.net/?retryWrites=true&w=majority
NODE_ENV='UAT'
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,35 @@
# bookmyshow-api-nodejs-sql
This repository contains the code for a movie ticket booking API. The API allows users to select a theatre in the city and see the dates of the next 7 days. Users can then click on any date to see all the movies in that theatre on that given date. Movies are displayed with details of all the showtimes.

POSTMAN DOCS - [here](https://documenter.getpostman.com/view/7984450/2s93m5zgVx)

#### This is an API for booking movie tickets.

1. Get available movies for given - Cinema, Date
2. Check available seats for a show
3. Book tickets for a slot

![er-diagram](./readme-assets/er-diagram.png)

#### Which columns should be indexed?

It's important to note that adding indexes also comes with some overhead, as they consume additional storage space and require maintenance during data modification operations (such as inserts, updates, and deletes).
Hence we should add them only when a bottleneck is observed.

In this example indexing the foreign keys for Shows table would be good as this will speed up our joins.
Also if we want to prioritize them then indexing the HallId in Shows table should be prioritized as it is used more frequently than the rest.

### Checklist

- [x] JWT Auth
- [x] Normalization of database
- [x] Locking the DB while bulk operation with transactions
- [x] Elastic Search for querying movies with filters(language, genre and dimension like 3D, 4D etc..) and fuzzy search
- [x] Adding comments for a movie and retrieving with Mongo (for better write performance)
- [x] Caching of movie details endpoints with Redis



### Example Query for the UI below

![example-query](./readme-assets/example-query.png)
![bookmyshow-ui](./readme-assets/bookmyshow.jpeg)
26 changes: 26 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import dotenv from "dotenv";
dotenv.config({ path: ".env.example" });
import express from "express";
import routes from "./src/routes/index.js";
import connectDB from "./src/helpers/mongoose.js";
// Make all variables from our .env file available in our process

// Init express server
const app = express();

//rate limit
await connectDB();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

// Here we define the api routes
app.use(routes);

const port = process.env.PORT || 8080;
const address = process.env.SERVER_ADDRESS || "localhost";

app.get("/", (req, res) => res.send("Hello World!"));

app.listen(port, () => console.log(`Server running on http://${address}:${port}`));

export default app;
Loading