# kongoner/petspaw-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/kongoner/petspaw-v2
- Repository: https://github.com/kongoner/petspaw-v2

## Overview

##### Project type and purpose
- PetsPaw is a client-only, single-page application (SPA) built with React and Vite.
- It provides an interactive UI for browsing, voting on, searching, and uploading cat images via TheCatAPI.

##### File structure
- Top-level files:
- index.html, public/ (static assets & fallback 404.html)
- vite.config.js (build config)
- “src/” is subdivided into:
- api/ — Axios instance and service modules (breeds, voting, uploads, etc.)
- components/ — Reusable UI building blocks (buttons, cards, grid, loader, toggles, etc.)
- pages/ — Route-level components (BreedsPage, GalleryPage, VotingPage, etc.)
- hooks/ — Custom React hooks (theme control/listener)
- utils/ — Shared utilities (e.g. user.js)
- styles/ & component-level SCSS modules — Theming, variables, mixins.
- Presence of React Router DOM implied by “PageRoutes.jsx.”

##### README
- Confirms tech stack: React, Vite, SCSS, Axios, React Router, TheCatAPI.
- No back-end code: all API calls go to the external TheCatAPI service.

##### Main components & interactions
a. Client/browser – hosts the React SPA.
b. Build tool – Vite dev server and bundler (handles module resolution, SCSS→CSS, hot reload).
c. Routing layer – React Router (“PageRoutes.jsx”) directs to route-specific pages.
d. Page components – high-level views (BreedsPage, GalleryPage, etc.) import:
- UI components (buttons, grids, cards, loader)
- Service functions (from src/api/*)
e. API layer – axiosInstance configured with base URL and headers; service modules implement REST calls to endpoints (GET /breeds, POST /votes, POST /images/upload, etc.).
f. External TheCatAPI service – responds with JSON data (images, breeds, votes).

##### Architectural patterns & design principles
- Component-based modularization (presentational vs container/page components).
- Feature-based directory organization.
- Separation of concerns: UI layer vs service layer vs routing.
- CSS Modules + global SCSS for theming.
- Custom hooks for cross-cutting concerns (theme).

##### Final checklist
- All components clearly labeled.
- Call out major directories and files (optional side list).
- External dependencies (TheCatAPI) and build tool (Vite).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build & Dev Server
    subgraph "Build & Dev Server"
        Vite["Vite Dev Server\n(vite.config.js)"]:::build
    end

    %% Static Assets
    subgraph "Static Assets"
        Assets["public/\nassets, images\n404.html"]:::static
    end

    %% Client Application
    subgraph "Client Application (React SPA)"
        subgraph "Entry Point"
            Main["main.jsx"]:::ui
            App["App.jsx"]:::ui
        end
        subgraph "Routing Layer"
            Routes["PageRoutes.jsx"]:::ui
        end
        subgraph "Pages"
            Breeds["BreedsPage.jsx"]:::ui
            Gallery["GalleryPage.jsx"]:::ui
            Voting["VotingPage.jsx"]:::ui
            Favourites["FavouritesPage.jsx"]:::ui
            Likes["LikesPage.jsx"]:::ui
            Dislikes["DislikesPage.jsx"]:::ui
            Search["SearchResultsPage.jsx"]:::ui
            BreedInfo["BreedInfoPage.jsx"]:::ui
        end
        subgraph "Reusable UI Components"
            ImageGrid["ImageGrid.jsx"]:::ui
            Carousel["Carousel.jsx"]:::ui
            Loader["Loader.jsx"]:::ui
            Toolbar["Toolbar.jsx"]:::ui
            UploadForm["UploadForm.jsx"]:::ui
            UserLog["UserLog.jsx"]:::ui
            Dropdown["Dropdown.jsx\nDropdownLabeled.jsx"]:::ui
            Pagination["Pagination.jsx"]:::ui
        end
        subgraph "Layout & Navigation"
            Layout["Layout.jsx"]:::ui
            Breadcrumbs["Breadcrumbs.jsx"]:::ui
            LinkButton["LinkButton.jsx"]:::ui
            SearchBar["SearchBar.jsx"]:::ui
            ThemeToggle["ThemeToggle.jsx"]:::ui
        end
        subgraph "Hooks & Utils"
            ThemeCtrl["useThemeControl.js"]:::ui
            ThemeListener["useThemeListener.js"]:::ui
            UserUtil["user.js"]:::ui
        end
    end

    %% API Layer
    subgraph "API Layer"
        Axios["axiosInstance.js"]:::api
        BreedsAPI["breeds.js"]:::api
        GalleryAPI["gallery.js"]:::api
        VotingAPI["voting.js"]:::api
        FavouritesAPI["favouritesVotes.js"]:::api
        UploadAPI["upload.js"]:::api
        LogsAPI["logs.js"]:::api
    end

    %% External Service
    External["TheCatAPI\nExternal Service"]:::external

    %% Connections
    Vite --> Assets
    Vite --> Main
    Main --> App
    App --> Routes
    Routes --> Breeds
    Routes --> Gallery
    Routes --> Voting
    Routes --> Favourites
    Routes --> Likes
    Routes --> Dislikes
    Routes --> Search
    Routes --> BreedInfo
    Breeds --> BreedsAPI
    Gallery --> GalleryAPI
    Voting --> VotingAPI
    Favourites --> FavouritesAPI
    Search --> GalleryAPI
    BreedInfo --> BreedsAPI
    BreedsAPI --> Axios
    GalleryAPI --> Axios
    VotingAPI --> Axios
    FavouritesAPI --> Axios
    UploadAPI --> Axios
    LogsAPI --> Axios
    Axios --> External

    %% Click Events
    click Vite "https://github.com/kongoner/petspaw-v2/blob/main/vite.config.js"
    click Assets "https://github.com/kongoner/petspaw-v2/tree/main/public/"
    click Assets "https://github.com/kongoner/petspaw-v2/blob/main/public/404.html"
    click Assets "https://github.com/kongoner/petspaw-v2/tree/main/public/assets/"
    click Assets "https://github.com/kongoner/petspaw-v2/tree/main/public/images/"
    click Main "https://github.com/kongoner/petspaw-v2/blob/main/src/main.jsx"
    click App "https://github.com/kongoner/petspaw-v2/blob/main/src/App.jsx"
    click Routes "https://github.com/kongoner/petspaw-v2/blob/main/src/components/PageRoutes.jsx"
    click Breeds "https://github.com/kongoner/petspaw-v2/blob/main/src/pages/BreedsPage.jsx"
    click Gallery "https://github.com/kongoner/petspaw-v2/blob/main/src/pages/GalleryPage.jsx"
    click Voting "https://github.com/kongoner/petspaw-v2/blob/main/src/pages/VotingPage.jsx"
    click Favourites "https://github.com/kongoner/petspaw-v2/blob/main/src/pages/FavouritesPage.jsx"
    click Likes "https://github.com/kongoner/petspaw-v2/blob/main/src/pages/LikesPage.jsx"
    click Dislikes "https://github.com/kongoner/petspaw-v2/blob/main/src/pages/DislikesPage.jsx"
    click Search "https://github.com/kongoner/petspaw-v2/blob/main/src/pages/SearchResultsPage.jsx"
    click BreedInfo "https://github.com/kongoner/petspaw-v2/blob/main/src/pages/BreedInfoPage.jsx"
    click ImageGrid "https://github.com/kongoner/petspaw-v2/blob/main/src/components/ImageGrid/ImageGrid.jsx"
    click Carousel "https://github.com/kongoner/petspaw-v2/blob/main/src/components/Carousel/Carousel.jsx"
    click Loader "https://github.com/kongoner/petspaw-v2/blob/main/src/components/Loader/Loader.jsx"
    click Toolbar "https://github.com/kongoner/petspaw-v2/blob/main/src/components/Toolbar/Toolbar.jsx"
    click UploadForm "https://github.com/kongoner/petspaw-v2/blob/main/src/components/Upload/UploadForm.jsx"
    click UserLog "https://github.com/kongoner/petspaw-v2/blob/main/src/components/UserLog/UserLog.jsx"
    click Dropdown "https://github.com/kongoner/petspaw-v2/blob/main/src/components/Dropdowns/Dropdown.jsx"
    click Pagination "https://github.com/kongoner/petspaw-v2/blob/main/src/components/Pagination/Pagination.jsx"
    click Layout "https://github.com/kongoner/petspaw-v2/blob/main/src/components/Layout.jsx"
    click Breadcrumbs "https://github.com/kongoner/petspaw-v2/blob/main/src/components/Breadcrumbs/Breadcrumbs.jsx"
    click LinkButton "https://github.com/kongoner/petspaw-v2/blob/main/src/components/LinkButton/LinkButton.jsx"
    click SearchBar "https://github.com/kongoner/petspaw-v2/blob/main/src/components/SearchBar/SearchBar.jsx"
    click ThemeToggle "https://github.com/kongoner/petspaw-v2/blob/main/src/components/Toggles/ThemeToggle.jsx"
    click ThemeCtrl "https://github.com/kongoner/petspaw-v2/blob/main/src/hooks/useThemeControl.js"
    click ThemeListener "https://github.com/kongoner/petspaw-v2/blob/main/src/hooks/useThemeListener.js"
    click UserUtil "https://github.com/kongoner/petspaw-v2/blob/main/src/utils/user.js"
    click Axios "https://github.com/kongoner/petspaw-v2/blob/main/src/api/axiosInstance.js"
    click BreedsAPI "https://github.com/kongoner/petspaw-v2/blob/main/src/api/breeds.js"
    click GalleryAPI "https://github.com/kongoner/petspaw-v2/blob/main/src/api/gallery.js"
    click VotingAPI "https://github.com/kongoner/petspaw-v2/blob/main/src/api/voting.js"
    click FavouritesAPI "https://github.com/kongoner/petspaw-v2/blob/main/src/api/favouritesVotes.js"
    click UploadAPI "https://github.com/kongoner/petspaw-v2/blob/main/src/api/upload.js"
    click LogsAPI "https://github.com/kongoner/petspaw-v2/blob/main/src/api/logs.js"

    %% Styles
    classDef build fill:#b0bec5,stroke:#000,color:#000
    classDef static fill:#eceff1,stroke:#000,color:#000
    classDef ui fill:#bbdefb,stroke:#000,color:#000
    classDef api fill:#c8e6c9,stroke:#000,color:#000
    classDef external fill:#ffe0b2,stroke:#000,color:#000
```
