# nguyenhaotran/filmstudio architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenhaotran/filmstudio
- Repository: https://github.com/nguyenhaotran/filmstudio

## Overview

##### Main components
- Entry Points & Build System:
- index.html, main.jsx and the Vite configuration (vite.config.js) form the foundation.
- package.json and other config files (eslint.config.js, .prettierrc, jsconfig.json) indicate the use of code standards and build/refresh tools (such as the available plugins for Babel and SWC).

- UI Layers:
- The main React application (App.jsx) acts as the container.
- Pages: There are distinct pages like “OurShop” and “Cart” found under src/pages which handle different routes and views.
- Components: A large number of reusable components such as Header, Footer, Banner, Sidebar, and specialized components (e.g., CountdownTimer, PaymentMethods) are organized within src/components.

- State Management:
- Context providers (OurShopProvider, SideBarProvider, ToastProvider, storeProvider) found under src/contexts manage application state and convey data to various components.

- API Integration:
- The src/apis directory contains modules like authService.js, cartService.js, productsService.js, and axios clients, suggesting RESTful API calls for user authentication and product/cart operations.

- Assets & Styling:

- Routing:
- The routers directory (with routers/routers.js) indicates how different pages are connected through routing rules.

##### Relationships and interactions
- Entry Point -> React Application:
- The index.html and main.jsx act as the starting point, loading App.jsx.

- Component Hierarchy & Routing:
- App.jsx likely embeds the Router component (from routers/routers.js) that switches between pages (e.g., OurShop and Cart).
- Each page then composes various presentational and interactive components (e.g., Banner, Header, Footer, etc.) that structure the UI.

- Global State Providers:
- The context providers wrap around the component tree to supply global state (like shopping cart data, user session, toast notifications).
- They interact with API modules to fetch or post data as changes occur.

- API Layer:
- The axiosClient modules manage communication with backend APIs,
- Services (authService, productsService, cartService) handle specific endpoints and business logic for actions such as user login, product fetching, or cart management.

- Static Assets:
- Assets (images, videos, styles) feed into the components, emphasizing visuals that enrich the user interface.

##### Important architectural patterns
- Component-Based Architecture:
- The extensive use of individual and reusable components follows React’s best practices.

- Separation of Concerns:
- Clear separation between UI (components), state management (contexts), routing (routers), and data fetching (apis).

- Modular Styling:
- SCSS modules and a dedicated assets directory for styling ensure that UI styling is maintained separately, enhancing maintainability.

##### Relevant technologies
- React for the component-based UI.
- Vite as the build tool and development server – emphasizing fast refresh (via Babel or SWC).
- ESLint/Prettier for code linting and formatting.
- RESTful API integration through axios-based clients.
- SCSS modules for styling.

