# tatyana25081974/goit-typescript-hw-02 architecture

> Architecture diagram of the GitHub repository tatyana25081974/goit-typescript-hw-02, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tatyana25081974/goit-typescript-hw-02
- Repository: https://github.com/tatyana25081974/goit-typescript-hw-02

## Overview

##### Project Type and Purpose
- This is a single-page React application written in TypeScript, bootstrapped with Vite.
- It consumes the Unsplash API to provide a searchable image gallery with modal previews, load-more functionality, and error/loader states.

##### Main Components
a. Build & Dev Tooling
- Vite dev server & bundler (vite.config.ts)
- ESLint configuration (eslint.config.js)
- TypeScript compiler configurations (tsconfig.*.json)
b. Static Assets
- index.html (app shell)
- /public folder (favicon, global static files)
c. Application Entry Points
- src/main.tsx – React bootstrap and mounting into index.html
- src/index.css – global styles
d. API Layer
- src/api/unsplashApi.ts – wrapper around fetch/XHR to Unsplash REST endpoints
- src/types/unsplash.ts – TS interfaces for API contracts
e. Core React Components (component-based UI layer)
- App – top-level container, holds search state and image list
- SearchBar – user input → triggers API calls
- ImageGallery – receives array of image metadata, renders ImageCard
- ImageCard – displays a thumbnail, click → opens ImageModal
- ImageModal – shows full-size image + info
- LoadMoreBtn – fetches next page, appends to gallery
- Loader / ErrorMessage – show spinner or error on API calls
f. External Service
- Unsplash API (remote REST service)

##### Relationships & Data Flow
- User → (SearchBar) → App state → unsplashApi.fetchImages(query, page) → HTTP request → Unsplash API → JSON response → App state update → ImageGallery → ImageCard → ImageModal
- LoadMoreBtn triggers the same API layer with an incremented page parameter
- Loader/ErrorMessage subscribe to App’s “loading” and “error” flags

##### Architectural Patterns & Principles
- Component-based UI decomposition (React functional components, CSS Modules)
- Unidirectional data flow: parent (App) supplies props to children; children raise events back up
- Separation of concerns: API logic isolated from UI; types isolated in /types

##### Technologies & Frameworks
- Vite for bundling, HMR, and dev server
- React + ReactDOM for UI rendering
- TypeScript for static typing
- Babel or SWC via @vitejs/plugin-react for Fast Refresh
- CSS Modules for scoped styles
- ESLint + plugin-react for linting

## Diagram (Mermaid)

```mermaid
graph TD
    %% Build & Dev Tooling
    subgraph "Build & Dev Tooling"
        VITE["vite.config.ts"]:::tooling
        ESLINT["eslint.config.js"]:::tooling
        TSCONFIG1["tsconfig.json"]:::tooling
        TSCONFIG2["tsconfig.app.json"]:::tooling
        TSCONFIG3["tsconfig.node.json"]:::tooling
        VITEENV["vite-env.d.ts"]:::tooling
        VITETSD["vite.config.d.ts"]:::tooling
    end

    %% Static Assets
    subgraph "Static Assets"
        HTML["index.html"]:::tooling
        PUBLIC["public/"]:::tooling
    end

    %% Application Runtime Layer
    subgraph "Application Runtime"
        MAIN["src/main.tsx"]:::tooling
        CSS["src/index.css"]:::tooling

        subgraph "UI Components"
            App["App\n(holds search state & image list)"]:::ui
            SearchBar["SearchBar"]:::ui
            ImageGallery["ImageGallery\n(renders ImageCard[])"]:::ui
            ImageCard["ImageCard"]:::ui
            ImageModal["ImageModal"]:::ui
            LoadMoreBtn["LoadMoreBtn"]:::ui
            Loader["Loader"]:::ui
            ErrorMessage["ErrorMessage"]:::ui
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        UNSPLASHAPI["unsplashApi.ts"]:::data
        TYPES["unsplash.ts"]:::data
    end

    %% External Service
    EXTERNAL["Unsplash API"]:::external

    %% User Interaction & Data Flow
    User["User"] --> SearchBar
    SearchBar --> App
    App --> UNSPLASHAPI
    UNSPLASHAPI --> EXTERNAL
    EXTERNAL --> UNSPLASHAPI
    UNSPLASHAPI --> App
    App --> ImageGallery
    ImageGallery --> ImageCard
    ImageCard --> ImageModal
    App --> LoadMoreBtn
    App --> Loader
    App --> ErrorMessage

    %% Click Events
    click VITE "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/vite.config.ts"
    click ESLINT "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/eslint.config.js"
    click TSCONFIG1 "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/tsconfig.json"
    click TSCONFIG2 "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/tsconfig.app.json"
    click TSCONFIG3 "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/tsconfig.node.json"
    click VITEENV "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/vite-env.d.ts"
    click VITETSD "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/vite.config.d.ts"
    click HTML "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/index.html"
    click PUBLIC "https://github.com/tatyana25081974/goit-typescript-hw-02/tree/master/public/"
    click MAIN "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/main.tsx"
    click CSS "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/index.css"
    click UNSPLASHAPI "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/api/unsplashApi.ts"
    click TYPES "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/types/unsplash.ts"
    click App "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/components/App/App.tsx"
    click SearchBar "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/components/SearchBar/SearchBar.tsx"
    click ImageGallery "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/components/ImageGallery/ImageGallery.tsx"
    click ImageCard "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/components/ImageCard/ImageCard.tsx"
    click ImageModal "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/components/ImageModal/ImageModal.tsx"
    click LoadMoreBtn "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/components/LoadMoreBtn/LoadMoreBtn.tsx"
    click Loader "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/components/Loader/Loader.tsx"
    click ErrorMessage "https://github.com/tatyana25081974/goit-typescript-hw-02/blob/master/src/components/ErrorMessage/ErrorMessage.tsx"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085;
    classDef data fill:#d4edda,stroke:#155724,color:#155724;
    classDef tooling fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef external fill:#fff3cd,stroke:#856404,color:#856404;
    class User external
    class User external
```
