# vubaolinh123/movie-fpoly architecture

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

- Interactive diagram: https://gitdiagram.com/vubaolinh123/movie-fpoly
- Repository: https://github.com/vubaolinh123/movie-fpoly

## Overview

##### Project type and purpose
- This is a Next.js–based full-stack web application (front-end + light SSR/backend integration) used as a movie discovery and streaming portal.
- It fetches data from TheMovieDB (TMDB) public API and from a separate custom backend (Node/Express API) for user-specific data (favorites, comments, profiles).
- Features include browsing movies/TV, authentication (NextAuth), user profile management, comments, favorites, and SSR/CSR pages.

##### File structure
Top-level directories and roles:
- pages/      ← Next.js routing (SSR, API routes)
– pages/api/auth/...  ← NextAuth endpoints
– pages/...           ← all site pages (home, movie, tv, category, account, admin)
- api/        ← front-end service wrappers for TMDB & backend REST calls
- app/        ← Next.js app entrypoints: root layout, hooks, Redux store setup
- components/ ← reusable UI components (Layout, Display, Movie, Shared, PrivateRouter)
- features/   ← Redux slices (auth, comment, favorite, products, user)
- models/     ← TypeScript interfaces / types
- public/     ← static assets
- styles/     ← global and module CSS/SCSS
Configuration & tooling files: next.config.js, tsconfig.json, .babelrc, Tailwind config, linting, etc.

##### README for additional insights
- Tech stack: Next.js, React, TypeScript, Tailwind, Ant Design, SWR, Redux Toolkit
- Integration points:
- NEXT_PUBLIC_TMDB_API_KEY & TMDB API URL
- NEXT_PUBLIC_API_BACKEND (custom backend)
- NextAuth for login (credentials/JWT)
- This is a team assignment demo with public URL, but architecturally it is a production-style SSR/CSR Next.js app.

##### Elements
- Browser → Next.js (page request)
- Components → Redux/SWR → API Layer → External APIs
- NextAuth flows for sign-in/sign-out
- UI (light blue)
- Data/State (yellow)
- Services (green)
- External APIs (orange)

