# vicktorry/03-react-movies architecture

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

- Interactive diagram: https://gitdiagram.com/vicktorry/03-react-movies
- Repository: https://github.com/vicktorry/03-react-movies

## Overview

##### Project type and purpose
- This is a single-page frontend application built with React, TypeScript, and Vite.
- It provides a movie search UI: users enter queries in a SearchBar, results appear in a MovieGrid, and detailed info pops up in a MovieModal. Data is fetched via src/services/movieService.ts from an external movie‐data API.

##### File structure
- Top-level
– public/index.html: host page template
– src/main.tsx: React app entry point
– vite.config.ts and ESLint configs: build and lint setup
- src/components
– App: root container
– SearchBar, MovieGrid, MovieModal, Loader, ErrorMessage: UI widgets
- src/services/movieService.ts: encapsulates HTTP calls to external API
- src/types/movie.ts: TypeScript interfaces
- CSS Modules alongside components for styling

##### README
- Generic React + TS + Vite template instructions
- No custom architecture notes beyond recommending ESLint/TS integration

a. Main components
- Browser (host)
- Vite Dev Server / Production Bundle (build tooling)
- React Application:
– UI Layer: App, SearchBar, MovieGrid, MovieModal, Loader, ErrorMessage
– Service Layer: movieService
– Type Definitions & CSS Modules (supporting libraries)
- External Movie‐Data API (e.g., OMDB/TMDB)
b. Relationships and interactions
- User → Browser → React App (UI events)
- SearchBar issues requests to movieService
- movieService → External API (HTTP) → returns JSON
- App component holds state and passes data down to MovieGrid and MovieModal
- Loader & ErrorMessage respond to service promise states
- Vite handles bundling, hot‐module replacement, and serves the app during development
c. Architectural patterns and principles
- Layered architecture: UI Layer vs Service Layer vs External API
- Component composition: parent (App) and child (SearchBar, MovieGrid, etc.)
- Single Responsibility: each component handles one concern
- CSS Modules for scoped styling
d. Key technologies/frameworks/libraries
- React + React DOM
- Vite (Dev Server, ESBuild, HMR)
- TypeScript (static types)
- CSS Modules
- ESLint + @vitejs/plugin-react

##### Detailed but concise: capture these elements
- On the left, show “Browser” hosting “Vite Dev Server (HMR)” or “Production Bundle”
- In the center, group React components: App → {SearchBar, MovieGrid, MovieModal, Loader, ErrorMessage}
- State flows and error/loading paths

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Browser & Tooling"
        indexHTML["index.html"]:::tooling
        DevServer["Vite Dev Server (HMR)"]:::tooling
        ProdBundle["Production Bundle"]:::tooling
        indexHTML --> DevServer
        indexHTML --> ProdBundle
        DevServer --> Browser["Browser"]:::external
        ProdBundle --> Browser
    end

    Browser --> Main["src/main.tsx"]:::entry

    subgraph "React App"
        subgraph "UI Layer"
            App["App"]:::ui
            SearchBar["SearchBar"]:::ui
            MovieGrid["MovieGrid"]:::ui
            MovieModal["MovieModal"]:::ui
            Loader["Loader"]:::ui
            ErrorMessage["ErrorMessage"]:::ui
        end
        subgraph "Service Layer"
            movieService["movieService"]:::service
        end
        subgraph "Supporting"
            Types["type definitions"]:::support
            Styles["CSS Modules/global styles"]:::support
        end
        App --> SearchBar
        App --> MovieGrid
        App --> MovieModal
        App --> Loader
        App --> ErrorMessage
        SearchBar -->|"search(query)"| movieService
        movieService -->|"HTTP request"| ExternalAPI
        ExternalAPI -->|"JSON response"| movieService
        movieService -->|"data"| App
        movieService -->|"loading/error"| Loader
        movieService -->|"error"| ErrorMessage
    end

    Main --> ReactApp
    ReactApp --> movieService
    subgraph "External System"
        ExternalAPI["External Movie API"]:::external
    end

    click indexHTML "https://github.com/vicktorry/03-react-movies/blob/main/index.html"
    click DevServer "https://github.com/vicktorry/03-react-movies/blob/main/vite.config.ts"
    click Main "https://github.com/vicktorry/03-react-movies/blob/main/src/main.tsx"
    click App "https://github.com/vicktorry/03-react-movies/blob/main/src/components/App/App.tsx"
    click SearchBar "https://github.com/vicktorry/03-react-movies/blob/main/src/components/SearchBar/SearchBar.tsx"
    click MovieGrid "https://github.com/vicktorry/03-react-movies/blob/main/src/components/MovieGrid/MovieGrid.tsx"
    click MovieModal "https://github.com/vicktorry/03-react-movies/blob/main/src/components/MovieModal/MovieModal.tsx"
    click Loader "https://github.com/vicktorry/03-react-movies/blob/main/src/components/Loader/Loader.tsx"
    click ErrorMessage "https://github.com/vicktorry/03-react-movies/blob/main/src/components/ErrorMessage/ErrorMessage.tsx"
    click movieService "https://github.com/vicktorry/03-react-movies/blob/main/src/services/movieService.ts"
    click Types "https://github.com/vicktorry/03-react-movies/blob/main/src/types/movie.ts"
    click Styles "https://github.com/vicktorry/03-react-movies/blob/main/src/index.css"

    classDef ui fill:#D0E8FF,stroke:#0288D1,stroke-width:1px
    classDef service fill:#E0F2F1,stroke:#00796B,stroke-width:1px
    classDef external fill:#F5F5F5,stroke:#9E9E9E,stroke-width:1px
    classDef tooling fill:#ECEFF1,stroke:#546E7A,stroke-width:1px
    classDef entry fill:#FFF3E0,stroke:#FB8C00,stroke-width:1px
    classDef support fill:#F3E5F5,stroke:#8E24AA,stroke-width:1px
```
