# linkmetal/phone-catalog-front architecture

> Architecture diagram of the GitHub repository linkmetal/phone-catalog-front, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/linkmetal/phone-catalog-front
- Repository: https://github.com/linkmetal/phone-catalog-front

## Overview

##### Project type and purpose
- This is a single‐page application (SPA) built with React and TypeScript.
- It serves as the frontend “Phone Catalog” web client, consuming a RESTful Phone Catalog API.
- Key indicators:
- Only a `public/` folder and `src/` directory.
- No backend code—network layer under `src/network`.
- README describes React Query + Axios for data fetching.

##### File structure
- Top-level dirs and files:
- public/ – static assets (index.html, manifest, fonts, robots.txt)
- src/ – application sources
- .github/workflows – CI pipeline
- Procfile – Heroku deployment manifest
- Under src/:
- App.tsx + index.tsx – root of the React tree
- components/ – generic, reusable UI controls (FileInput, Modal, Toast, etc.)
- screens/ – page‐level views (Home, PhoneDetail), each with its own components
- network/ – ApiClient wrapper around Axios + repository layer (PhonesRepository)
- hooks/ – custom React Query hooks (mutations + queries)
- contexts/ – global contexts (ToastContext)
- styles/ – theming (stitches config) and shared styles
- constants/ + types/ – domain types and constants

##### Extract insights from the README
- Core libraries: React Query, Axios, Radix Primitives, React Stitches, Formik, ahooks.
- Testing via Jest + React Testing Library.
- CI defined in `.github/workflows/pr-main.yml`.
- Deployment uses Procfile (Heroku) and standard `yarn build` for static hosting.

##### Detail
- Repository pattern under the network layer.
- Environment injection (REACT_APP_BACKEND_API_URL) from .env into ApiClient.