- Clear labels for each component cluster (e.g., “Entry Point”, “UI Components”, “Pages”, “Context Providers”, “API Services”, “Assets & Styling”).
- Data flow from the API Services to Context Providers.
- How Routers pass control to different Pages.
- How State Providers feed into the main App and then to nested components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Points & Build System
    subgraph "Entry Points & Build System"
        EP1["index.html"]:::entry
        EP2["src/main.jsx"]:::entry
        EP3["vite.config.js"]:::entry
        EP4["package.json"]:::entry
        EP5["eslint.config.js"]:::entry
        EP6[".prettierrc"]:::entry
        EP7["jsconfig.json"]:::entry
    end

    %% Main React Application
    subgraph "Main React Application"
        App["App.jsx"]:::app
    end

    %% Routing
    subgraph "Routing"
        Router["routers/routers.js"]:::router
    end

    %% Pages
    subgraph "Pages"
        OurShop["Our-Shop Page"]:::page
        Cart["Cart Page"]:::page
    end

    %% UI Components
    subgraph "UI Components"
        Header["Header"]:::component
        Footer["Footer"]:::component
        Banner["Banner"]:::component
        Countdown["CountdownTimer"]:::component
        Payment["PaymentMethods"]:::component
        Others["Other Reusable Components"]:::component
    end

    %% Global State Providers
    subgraph "Global State Providers"
        Provider1["OurShopProvider"]:::context
        Provider2["SideBarProvider"]:::context
        Provider3["ToastProvider"]:::context
        Provider4["storeProvider"]:::context
    end

    %% API Services
    subgraph "API Services"
        Auth["authService"]:::api
        CartService["cartService"]:::api
        Products["productsService"]:::api
        Axios["axiosClient"]:::api
        AxiosAuth["axiosClientAuth"]:::api
    end

    %% Assets & Styling
    subgraph "Assets & Styling"
        Images["Images"]:::asset
        Icons["Icons"]:::asset
        Videos["Videos"]:::asset
        Styles["SCSS Files"]:::asset
    end

    %% Connections: Entry Points load the App
    EP1 --> App
    EP2 --> App
    EP3 --> App
    EP4 --> App
    EP5 --> App
    EP6 --> App
    EP7 --> App

    %% App connects to Router and is wrapped by Global State Providers
    App --> Router
    Provider1 --- App
    Provider2 --- App
    Provider3 --- App
    Provider4 --- App

    %% Router directs to Pages
    Router --> OurShop
    Router --> Cart

    %% Global State Providers interact with API Services
    Auth --> Provider1
    Auth --> Provider2
    Auth --> Provider3
    Auth --> Provider4

    CartService --> Provider1
    CartService --> Provider2
    CartService --> Provider3
    CartService --> Provider4

    Products --> Provider1
    Products --> Provider2
    Products --> Provider3
    Products --> Provider4

    Axios --> Auth
    AxiosAuth --> Auth

    %% Pages incorporate UI Components
    OurShop --> Header
    OurShop --> Banner
    OurShop --> Footer
    Cart --> Header
    Cart --> Footer

    %% UI Components inter-relate
    Header --> Countdown
    Banner --> Payment
    Others --> Header

    %% Assets & Styling feed into UI Components
    Images --> Header
    Icons --> Header
    Videos --> Banner
    Styles --> Banner
    Styles --> Footer
    Styles --> Header

    %% Click Events for Entry Points & Build System
    click EP1 "https://github.com/nguyenhaotran/filmstudio/blob/main/index.html"
    click EP2 "https://github.com/nguyenhaotran/filmstudio/blob/main/src/main.jsx"
    click EP3 "https://github.com/nguyenhaotran/filmstudio/blob/main/vite.config.js"
    click EP4 "https://github.com/nguyenhaotran/filmstudio/blob/main/package.json"
    click EP5 "https://github.com/nguyenhaotran/filmstudio/blob/main/eslint.config.js"
    click EP6 "https://github.com/nguyenhaotran/filmstudio/blob/main/.prettierrc"
    click EP7 "https://github.com/nguyenhaotran/filmstudio/blob/main/jsconfig.json"

    %% Click Events for Main React Application and Routing
    click App "https://github.com/nguyenhaotran/filmstudio/blob/main/src/App.jsx"
    click Router "https://github.com/nguyenhaotran/filmstudio/blob/main/src/routers/routers.js"

    %% Click Events for Pages
    click OurShop "https://github.com/nguyenhaotran/filmstudio/blob/main/src/pages/OurShop/OurShop.jsx"
    click Cart "https://github.com/nguyenhaotran/filmstudio/blob/main/src/pages/Cart/Cart.jsx"

    %% Click Events for UI Components
    click Header "https://github.com/nguyenhaotran/filmstudio/blob/main/src/components/Header/Header.jsx"
    click Footer "https://github.com/nguyenhaotran/filmstudio/blob/main/src/components/Footer/Footer.jsx"
    click Banner "https://github.com/nguyenhaotran/filmstudio/blob/main/src/components/Banner/Banner.jsx"
    click Countdown "https://github.com/nguyenhaotran/filmstudio/blob/main/src/components/CountdownTimer/CountdownTimer.jsx"
    click Payment "https://github.com/nguyenhaotran/filmstudio/blob/main/src/components/PaymentMethods/PaymentMethods.jsx"

    %% Click Events for Global State Providers
    click Provider1 "https://github.com/nguyenhaotran/filmstudio/blob/main/src/contexts/OurShopProvider.jsx"
    click Provider2 "https://github.com/nguyenhaotran/filmstudio/blob/main/src/contexts/SideBarProvider.jsx"
    click Provider3 "https://github.com/nguyenhaotran/filmstudio/blob/main/src/contexts/ToastProvider.jsx"
    click Provider4 "https://github.com/nguyenhaotran/filmstudio/blob/main/src/contexts/storeProvider.jsx"

    %% Click Events for API Services
    click Auth "https://github.com/nguyenhaotran/filmstudio/blob/main/src/apis/authService.js"
    click CartService "https://github.com/nguyenhaotran/filmstudio/blob/main/src/apis/cartService.js"
    click Products "https://github.com/nguyenhaotran/filmstudio/blob/main/src/apis/productsService.js"
    click Axios "https://github.com/nguyenhaotran/filmstudio/blob/main/src/apis/axiosClient.js"
    click AxiosAuth "https://github.com/nguyenhaotran/filmstudio/blob/main/src/apis/axiosClientAuth.js"

    %% Click Events for Assets & Styling
    click Images "https://github.com/nguyenhaotran/filmstudio/tree/main/src/assets/images"
    click Icons "https://github.com/nguyenhaotran/filmstudio/tree/main/src/assets/icons"
    click Videos "https://github.com/nguyenhaotran/filmstudio/tree/main/src/assets/videos"
    click Styles "https://github.com/nguyenhaotran/filmstudio/tree/main/src/assets/styles"

    %% Styles for nodes by category
    classDef entry fill:#f7c6c7,stroke:#333,stroke-width:2px;
    classDef app fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef router fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef page fill:#e2e3e5,stroke:#333,stroke-width:2px;
    classDef component fill:#ffeeba,stroke:#333,stroke-width:2px;
    classDef context fill:#d1ecf1,stroke:#333,stroke-width:2px;
    classDef api fill:#f8d7da,stroke:#333,stroke-width:2px;
    classDef asset fill:#e2eafc,stroke:#333,stroke-width:2px;
```
