Odvin / cinema-network

Express + Mongoose = API Demo Service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Requirements

Implement HTTP API for the Cinema Network Project.

Data entry required:

  1. Cinemas (city, cinema name);
  2. Halls with reference to the cinema (name of the cinema hall, number of seats);
  3. Movies (name, year, duration);
  4. Sessions with reference to the hall;

API has to support:

  1. GET list of cinemas;
  2. GET list of the cinema halls;
  3. GET movie list;
  4. GET list of sessions that are added on a specific day;
    1. at the cinema;
    2. in the hall;

Implementation

Data storage model

ER-diagram

It is possible to denormalized entities: Cinema and Hall and merge them into one Mongo collection. But if two cinema company rents the same halls then the relation between Cinema and Hall will be many-to-many. That's why we keep normalization, it gives us flexibility and opportunity to migration to PostgreSQL, easy to create resolves with GraphQL schema.

API Routes

GET Requests

host/api/v1/cinema/list
host/api/v1/hall/list/{cinema_id}
host/api/v1/movie/list
host/api/v1/sessions/{day}/{month}/{year}/{cinema_id}
host/api/v1/sessions/{day}/{month}/{year}/{hall_id}

POST Requests

host/api/v1/cinema
host/api/v1/hall

DEV requirements

  1. Docker
  2. Docker-compose
  3. node

Install dependence

cd /service/api-server
mpm i

To start the project run in the root directory:

docker-compose up

To set up env params create file .env file in the root directory, see .env.config.

docker-compose is used during development and may run and connect several services. For deployment individual Docker file will be used for each service.

Seeding Database

To seed, the database, invoke the route.

host/api/v1/seed

The database will be cleaned and populated with predefined data. To get the list of cinemas use route

host/api/v1/cinema/list

About

Express + Mongoose = API Demo Service

License:MIT License


Languages

Language:JavaScript 100.0%