# shashishekhar-m/ai-movie-recommender architecture

> Architecture diagram of the GitHub repository shashishekhar-m/ai-movie-recommender, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shashishekhar-m/ai-movie-recommender
- Repository: https://github.com/shashishekhar-m/ai-movie-recommender

## Overview

##### Project type and purpose
- This is a full-stack web application:
- Frontend: delivers a modern, interactive UI for browsing and filtering movie recommendations.
- Backend: a Python/Flask service exposing REST endpoints, handling NLP search, “Surprise Me,” and querying a MySQL database.
- Data: IMDb datasets stored in MySQL, filtered by genre, language, year, duration.

##### File structure
- Original (static) layout:
- app.py & db_config.py → Flask app + DB connection
- index.html, script.js, style.css → static frontend
- If using Next.js instead of static files, you would replace index.html, script.js, style.css with a Next.js project structure:
- pages/ → React/SSR routes (e.g., pages/index.js, pages/api/*)
- components/ → UI components
- public/ → static assets (CSS, images)
- next.config.js, package.json → build & deployment config

##### README for additional insights
- The system filters IMDb data by multiple criteria and offers NLP-based search.
- Key features: “Surprise Me” (randomized recommendation), modern UI for engagement.

a. Main components
- Next.js Frontend (React, SSR/CSR)
- Flask API Server (Python, Flask)
- MySQL Database (IMDb data)
- Optional: External IMDb data source (if data ingested dynamically)
b. Relationships & interactions
- User → Next.js Frontend (HTTP/HTTPS)
- Next.js → Flask API (REST calls)
- Flask API → MySQL (SQL queries)
- Flask NLP modules → process query inputs
- “Surprise Me” routine → random selection logic in Flask
c. Architectural patterns & design principles
- Separation of concerns: frontend UI vs. backend logic
- API-driven architecture: frontend consumes RESTful endpoints
- SSR/CSR hybrid (Next.js): SEO & performance
- Modularization: distinct layers for routing, business logic, data access
d. Relevant technologies
- Next.js (React, SSR, API routes)
- Flask (WSGI server, Blueprints for routes)
- MySQL (InnoDB tables for movies)
- Python NLP libraries (e.g., NLTK or spaCy)
- Docker or CI/CD scripts (if present)

##### Essential elements
- Layers: UI, API, business logic, data store
- Functional grouping: filtering module, search module, randomizer
- Keep it readable: group related components, avoid over-cluttering

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["User Browser"]:::client
    subgraph "Next.js Frontend"
        Pages["Pages (pages/)"]:::frontend
        Components["UI Components (components/)"]:::frontend
        APIRoutes["API Routes (pages/api/)"]:::frontend
    end
    subgraph "Flask Backend"
        Controllers["Routes & Controllers"]:::backend
        NLPLogic["NLP Logic & Surprise Me"]:::backend
        DBAccess["DB Access Layer"]:::backend
        DBConfig["Database Config"]:::backend
    end
    MySQL[(MySQL Database)]:::db
    Importer["IMDb Data Importer"]:::external

    Browser -->|"HTTP/HTTPS"| Pages
    Browser -->|"Client-side Navigation"| Components
    Pages -->|"SSR/CSR API Calls"| APIRoutes
    APIRoutes -->|"REST Calls"| Controllers
    Controllers -->|"Invoke NLP"| NLPLogic
    Controllers -->|"Query Data"| DBAccess
    DBAccess -->|"Connect"| MySQL
    DBConfig -->|"Config Details"| DBAccess
    Importer -.->|"Data Ingestion"| MySQL

    click Controllers "https://github.com/shashishekhar-m/ai-movie-recommender/blob/main/app.py"
    click DBConfig "https://github.com/shashishekhar-m/ai-movie-recommender/blob/main/db_config.py"
    click Pages "https://github.com/shashishekhar-m/ai-movie-recommender/blob/main/index.html"
    click Components "https://github.com/shashishekhar-m/ai-movie-recommender/blob/main/script.js"
    click APIRoutes "https://github.com/shashishekhar-m/ai-movie-recommender/blob/main/style.css"
    click README "https://github.com/shashishekhar-m/ai-movie-recommender/blob/main/README.md"

    classDef frontend fill:#D0E8FF,stroke:#0275d8;
    classDef backend fill:#DFF0D8,stroke:#5cb85c;
    classDef db fill:#FCF8E3,stroke:#F0AD4E;
    classDef external fill:#F5F5F5,stroke:#CCCCCC;
    classDef client fill:#E8E8E8,stroke:#999999;
    classDef doc fill:#F2DEDE,stroke:#D9534F;
    classDef dashed stroke-dasharray: 5 5;
```
