# gagan987123/movie-search architecture

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

- Interactive diagram: https://gitdiagram.com/gagan987123/movie-search
- Repository: https://github.com/gagan987123/movie-search

## Overview

##### Project type and purpose
- This is a monorepo hosting a full-stack “Movie Search” web application.
- The backend (Backend/) is a Node.js/Express API server with MVC-style controllers, JWT authentication, MongoDB persistence via Mongoose, and Swagger documentation.
- The frontend (movie-searcher-fav/) is a React single-page application (SPA) built with Vite, using context/hooks and Axios to call the backend.

##### File structure
- Top-level:
- Backend/ – all server-side code (app.js, controllers/, middleware/, models/, routes/, services/, swagger.yaml)
- movie-searcher-fav/ – React app (src/, public/, index.html, Vite config, ESLint)
- docs_Backend/ – auto-generated Markdown docs for each backend module
- .windsurf/ – documentation/workflow scripts (autodoc, confluence publisher)
- Backend sub-structure follows a clear MVC + service-layer pattern.
- React side uses a component/context/store structure, with a services/api.js wrapper for HTTP calls.

##### README for additional insights
- Purpose: register/login/logout, search TMDb for movies/TV shows, view details.
- Key tech: Express, JWT, MongoDB, Swagger JsDoc, React, Vite, Axios.
- External dependency: TMDb REST API.

