A Typescript implementation for a Lightweight Netflix API.
https://documenter.getpostman.com/view/8362406/UVXjLc7N#intro
- Docker Engine
- Docker Compose
- Navigate to the root directory of the project
lightweight-netflix
- Run the following command
docker-compose up --build
- Wait for the image to build and the API initializes
The project features Bob Martin's clean architecture ideology, by layering all the components that make the API into separate independent components. By eliminating the dependency on frameworks and databases, the code is testable, plugabble and open to feature updates.
This project fully implements the 5 SOLID Principles for clean code.
- Single Resposibility
- Open-closed
- Liskov Substitution
- Interface Segregation
- Dependency Inversion
That is obvious in every class and every file in the project, where each class performs only one function. Only worries about the input and the output.
This principle is more obvious in the Repository
abstract class, where other repositories can implement or extend it without breaking the rest of the components.
Example: This allows us to implement an in-memory repository for testing the application without needing a test database! which brings us to the next principle
We are able to provide a different implementation of the repository to the Interactors
without the interactors changing a single line of code. Which gives us room for expanding and testing
Example:
If we decide that the Movie
should be a different service, then a MovieAPIRepository
can be implemented and passed to the Interactor
and the interactor would still function normally without changing a single line of code, But the movies are now being fetched from a remote service rather than from the database.
By implementing the IoC (Inversion of Control) principle in the form of "Dependency Injection", every component of the application is extisible and open for changes without breaking the rest of the components.
For example:
Using Express as a web framework can be replaced by any other framework without any changes. Since the Controllers
depend on an abstract HttpRequest
Interface that allows any web framework to be plugged in without changing the controllers.
There are some enhancements that need to be done
- Move the user authorization logic to a middleware function rather than repeating the code in each interactor
- Implement a more efficient updated mechanism to update only the fields provided, rather than setting the whole movie
- Handle movie duplication logic. Maybe create a hash (movie name + movie year) and check if the hash exists in any of the movies.
- Proper logging