FilmFlare is a RESTful API designed for managing a movie catalog, offering advanced search features and complete catalog management. The API supports adding, updating, removing, and searching for movies, and is designed for high performance and scalability. Built with Node.js and using DynamoDB for data storage, Elasticsearch for advanced search, and Redis for caching, FilmFlare ensures a fast and reliable user experience. The application is containerized with Docker and orchestrated using Kubernetes to handle high demand with ease.
- Complete Movie Management: Enables adding, updating, removing, and listing movies from the catalog.
- Advanced Search: Provides fast and efficient catalog searches using Elasticsearch, with support for filters like title, genre, and release year.
- Scalability and Resilience: Built using Docker and Kubernetes, the system supports caching and distributed databases, ensuring high availability and scalability as demand increases.
- Optimized Performance: Utilizes Redis as a caching layer to reduce latency and improve performance for frequent searches.
- Separation of Concerns: Follows the Hexagonal Architecture pattern to ensure that the core business logic is decoupled from external services, promoting maintainability and scalability.
- The primary platform used for implementing the API.
- A framework used for routing and middleware management, simplifying the creation of RESTful endpoints.
- A highly available NoSQL distributed database used for storing movie data.
- A search engine that enables full-text search and complex queries on the movie catalog, providing fast and advanced search capabilities.
- An in-memory caching system used to improve response times for frequent operations and reduce the load on DynamoDB and Elasticsearch.
- Used to containerize the application and its services, ensuring consistency across different environments.
- A container orchestration platform that handles scaling and ensures high availability by automatically managing container replicas.
- A library for interacting with AWS services such as DynamoDB and other AWS resources.
- Can be used for user authentication and authorization, ensuring that only authenticated users can perform certain actions like adding, updating, or removing movies.
FilmFlare follows the Hexagonal Architecture pattern, separating the business logic from external services like databases, caches, and search engines. This ensures that the core logic is adaptable and easily maintainable.
-
Domain Layer (Core): Contains business logic and domain entities.
- Example: The Movie entity representing a movie in the system and the services operating on it.
-
Ports and Adapters (External Interfaces):
- Ports: REST endpoints allowing users to interact with the system (e.g., GET /movies, POST /movies).
- Adapters: Interfaces to external services such as DynamoDB, Elasticsearch, and Redis.
-
Application Layer (Use Cases): Coordinates the execution of operations.
- Example: Use cases like
AddMovie
,GetMovies
,UpdateMovie
define the operations that interact with the domain.
- Example: Use cases like
-
Infrastructure Layer: Implements external interfaces like databases and search engines.
- Example: Connects to DynamoDB for persistence, Elasticsearch for search, and Redis for caching.
- The client sends a
POST /movies
request with movie data. - The request is received by the
MovieController
, triggering theAddMovie
use case. - The movie is stored in DynamoDB.
- After saving, the movie is indexed in Elasticsearch for fast searches.
- Redis invalidates the movie cache to ensure fresh data is served in future requests.
- The client sends a
GET /movies
request with filters (title, genre, release year). - The
MovieController
calls theGetMovies
use case, which checks if the result is cached in Redis. - If cached, the result is returned; otherwise, Elasticsearch is queried.
- The search result is then cached in Redis to improve performance for future searches.
- The client sends a
PUT /movies/:id
request with updated movie data. - The
MovieController
triggers theUpdateMovie
use case, which updates the movie in both DynamoDB and Elasticsearch. - The relevant cache in Redis is invalidated to ensure fresh data is returned in future searches.
- The client sends a
DELETE /movies/:id
request to remove a movie. - The
MovieController
triggers theDeleteMovie
use case, removing the movie from both DynamoDB and Elasticsearch. - The relevant cache in Redis is invalidated to reflect the removal.
FilmFlare is containerized using Docker, allowing the API and its auxiliary services (Redis, Elasticsearch) to be easily distributed and managed. Docker Compose is used during local development to orchestrate the application and its dependencies.
In production, Kubernetes is used to manage the FilmFlare API. It automatically scales the number of API replicas based on demand, ensuring high availability. Kubernetes manifest files handle:
- Deployment: Defines the number of API replicas and how they are distributed across the cluster.
- Service: Provides a stable interface to access the API containers.
- Ingress: Manages external access to the API, routing requests to the appropriate services.
git clone https://github.com/yourusername/filmflare.git
cd filmflare
Create a .env
file based on the provided env.example
file:
cp .env.example .env
Edit the .env
file and add your own configurations for Redis, Elasticsearch, DynamoDB, and other services:
# Example .env configuration
REDIS_ADDRESS=your_localhost
DYNAMODB_REGION=us-east-1
ELASTICSEARCH_URL=your_localhost
Install dependencies:
npm install
Start the services (Redis, Elasticsearch, etc.) using Docker Compose:
docker-compose up --build
Run the application:
npm start