##### Detail
- Routes: authRoutes, movieRoutes, tvRoutes
- Controllers: authController, movieController, tvController
- Middleware: authMiddleware
- Services: TMDb API wrapper
- Models: User, People
- On the frontend side, show Context Providers, key pages (Home, Search, Favorites, AuthScreen), and the services/api.js call path.
- JWT flow: login request → token issued → token stored in client context/localStorage → token sent on protected API calls → middleware verifies.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (React SPA)" 
        direction TB
        Browser["User Browser"]:::user
        ReactSPA["React SPA"]:::frontend
        subgraph "Entry & Root"
            direction TB
            MainEntry["main.jsx"]:::frontend
            RootComponent["App.jsx"]:::frontend
        end
        subgraph "Pages" 
            direction TB
            HomePage["HomePage.jsx"]:::frontend
            SearchPage["SearchPage.jsx"]:::frontend
            FavoritesPage["Favorites.jsx"]:::frontend
            AuthScreen["AuthScreen.jsx"]:::frontend
            LoginPage["Login.jsx"]:::frontend
            SignUpPage["SignUp.jsx"]:::frontend
            WatchPage["WatchPage.jsx"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            MovieCard["MovieCard.jsx"]:::frontend
            Navbar["Navbar.jsx"]:::frontend
            MovieSlider["MovieSlider.jsx"]:::frontend
        end
        subgraph "State & Hooks"
            direction TB
            MovieContext["MovieContext.jsx"]:::frontend
            ContentStore["ContentStore.js"]:::frontend
            AuthStore["authUser.js"]:::frontend
            UseGetTrending["useGetTrendingContent.jsx"]:::frontend
        end
        subgraph "HTTP Service"
            direction TB
            APIService["api.js"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (Express API Server)" 
        direction TB
        AppEntry["app.js"]:::backend
        subgraph "Routes"
            direction TB
            AuthRoutes["authRoutes.js"]:::backend
            MovieRoutes["movieRoutes.js"]:::backend
            TVRoutes["tvRoutes.js"]:::backend
        end
        subgraph "Controllers"
            direction TB
            AuthController["authController.js"]:::backend
            MovieController["movieController.js"]:::backend
            TVController["tvController.js"]:::backend
        end
        subgraph "Middleware"
            direction TB
            AuthMiddleware["authMiddleware.js"]:::backend
        end
        subgraph "Services"
            direction TB
            TMDbService["services/api.js"]:::backend
        end
        subgraph "Models"
            direction TB
            UserModel["User.js"]:::backend
            PeopleModel["people.js"]:::backend
        end
        subgraph "API Docs"
            direction TB
            SwaggerSetup["swagger.js"]:::backend
            SwaggerSpec["swagger.yaml"]:::backend
        end
    end

    %% Data Stores and External
    MongoDB[(MongoDB)]:::database
    TMDB[(TMDb API)]:::external

    %% Flows
    Browser -->|interacts with| ReactSPA
    ReactSPA -->|uses Axios| APIService
    APIService -->|HTTPS JSON| AppEntry
    AppEntry -->|routes to| AuthRoutes
    AppEntry -->|routes to| MovieRoutes
    AppEntry -->|routes to| TVRoutes
    AuthRoutes -->|calls| AuthController
    MovieRoutes -->|calls| MovieController
    TVRoutes -->|calls| TVController
    AuthController -->|uses| AuthMiddleware
    AuthController -->|uses| TMDbService
    MovieController -->|uses| TMDbService
    TVController -->|uses| TMDbService
    AuthController -->|queries| UserModel
    MovieController -->|queries| PeopleModel
    AuthController -->|queries| MongoDB
    TMDbService -->|fetches data| TMDB
    AuthMiddleware -->|verifies JWT| AuthController
    AppEntry -->|serves| SwaggerSetup
    SwaggerSetup -->|reads| SwaggerSpec
    AppEntry -->|connects to| MongoDB

    %% Click Events Frontend
    click ReactSPA "https://github.com/gagan987123/movie-search/tree/main/movie-searcher-fav/"
    click MainEntry "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/main.jsx"
    click RootComponent "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/App.jsx"
    click HomePage "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/pages/HomePage.jsx"
    click SearchPage "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/pages/SearchPage.jsx"
    click FavoritesPage "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/pages/Favorites.jsx"
    click AuthScreen "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/pages/AuthScreen.jsx"
    click LoginPage "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/pages/Login.jsx"
    click SignUpPage "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/pages/SignUp.jsx"
    click WatchPage "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/pages/WatchPage.jsx"
    click MovieCard "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/components/MovieCard.jsx"
    click Navbar "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/components/Navbar.jsx"
    click MovieSlider "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/components/MovieSlider.jsx"
    click MovieContext "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/context/MovieContext.jsx"
    click ContentStore "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/store/ContentStore.js"
    click AuthStore "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/store/authUser.js"
    click UseGetTrending "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/hooks/useGetTrendingContent.jsx"
    click APIService "https://github.com/gagan987123/movie-search/blob/main/movie-searcher-fav/src/services/api.js"

    %% Click Events Backend
    click AppEntry "https://github.com/gagan987123/movie-search/blob/main/Backend/app.js"
    click AuthRoutes "https://github.com/gagan987123/movie-search/blob/main/Backend/routes/authRoutes.js"
    click MovieRoutes "https://github.com/gagan987123/movie-search/blob/main/Backend/routes/movieRoutes.js"
    click TVRoutes "https://github.com/gagan987123/movie-search/blob/main/Backend/routes/tvRoutes.js"
    click AuthController "https://github.com/gagan987123/movie-search/blob/main/Backend/controller/authConotroller.js"
    click MovieController "https://github.com/gagan987123/movie-search/blob/main/Backend/controller/movieController.js"
    click TVController "https://github.com/gagan987123/movie-search/blob/main/Backend/controller/tvController.js"
    click AuthMiddleware "https://github.com/gagan987123/movie-search/blob/main/Backend/middleware/authMiddleware.js"
    click TMDbService "https://github.com/gagan987123/movie-search/blob/main/Backend/services/api.js"
    click UserModel "https://github.com/gagan987123/movie-search/blob/main/Backend/models/User.js"
    click PeopleModel "https://github.com/gagan987123/movie-search/blob/main/Backend/models/people.js"
    click SwaggerSetup "https://github.com/gagan987123/movie-search/blob/main/Backend/swagger.js"
    click SwaggerSpec "https://github.com/gagan987123/movie-search/blob/main/Backend/swagger.yaml"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#3675A0,stroke-width:1px
    classDef backend fill:#DFFFE0,stroke:#278A0D,stroke-width:1px
    classDef database fill:#FFE4B5,stroke:#C47A00,stroke-width:1px
    classDef external fill:#EEEEEE,stroke:#888888,stroke-width:1px
    classDef user fill:#FFF0F0,stroke:#A00000,stroke-width:1px
```
