# aman-chhetri/movix-app architecture

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

- Interactive diagram: https://gitdiagram.com/aman-chhetri/movix-app
- Repository: https://github.com/aman-chhetri/movix-app

## Overview

##### Project Type & Purpose
- Movix is a front-end, single-page movie information web app that leverages the TMDB API to fetch movie data.
- It is built using React for the view layer, Redux for state management, and Vite as its build tool. Tailwind CSS is mentioned in the README (although the code uses SCSS in many components), which implies a focus on styled, responsive UI components.
- The primary purpose is to provide users with rich details on movies including trailers, cast & crew, reviews, and ratings.

##### Analyzing the File Structure
- Top-level files such as index.html, package.json, vite.config.js, and .env indicate a typical modern web front-end project setup.
- The src folder contains:
- The entry point (main.jsx) and global styles (index.scss, mixins.scss).
- A well-organized components structure with dedicated subdirectories for UI elements (carousel, header, footer, movieCard, etc.). This shows that the design follows a component-driven development approach.
- The pages directory segregates the various routes (home, details, explore, searchResult, a 404 page) — suggesting that there's routing logic to handle different views.
- A store directory indicates state management using Redux (store.js and homeSlice.js).
- A hooks folder (with useFetch.jsx) for custom React hooks to deal with data fetching, likely targeting the TMDB API through the utils/api.js module.
- Additional directories like public and screenshots provide static assets and visual references for documentation, respectively.

##### Key Components & Interactions
- Presentation Layer:
- Root UI component (App.jsx) that ties together the various pages and shared components like Header, Footer, and Content Wrapper.
- Multiple small components (Carousel, CircleRating, MovieCard, Spinner, VideoPopup, etc.) which assemble the user interface into complete pages.
- Routing & Page Organization:
- Pages (home, details, explore, searchResult, 404) are designed to display different movie-related data and require navigation between them.
- State Management:
- Redux store is used to manage global state for movies, which is likely updated via actions in slices (e.g., homeSlice.js) and triggered by components.
- Data Access Layer:
- The custom hook (useFetch.jsx) and utils/api.js are the abstraction layers that fetch data from the external TMDB API. This external API integration is central to acquiring movie data.
- Build & Configuration:
- Configuration files like vite.config.js and .env represent build settings, environment variables, and deployment configurations.

