# jaewonhimnae/react-tmdb-app architecture

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

- Interactive diagram: https://gitdiagram.com/jaewonhimnae/react-tmdb-app
- Repository: https://github.com/jaewonhimnae/react-tmdb-app

## Overview

##### Project type and purpose
- This is a classic full-stack MERN-style web application.
- Frontend: React SPA (with Redux for state management).
- Backend: Node/Express API server.
- Database: MongoDB (via Mongoose).
- External service: The Movie Database (TMDB) API for movie metadata.
- Purpose: Browse, like/dislike, favorite videos; leave comments; user auth/registration.

##### File structure
- Top-level:
- client/ – React app (“public”, “src” with actions, reducers, components, HOC auth).
- server/ – Express app (config, middleware, models, routes).
- Patterns:
- Client uses Redux (/_actions, /_reducers).
- Server uses MVC-style separation: routes → controllers (implicitly in route handlers) → Mongoose models.
- Auth middleware (JWT based) guards protected routes.
- Proxy setup (client/src/setupProxy.js) routes /api calls to server.

##### Key insights from README
- Environment config: server/config/dev.js for MongoDB URI and secret keys.
- Build steps: install in root (server) & client.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Browser)"
        direction TB
        UI["React SPA (UI Layer)"]:::frontend
        Store["Redux Store\n(Actions & Reducers)"]:::frontend
        AuthHOC["Auth HOC"]:::frontend
        SW["Service Worker"]:::frontend
        Manifest["Web App Manifest"]:::frontend
        Proxy["Dev Proxy"]:::frontend
    end

    %% Backend Layer
    subgraph "Express API Server"
        direction TB
        Entry["Server Entry\n(server/index.js)"]:::backend
        Config["Server Config\n(key.js & prod.js)"]:::backend
        AuthMW["Auth Middleware"]:::backend
        subgraph "API Routes"
            direction TB
            Users["Users Route"]:::backend
            Comments["Comments Route"]:::backend
            Likes["Likes Route"]:::backend
            Dislikes["Dislikes Route"]:::backend
            Favorites["Favorites Route"]:::backend
        end
        subgraph "Mongoose Models"
            direction TB
            MUser["User Model"]:::backend
            MVideo["Video Model"]:::backend
            MComment["Comment Model"]:::backend
            MLike["Like Model"]:::backend
            MDislike["Dislike Model"]:::backend
            MFavorite["Favorite Model"]:::backend
        end
    end

    %% Database
    MongoDB["MongoDB Cluster"]:::database

    %% External Service
    TMDB["TMDB REST API"]:::external

    %% Interactions
    UI -->|"dispatch actions"| Store
    UI -->|"HTTP /api/*"| Proxy
    Store -->|"subscribe/dispatch"| UI

    Proxy -->|"forwards HTTP"| Entry
    Entry -->|"/api/*"| Users
    Entry -->|"/api/*"| Comments
    Entry -->|"/api/*"| Likes
    Entry -->|"/api/*"| Dislikes
    Entry -->|"/api/*"| Favorites

    Users -->|uses| AuthMW
    Comments -->|uses| AuthMW
    Likes -->|uses| AuthMW
    Dislikes -->|uses| AuthMW
    Favorites -->|uses| AuthMW

    Users -->|CRUD| MUser
    Comments -->|CRUD| MComment
    Likes -->|CRUD| MLike
    Dislikes -->|CRUD| MDislike
    Favorites -->|CRUD| MFavorite

    Users -->|DB ops| MongoDB
    Comments -->|DB ops| MongoDB
    Likes -->|DB ops| MongoDB
    Dislikes -->|DB ops| MongoDB
    Favorites -->|DB ops| MongoDB

    Entry -->|fetch metadata| TMDB
    TMDB -->|JSON data| Entry
    Entry -->|connect| Config

    %% Click Events
    click UI "https://github.com/jaewonhimnae/react-tmdb-app/tree/master/client/src/components"
    click Store "https://github.com/jaewonhimnae/react-tmdb-app/tree/master/client/src/_actions"
    click Store "https://github.com/jaewonhimnae/react-tmdb-app/tree/master/client/src/_reducers"
    click AuthHOC "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/client/src/hoc/auth.js"
    click SW "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/client/src/serviceWorker.js"
    click Manifest "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/client/public/manifest.json"
    click Proxy "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/client/src/setupProxy.js"
    click Entry "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/index.js"
    click Config "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/config/key.js"
    click AuthMW "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/middleware/auth.js"
    click Users "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/routes/users.js"
    click Comments "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/routes/comment.js"
    click Likes "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/routes/like.js"
    click Dislikes "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/routes/dislike.js"
    click Favorites "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/routes/favorite.js"
    click MUser "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/models/user.js"
    click MVideo "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/models/Video.js"
    click MComment "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/models/Comment.js"
    click MLike "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/models/Like.js"
    click MDislike "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/models/Dislike.js"
    click MFavorite "https://github.com/jaewonhimnae/react-tmdb-app/blob/master/server/models/Favorite.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px
    classDef backend fill:#DFF2D8,stroke:#28A745,stroke-width:1px
    classDef database fill:#FFE4B5,stroke:#D2691E,stroke-width:1px
    classDef external fill:#F3E5F5,stroke:#6A1B9A,stroke-width:1px
```
