# mohit9339/yourmoviebuddy architecture

> Architecture diagram of the GitHub repository mohit9339/yourmoviebuddy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohit9339/yourmoviebuddy
- Repository: https://github.com/mohit9339/yourmoviebuddy

## Overview

##### Project type and purpose
- From the file tree and README, “YourMovieBuddy” is a full-stack movie discovery and list-management web application.
- The frontend is delivered as static HTML/CSS/JS (under public/) and built with Tailwind via Vite.
- The backend is a Node.js/Express server (backend/), with user management, session handling, and a small scraper for IMDb ratings.
- Data is persisted in MongoDB Atlas; some sample JSON (top_movies.json, directors.json) live under public/data.

##### File structure
Top-level:
- README.md, vite.config.js, package.json (root)
- backend/
– server.js (Express setup, API routes, static-file serving)
– imdbScraper.js (external IMDb scraping module)
– models/user.js (Mongoose schema or similar)
– .env (DB credentials, secret keys)
– users.json (fallback or seed data)
- public/
– HTML views (index.html, login.html, dashboard.html, …)
– CSS (style.css)
– JS controllers (auth.js, search.js, dashboard.js, etc.)
– data (top_movies.json, other static data)

##### README for additional insights
- Confirms use of MongoDB Atlas, Tailwind CSS, session-based auth (Signup & Login).
- Core features: search by title, filter by genre/language/director, personal lists (Favorites/Watched), director filmographies, IMDb ratings.

##### Main components & their relationships
a. Frontend (Client Browser)
- Static assets (HTML/CSS/JS) served by Vite/Express
- UI built with Tailwind, vanilla JS modules under public/js
- Invokes RESTful endpoints (XHR/fetch calls) to backend
b. Backend (Node.js + Express)
- Serves static files + API routes (/api/auth, /api/movies, /api/user, …)
- Orchestrates business logic: authentication, list management, movie lookups
- Uses imdbScraper.js to fetch external rating data from IMDb
c. Database (MongoDB Atlas)
- Stores User documents (credentials, Favorites, Watched lists)
- Potentially caches movie metadata or sessions
d. External Service (IMDb)
- Accessed via imdbScraper for live ratings
e. (Optional) Static JSON Data
- public/data/top_movies.json for client-side “most popular” list

Interactions:
Client → HTTP(S) → Backend API
Backend → MongoDB Atlas (via Mongoose or Mongo client)
Backend → imdbScraper → external IMDb pages
Backend → Client (serves HTML, assets & JSON responses)

##### Architectural patterns & design principles
- MVC-inspired separation:
- Models (backend/models)
- Controllers/Routes (server.js)
- Views (public/*.html) + client-side JS (public/js)
- RESTful HTTP API between frontend and backend
- Single-page-app-style modular JS, but delivered as multiple HTML entry points
- External integration layer (imdbScraper) decoupled from core business logic
- Environment configuration via .env

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser Container
    subgraph "Client Browser"
        direction TB
        subgraph "HTML Views"
            direction TB
            v1["index.html"]
            v2["login.html"]
            v3["signup.html"]
            v4["dashboard.html"]
            v5["search.html"]
            v6["movie.html"]
            v7["directors.html"]
            v8["director_info.html"]
            v9["genre.html"]
            v10["language.html"]
            v11["profile.html"]
        end
        subgraph "CSS Styles"
            css["style.css"]
        end
        subgraph "JS Modules"
            js1["home.js"]
            js2["auth.js"]
            js3["logout.js"]
            js4["search.js"]
            js5["movie.js"]
            js6["directors.js"]
            js7["director_info.js"]
            js8["genre.js"]
            js9["language.js"]
            js10["dashboard.js"]
            js11["profile.js"]
            js12["protect.js"]
        end
        subgraph "Static JSON Data"
            data["top_movies.json"]
        end
    end

    %% Web Server Container
    subgraph "Web Server (Express)"
        direction TB
        server["server.js"]:::server
        scraper["imdbScraper.js"]:::service
        userModel["models/user.js"]:::model
        env[".env"]:::config
        usersSeed["users.json"]:::datafile
    end

    %% Database and External
    db[(MongoDB Atlas)]:::database
    external("IMDb External Service"):::external

    %% Relationships
    v1 -->|"HTTP GET HTML"| server
    v2 -->|"HTTP GET HTML"| server
    v3 -->|"HTTP GET HTML"| server
    v4 -->|"HTTP GET HTML"| server
    css -->|"HTTP GET CSS"| server
    js2 -->|"POST /api/auth/login (JSON)"| server
    js4 -->|"GET /api/movies/search (JSON)"| server
    js10 -->|"GET /api/user/lists (JSON)"| server
    data -->|"HTTP GET JSON"| server
    server -->|"MongoDB Driver (JSON)"| db
    server -->|"HTTP Scrape (HTML)"| external

    %% Click Events
    click v1 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/index.html"
    click v2 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/login.html"
    click v3 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/signup.html"
    click v4 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/dashboard.html"
    click v5 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/search.html"
    click v6 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/movie.html"
    click v7 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/directors.html"
    click v8 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/director_info.html"
    click v9 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/genre.html"
    click v10 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/language.html"
    click v11 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/profile.html"
    click css "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/css/style.css"
    click js1 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/home.js"
    click js2 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/auth.js"
    click js3 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/logout.js"
    click js4 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/search.js"
    click js5 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/movie.js"
    click js6 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/directors.js"
    click js7 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/director_info.js"
    click js8 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/genre.js"
    click js9 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/language.js"
    click js10 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/dashboard.js"
    click js11 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/profile.js"
    click js12 "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/js/protect.js"
    click data "https://github.com/mohit9339/yourmoviebuddy/blob/main/public/data/top_movies.json"
    click server "https://github.com/mohit9339/yourmoviebuddy/blob/main/backend/server.js"
    click scraper "https://github.com/mohit9339/yourmoviebuddy/blob/main/backend/imdbScraper.js"
    click userModel "https://github.com/mohit9339/yourmoviebuddy/blob/main/backend/models/user.js"
    click env "https://github.com/mohit9339/yourmoviebuddy/blob/main/backend/.env"
    click usersSeed "https://github.com/mohit9339/yourmoviebuddy/blob/main/backend/users.json"

    %% Styles
    classDef client fill:#D6E9FF,stroke:#2B7CE9,color:#000
    classDef server fill:#DFFFE0,stroke:#2EB82E,color:#000
    classDef service fill:#FFEFD6,stroke:#E68A00,color:#000
    classDef model fill:#F0F0F0,stroke:#999999,color:#000
    classDef config fill:#F9D6FF,stroke:#D02B8E,color:#000
    classDef datafile fill:#FFF8D6,stroke:#E6C200,color:#000
    classDef database fill:#FFF0D6,stroke:#E68A00,color:#000,stroke-width:2px
    classDef external fill:#F5F5F5,stroke-dasharray: 5 5,stroke:#888888,color:#000
    class v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,css,js1,js2,js3,js4,js5,js6,js7,js8,js9,js10,js11,js12,data client
    class server server
    class scraper service
    class userModel model
    class env config
    class usersSeed datafile
    class db database
    class external external
```