##### Architectural Patterns & Design Principles
- Component-Based Architecture: Clear separation of UI elements into reusable, independent components.
- Unidirectional Data Flow: Through React and Redux, where user interactions trigger Redux actions causing updates that lead to UI re-rendering.
- Separation of Concerns: Dividing the app into presentation (React components), state management (Redux store), and data access (hooks and API utilities).
- Modularity: A clear modular structure is maintained by grouping features into respective directories (pages, components, hooks, store).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface Layer"
        EP["Entry Point & Global Setup"]:::ui
        GlobalStyles["Global Styles"]:::ui
        App["App Container"]:::ui

        subgraph "Components"
            Header["Header"]:::ui
            Footer["Footer"]:::ui
            ContentWrapper["Content Wrapper"]:::ui
            Carousel["Carousel"]:::ui
            MovieCard["Movie Card"]:::ui
            CircleRating["Circle Rating"]:::ui
            Spinner["Spinner"]:::ui
            VideoPopup["Video Popup"]:::ui
            Genres["Genres"]:::ui
            LazyLoadImage["LazyLoad Image"]:::ui
            SwitchTabs["Switch Tabs"]:::ui
        end

        subgraph "Pages"
            HomePage["Home Page"]:::ui
            DetailsPage["Details Page"]:::ui
            ExplorePage["Explore Page"]:::ui
            SearchResultPage["Search Result Page"]:::ui
            PageNotFound["404 Page"]:::ui
        end
    end

    subgraph "State Management"
        ReduxStore["Redux Store"]:::state
        HomeSlice["Home Slice"]:::state
    end

    subgraph "Data Access"
        UseFetch["Custom Data Fetch Hook"]:::data
        APIUtil["API Utilities"]:::data
    end

    subgraph "Configuration"
        BuildConfig["Build Tool & Config"]:::config
    end

    subgraph "External Services"
        TMDB["TMDB API"]:::external
    end

    %% Connections between layers
    BuildConfig -->|"Build"| EP
    EP -->|"Loads"| App
    GlobalStyles -->|"AppliesTo"| App

    App -->|"Renders"| HomePage
    App -->|"Renders"| DetailsPage
    App -->|"Renders"| ExplorePage
    App -->|"Renders"| SearchResultPage
    App -->|"Renders"| PageNotFound

    HomePage -->|"dispatch"| ReduxStore
    DetailsPage -->|"dispatch"| ReduxStore
    ExplorePage -->|"dispatch"| ReduxStore
    SearchResultPage -->|"dispatch"| ReduxStore
    PageNotFound -->|"dispatch"| ReduxStore

    ReduxStore -->|"uses"| HomeSlice
    ReduxStore -->|"triggers"| UseFetch
    UseFetch -->|"calls"| APIUtil
    APIUtil -->|"fetches"| TMDB
    TMDB -->|"returns"| APIUtil
    APIUtil -->|"updates"| UseFetch
    UseFetch -->|"updates"| ReduxStore

    Header -->|"partOf"| App
    Footer -->|"partOf"| App
    ContentWrapper -->|"wraps"| Carousel
    Carousel -->|"displays"| MovieCard
    MovieCard -->|"shows"| CircleRating
    Spinner -->|"loading"| VideoPopup
    Genres -->|"filters"| MovieCard
    LazyLoadImage -->|"loads"| MovieCard
    SwitchTabs -->|"switches"| MovieCard

    %% Click Events
    click EP "https://github.com/aman-chhetri/movix-app/blob/main/src/main.jsx, index.html"
    click App "https://github.com/aman-chhetri/movix-app/blob/main/src/App.jsx"
    click GlobalStyles "https://github.com/aman-chhetri/movix-app/blob/main/src/index.scss, src/mixins.scss"
    click Header "https://github.com/aman-chhetri/movix-app/blob/main/src/components/header/Header.jsx"
    click Footer "https://github.com/aman-chhetri/movix-app/blob/main/src/components/footer/Footer.jsx"
    click ContentWrapper "https://github.com/aman-chhetri/movix-app/blob/main/src/components/contentWrapper/ContentWrapper.jsx"
    click Carousel "https://github.com/aman-chhetri/movix-app/blob/main/src/components/carousel/Carousel.jsx"
    click MovieCard "https://github.com/aman-chhetri/movix-app/blob/main/src/components/movieCard/MovieCard.jsx"
    click CircleRating "https://github.com/aman-chhetri/movix-app/blob/main/src/components/circleRating/CircleRating.jsx"
    click Spinner "https://github.com/aman-chhetri/movix-app/blob/main/src/components/spinner/Spinner.jsx"
    click VideoPopup "https://github.com/aman-chhetri/movix-app/blob/main/src/components/videoPopup/VideoPopup.jsx"
    click Genres "https://github.com/aman-chhetri/movix-app/blob/main/src/components/genres/Genres.jsx"
    click LazyLoadImage "https://github.com/aman-chhetri/movix-app/blob/main/src/components/lazyLoadImage/Img.jsx"
    click SwitchTabs "https://github.com/aman-chhetri/movix-app/blob/main/src/components/switchTabs/SwitchTabs.jsx"
    click HomePage "https://github.com/aman-chhetri/movix-app/blob/main/src/pages/home/Home.jsx"
    click DetailsPage "https://github.com/aman-chhetri/movix-app/blob/main/src/pages/details/Details.jsx"
    click ExplorePage "https://github.com/aman-chhetri/movix-app/blob/main/src/pages/explore/Explore.jsx"
    click SearchResultPage "https://github.com/aman-chhetri/movix-app/blob/main/src/pages/searchResult/SearchResult.jsx"
    click PageNotFound "https://github.com/aman-chhetri/movix-app/blob/main/src/pages/404/PageNotFound.jsx"
    click ReduxStore "https://github.com/aman-chhetri/movix-app/blob/main/src/store/store.js"
    click HomeSlice "https://github.com/aman-chhetri/movix-app/blob/main/src/store/homeSlice.js"
    click UseFetch "https://github.com/aman-chhetri/movix-app/blob/main/src/hooks/useFetch.jsx"
    click APIUtil "https://github.com/aman-chhetri/movix-app/blob/main/src/utils/api.js"
    click BuildConfig "https://github.com/aman-chhetri/movix-app/blob/main/vite.config.js, .env"

    %% Styles
    classDef ui fill:#D0E5F5,stroke:#333,stroke-width:2px;
    classDef state fill:#F5D0D0,stroke:#333,stroke-width:2px;
    classDef data fill:#D0F5D0,stroke:#333,stroke-width:2px;
    classDef config fill:#FDF5D0,stroke:#333,stroke-width:2px;
    classDef external fill:#F5F5D0,stroke:#333,stroke-width:2px;
```