- Identifies all major React pieces (UI, state, network)
- Shows how they interconnect
- Reflects third‐party libraries where they play a key role
- Captures CI/CD and deployment context

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CI/CD Layer
    subgraph "CI/CD Pipeline"
        GH["GitHub Actions Workflow"]:::ci
        ProcfileNode["Procfile"]:::ci
    end
    GH -->|"runs CI"| ProcfileNode
    ProcfileNode -->|"deploy"| StaticHost["Static Asset Hosting"]:::external

    %% External Service
    subgraph "External Service"
        API["Phone Catalog REST API"]:::externalService
    end

    %% React Application in Browser
    subgraph "React Application (Browser)"
        subgraph "Entry & App Shell"
            IDX["index.tsx"]:::entry
            APP["App.tsx"]:::appShell
        end

        subgraph "Screens"
            Home["Home Screen"]:::screen
            Detail["Phone Detail Screen"]:::screen
        end

        subgraph "Reusable UI Components"
            Header["Header"]:::ui
            Toolbar["Toolbar"]:::ui
            FileInput["FileInput"]:::ui
            Select["Select"]:::ui
            MultiCheckboxSelect["MultiCheckboxSelect"]:::ui
            RangeInput["RangeInput"]:::ui
            TextInput["TextInput"]:::ui
            Modal["Modal"]:::ui
            ToastComponent["Toast"]:::ui
            Typography["Typography"]:::ui
        end

        subgraph "State & Data Layer"
            ToastCtx["ToastContext"]:::context
            subgraph "React Query Hooks"
                FetchList["useFetchPhones Query"]:::hook
                FetchDetails["useFetchPhoneDetails Query"]:::hook
                AddPhone["useAddPhone Mutation"]:::hook
                AddImage["useAddPhoneImage Mutation"]:::hook
                EditPhone["useEditPhone Mutation"]:::hook
                DeletePhone["useDeletePhone Mutation"]:::hook
            end
        end

        subgraph "Network Layer"
            ApiClient["ApiClient (Axios)"]:::network
            Repo["PhonesRepository"]:::network
        end
    end

    %% Data Flows
    IDX -->|renders| APP
    APP -->|navigates to| Home
    APP -->|navigates to| Detail

    Home -->|uses| FetchList
    Detail -->|uses| FetchDetails

    Header -->|ui| APP
    Toolbar -->|ui| APP
    FileInput -->|ui| Home
    Select -->|ui| Home
    MultiCheckboxSelect -->|ui| Home
    RangeInput -->|ui| Home
    TextInput -->|ui| Home
    Modal -->|ui| Detail
    ToastComponent -->|ui| APP
    Typography -->|ui| Home

    FetchList -->|calls| ApiClient
    FetchDetails -->|calls| ApiClient
    AddPhone -->|calls| ApiClient
    AddImage -->|calls| ApiClient
    EditPhone -->|calls| ApiClient
    DeletePhone -->|calls| ApiClient

    ApiClient -->|uses| Repo
    Repo -->|HTTP requests| API

    API -->|response| Repo
    Repo -->|data| ApiClient

    ApiClient -->|resolves| FetchList
    ApiClient -->|resolves| FetchDetails
    ApiClient -->|resolves| AddPhone
    ApiClient -->|resolves| AddImage
    ApiClient -->|resolves| EditPhone
    ApiClient -->|resolves| DeletePhone

    FetchList -->|updates| Home
    FetchDetails -->|updates| Detail
    AddPhone -->|updates cache| Home
    EditPhone -->|updates cache| Detail
    DeletePhone -->|updates cache| Home
    AddImage -->|updates cache| Detail

    %% Click Events
    click IDX "https://github.com/linkmetal/phone-catalog-front/blob/master/src/index.tsx"
    click APP "https://github.com/linkmetal/phone-catalog-front/blob/master/src/App.tsx"
    click Home "https://github.com/linkmetal/phone-catalog-front/blob/master/src/screens/Home/Home.tsx"
    click Detail "https://github.com/linkmetal/phone-catalog-front/blob/master/src/screens/PhoneDetail/PhoneDetail.tsx"
    click Header "https://github.com/linkmetal/phone-catalog-front/blob/master/src/components/Header/Header.tsx"
    click Toolbar "https://github.com/linkmetal/phone-catalog-front/blob/master/src/components/Toolbar/Toolbar.tsx"
    click FileInput "https://github.com/linkmetal/phone-catalog-front/blob/master/src/components/FileInput/FileInput.tsx"
    click Select "https://github.com/linkmetal/phone-catalog-front/blob/master/src/components/Select/Select.tsx"
    click MultiCheckboxSelect "https://github.com/linkmetal/phone-catalog-front/blob/master/src/components/MultiCheckboxSelect/MultiCheckboxSelect.tsx"
    click RangeInput "https://github.com/linkmetal/phone-catalog-front/blob/master/src/components/RangeInput/RangeInput.tsx"
    click TextInput "https://github.com/linkmetal/phone-catalog-front/blob/master/src/components/TextInput/TextInput.tsx"
    click Modal "https://github.com/linkmetal/phone-catalog-front/blob/master/src/components/Modal/Modal.tsx"
    click ToastComponent "https://github.com/linkmetal/phone-catalog-front/blob/master/src/components/Toast/Toast.tsx"
    click Typography "https://github.com/linkmetal/phone-catalog-front/blob/master/src/components/Typography/Typography.tsx"
    click ToastCtx "https://github.com/linkmetal/phone-catalog-front/blob/master/src/contexts/ToastContext.tsx"
    click FetchList "https://github.com/linkmetal/phone-catalog-front/blob/master/src/hooks/queries/useFetchPhones.tsx"
    click FetchDetails "https://github.com/linkmetal/phone-catalog-front/blob/master/src/hooks/queries/useFetchPhoneDetails.tsx"
    click AddPhone "https://github.com/linkmetal/phone-catalog-front/blob/master/src/hooks/mutations/useAddPhone.tsx"
    click AddImage "https://github.com/linkmetal/phone-catalog-front/blob/master/src/hooks/mutations/useAddPhoneImage.tsx"
    click EditPhone "https://github.com/linkmetal/phone-catalog-front/blob/master/src/hooks/mutations/useEditPhone.tsx"
    click DeletePhone "https://github.com/linkmetal/phone-catalog-front/blob/master/src/hooks/mutations/useDeletePhone.tsx"
    click ApiClient "https://github.com/linkmetal/phone-catalog-front/blob/master/src/network/ApiClient.ts"
    click Repo "https://github.com/linkmetal/phone-catalog-front/blob/master/src/network/repositories/PhonesRepository.ts"
    click StaticHost "https://github.com/linkmetal/phone-catalog-front/blob/master/public/index.html"
    click GH "https://github.com/linkmetal/phone-catalog-front/blob/master/.github/workflows/pr-main.yml"
    click ProcfileNode "https://github.com/linkmetal/phone-catalog-front/tree/master/Procfile"

    %% Styles
    classDef ui fill:#B3D4FC,stroke:#0366d6,color:#000
    classDef screen fill:#A8D5BA,stroke:#2C7A4B,color:#000
    classDef entry fill:#D0C8F2,stroke:#5D3FD3,color:#000
    classDef appShell fill:#ECDCB0,stroke:#B5838D,color:#000
    classDef context fill:#C1E1C1,stroke:#2E8B57,color:#000
    classDef hook fill:#D0F0C0,stroke:#228B22,color:#000
    classDef network fill:#FFD8B1,stroke:#FF8C00,color:#000
    classDef externalService fill:#F4C2C2,stroke:#B22222,color:#000
    classDef ci fill:#E0E0E0,stroke:#808080,color:#000
    classDef external fill:#FFE4B5,stroke:#DAA520,color:#000
```