##### Final advice
- Both SSR initial loads and CSR fetch patterns separately.
- Authentication flow (NextAuth) is distinctly highlighted (session cookie, JWT verification).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Boundary
    subgraph "Client / Browser"
        Browser["Browser"]:::external
    end

    %% Server Boundary
    subgraph "Next.js Application Server"
        %% Presentation Layer
        subgraph "Presentation Layer (pages/)"
            Home["pages/index.tsx"]:::ui
            MoviePage["pages/movie/[id]/index.tsx"]:::ui
            WatchPage["pages/movie/[id]/watch.tsx"]:::ui
            TvPage["pages/tv/[id]/index.tsx"]:::ui
            TvEpisode["pages/tv/[id]/episode.tsx"]:::ui
            TvWatch["pages/tv/[id]/watch.tsx"]:::ui
            MovieCat["pages/category/movie/index.tsx"]:::ui
            TvCat["pages/category/tv/index.tsx"]:::ui
            SubCat["pages/category/subCategory/index.tsx"]:::ui
            Search["pages/search.tsx"]:::ui
            Account["pages/account/*.tsx"]:::ui
            Admin["pages/admin/**/*.tsx"]:::ui
        end

        %% Component Library
        subgraph "Component Library (components/)"
            LayoutComp["Layout Components"]:::ui
            DisplayComp["Display Components"]:::ui
            MovieComp["Movie Components"]:::ui
            SharedComp["Shared Components"]:::ui
            PrivateRouterComp["PrivateRouter"]:::ui
        end

        %% State Management
        subgraph "State Management (app/store.tsx + features/ + hooks)"
            ReduxStore["app/store.tsx"]:::state
            AuthSlice["features/auth/auth.slice.tsx"]:::state
            CommentSlice["features/comment/comment.slice.ts"]:::state
            FavSlice["features/favorite/favorite.slice.tsx"]:::state
            ProdSlice["features/products/products.slice.tsx"]:::state
            UserSlice["features/user/user.slice.ts"]:::state
            UseCategoryHook["hook/use-category.ts"]:::state
        end

        %% API Service Layer
        subgraph "API Service Layer (api/)"
            APIConfig["api/config.tsx"]:::service
            APIConsts["api/constants.tsx"]:::service
            MoviesAPI["api/movies.tsx"]:::service
            CategoryAPI["api/category.tsx"]:::service
            AuthAPI["api/auth.tsx"]:::service
            FavAPI["api/favorite.tsx"]:::service
            CommentAPI["api/comment.ts"]:::service
            UserAPI["api/user.tsx"]:::service
        end

        %% Auth Module
        subgraph "Auth Module (NextAuth)"
            NextAuthAPI["pages/api/auth/[...nextauth].ts"]:::service
        end

        %% App Entrypoints
        subgraph "App Entrypoints & Global Setup"
            RootLayout["app/root.tsx"]:::ui
            AppHook["app/hook.tsx"]:::state
        end
    end

    %% External Services
    TMDB["TheMovieDB API"]:::external
    BackendAPI["Custom Backend API"]:::external

    %% Connections - SSR/CSR Flows
    Browser -->|"HTTP Request (SSR/CSR)"| Home
    Home -->|"renders"| LayoutComp
    LayoutComp --> DisplayComp
    LayoutComp --> MovieComp
    LayoutComp --> SharedComp
    Home --> RootLayout

    %% Component to State
    Home -->|"dispatch/useSWR"| ReduxStore
    MoviePage -->|"dispatch/useSWR"| ReduxStore
    TvPage -->|"dispatch/useSWR"| ReduxStore
    Search -->|"dispatch/useSWR"| ReduxStore

    %% Hooks
    Home --> UseCategoryHook
    MovieCat --> UseCategoryHook
    TvCat --> UseCategoryHook
    UseCategoryHook --> CategoryAPI

    %% State to API
    AuthSlice --> AuthAPI
    CommentSlice --> CommentAPI
    FavSlice --> FavAPI
    ProdSlice --> MoviesAPI
    UserSlice --> UserAPI

    %% API to External
    MoviesAPI -->|"GET /movie"| TMDB
    CategoryAPI -->|"GET /category"| TMDB
    AuthAPI -->|"POST /auth"| BackendAPI
    FavAPI -->|"GET/POST /favorites"| BackendAPI
    CommentAPI -->|"GET/POST /comments"| BackendAPI
    UserAPI -->|"GET/PUT /user"| BackendAPI

    %% Auth Flow
    Browser -->|"SignIn/SignOut"| NextAuthAPI
    NextAuthAPI --> AuthAPI
    AuthAPI --> BackendAPI

    %% Click Events
    click Home "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/index.tsx"
    click MoviePage "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/movie/[id]/index.tsx"
    click WatchPage "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/movie/[id]/watch.tsx"
    click TvPage "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/tv/[id]/index.tsx"
    click TvEpisode "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/tv/[id]/episode.tsx"
    click TvWatch "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/tv/[id]/watch.tsx"
    click MovieCat "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/category/movie/index.tsx"
    click TvCat "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/category/tv/index.tsx"
    click SubCat "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/category/subCategory/index.tsx"
    click Search "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/search.tsx"
    click Account "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/account/*.tsx"
    click Admin "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/admin/**/*.tsx"
    click NextAuthAPI "https://github.com/vubaolinh123/movie-fpoly/blob/main/pages/api/auth/[...nextauth].ts"
    click ReduxStore "https://github.com/vubaolinh123/movie-fpoly/blob/main/app/store.tsx"
    click AppHook "https://github.com/vubaolinh123/movie-fpoly/blob/main/app/hook.tsx"
    click RootLayout "https://github.com/vubaolinh123/movie-fpoly/blob/main/app/root.tsx"
    click APIConfig "https://github.com/vubaolinh123/movie-fpoly/blob/main/api/config.tsx"
    click APIConsts "https://github.com/vubaolinh123/movie-fpoly/blob/main/api/constants.tsx"
    click MoviesAPI "https://github.com/vubaolinh123/movie-fpoly/blob/main/api/movies.tsx"
    click CategoryAPI "https://github.com/vubaolinh123/movie-fpoly/blob/main/api/category.tsx"
    click AuthAPI "https://github.com/vubaolinh123/movie-fpoly/blob/main/api/auth.tsx"
    click FavAPI "https://github.com/vubaolinh123/movie-fpoly/blob/main/api/favorite.tsx"
    click CommentAPI "https://github.com/vubaolinh123/movie-fpoly/blob/main/api/comment.ts"
    click UserAPI "https://github.com/vubaolinh123/movie-fpoly/blob/main/api/user.tsx"
    click AuthSlice "https://github.com/vubaolinh123/movie-fpoly/blob/main/features/auth/auth.slice.tsx"
    click CommentSlice "https://github.com/vubaolinh123/movie-fpoly/blob/main/features/comment/comment.slice.ts"
    click FavSlice "https://github.com/vubaolinh123/movie-fpoly/blob/main/features/favorite/favorite.slice.tsx"
    click ProdSlice "https://github.com/vubaolinh123/movie-fpoly/blob/main/features/products/products.slice.tsx"
    click UserSlice "https://github.com/vubaolinh123/movie-fpoly/blob/main/features/user/user.slice.ts"
    click UseCategoryHook "https://github.com/vubaolinh123/movie-fpoly/blob/main/hook/use-category.ts"

    %% Styles
    classDef ui fill:#E0F7FA,stroke:#0288D1,stroke-width:1px
    classDef state fill:#FFF9C4,stroke:#FBC02D,stroke-width:1px
    classDef service fill:#E8F5E9,stroke:#388E3C,stroke-width:1px
    classDef external fill:#FFE0B2,stroke:#F57C00,stroke-width:1px
```
