# kshitij-git24/moviemaster-ott architecture

> Architecture diagram of the GitHub repository kshitij-git24/moviemaster-ott, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kshitij-git24/moviemaster-ott
- Repository: https://github.com/kshitij-git24/moviemaster-ott

## Overview

##### Project Type & Purpose
- The project is a full-stack application that hosts movies by genre and provides enhanced user interactivity through features like commenting, chatrooms, and personalized movie recommendations.
- It integrates multiple technologies: a React-based frontend for the UI, an Express backend (with Firebase authentication and Redis caching), and a Flask-based recommender engine for delivering genre and movie-based recommendations.

##### Analyzing the File Structure
- There are three top-level directories/servers:
– Flask-server: Contains Python code with a machine learning recommender engine. Key files include app.py, recommender.csv, Data_Preprocessing.ipynb, and requirements.txt.
– Express-server: This serves as the backend REST API and integrates with Firebase (for authentication), Redis (for caching TMDB API responses) and routes for functionalities such as comments, likes/dislikes, profile page, and recommendations.
▸ The Express-server directory includes configuration files (in the Config folder), core application logic (app.js), data abstraction modules in the data subfolder, Firebase integration logic, and route definitions.
– React-server: Contains a React single-page application. It is responsible for rendering the user interface (movie details, chatroom, comments, and other interactive features) as well as handling client-side routing and state management.
- Each server has its respective dependency files (package.json for Node servers and requirements.txt for Flask) and configuration files (e.g., .env for react-server, settings.json for Express).

a. Main Components:
- Frontend Component (React-server): This is the client-facing single-page application. Key parts include pages/components for Home, MovieDetails, Comments, Login/Registration, Profile, and real-time chatrooms.
- API Gateway / Backend (Express-server): Acts as the central hub handling user requests by:
▸ Authenticating users via Firebase.
▸ Managing session-based activities and route handling for comments, likes, profiles, etc.
▸ Interfacing with external movie information services (such as TMDB) and caching responses in Redis.
▸ Forwarding recommendation requests to the Flask server.
- Recommendation Engine (Flask-server): Implements a content-based recommender system that processes movie data (from movies.csv/recommender.csv) and provides personalized recommendations.
b. External Services & Libraries:
- Firebase: Used for secure user authentication (login/signup including Google and Facebook).
- Redis: Used in the Express server for caching movie data to reduce repeated calls to external APIs.
- Socket.io (mentioned in README): For enabling real-time chat capabilities in the movie-specific chatrooms.
- Third-party movie databases (TMDB): To fetch movie details when not already cached.
c. Relationships and Data Flow:
- Users interact with the React frontend.
- The React app communicates with the Express backend via REST API endpoints.
- The Express server validates requests, handles business logic (comments, likes, profiles), and if recommendations are needed, it forwards queries to the Flask recommender engine.
- The Flask server processes the recommendation logic and returns results in JSON format to the Express server.
- The Express server then may further enrich the data (using Redis/TMDB integration) before returning the consolidated results to the frontend.
- Real-time interactions (chatrooms) are enabled via Socket.io, with bidirectional communication between the client and server.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Flask Recommendation Engine
    subgraph "Flask Recommendation Engine"
        FAPI["Recommendation API Endpoints"]:::ml
        FDS["Data Sources (movies.csv,recommender.csv)"]:::ml
        FSP["Supporting Files"]:::ml
        FAPI -->|"uses"| FDS
        FAPI -->|"relies_on"| FSP
    end

    %% Express API Gateway / Backend
    subgraph "Express API Gateway / Backend"
        EMain["Express API Gateway"]:::backend
        EConfig["Configuration"]:::backend
        EData["Data Abstraction"]:::backend
        ERoutes["Route Definitions"]:::backend
        EFirebase["Firebase Integration"]:::backend
        EMain -->|"includes"| EConfig
        EMain -->|"includes"| EData
        EMain -->|"includes"| ERoutes
        EMain -->|"integrates"| EFirebase
    end

    %% React Frontend
    subgraph "React Frontend"
        RMain["React Frontend"]:::frontend
        RComponents["UI Components & Pages"]:::frontend
        RMain -->|"contains"| RComponents
    end

    %% External Services
    subgraph "External Services"
        Firebase["Firebase Auth"]:::external
        Redis["Redis Cache"]:::external
        TMDB["TMDB API"]:::external
        SocketIO["Socket.io"]:::external
    end

    %% Data Flow Arrows
    RMain -->|"API_calls"| EMain
    EMain -->|"Recommendation_Request"| FAPI
    FAPI -->|"Recommendation_Response"| EMain
    EMain -->|"API_Response"| RMain
    EMain -->|"Firebase_Auth"| Firebase
    EMain -->|"Cache_Redis"| Redis
    EMain -->|"Fetch_TMDB"| TMDB
    RMain <-->|"Socket.io_Communication"| EMain

    %% Click Events
    click FAPI "https://github.com/kshitij-git24/moviemaster-ott/blob/main/flask-server/app.py"
    click FSP "https://github.com/kshitij-git24/moviemaster-ott/tree/main/flask-server"
    click EMain "https://github.com/kshitij-git24/moviemaster-ott/blob/main/Express-server/app.js"
    click EConfig "https://github.com/kshitij-git24/moviemaster-ott/tree/main/Express-server/Config"
    click EData "https://github.com/kshitij-git24/moviemaster-ott/tree/main/Express-server/data"
    click ERoutes "https://github.com/kshitij-git24/moviemaster-ott/tree/main/Express-server/routes"
    click EFirebase "https://github.com/kshitij-git24/moviemaster-ott/tree/main/Express-server/firebase"
    click RMain "https://github.com/kshitij-git24/moviemaster-ott/tree/main/react-server"
    click RComponents "https://github.com/kshitij-git24/moviemaster-ott/tree/main/react-server/src"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef backend fill:#FAD7A0,stroke:#333,stroke-width:2px;
    classDef ml fill:#ABEBC6,stroke:#333,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#333,stroke-width:2px;
```
