# ezedealla/pi-dogs architecture

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

- Interactive diagram: https://gitdiagram.com/ezedealla/pi-dogs
- Repository: https://github.com/ezedealla/pi-dogs

## Overview

##### Project type and purpose
- This is a full-stack “Henry Dogs” application.
- Frontend: React (CRA) + Redux for state management.
- Backend: Node.js + Express, using Sequelize to connect to a Postgres database.
- Purpose: Display dog breeds from an external Dog API, allow searching/filtering/ordering on the frontend, and enable users to create new breeds stored in the local database.

##### File structure
- Top-level folders:
- api/ → Express server
- client/ → React app (Create React App structure)
- In api/:
- src/app.js → Express app initialization
- src/routes/ → route definitions for `/dogs` and `/temperaments`
- src/controllers/ → business logic for each route
- src/models/ → Sequelize models (Dog.js, Temperament.js)
- src/db.js → Sequelize setup and model associations (many-to-many)
- .env file (not committed) holds DB credentials and Dog API key
- In client/:
- public/ → static HTML, manifest, robots.txt
- src/index.js → React entry point
- src/components/ → UI components by feature (Card, Home, DogDetail, Formulario, etc.)
- src/Redux/ → actions, reducers, store configuration
- CSS modules for component styling
- setupTests.js and App.test.js for frontend tests

##### Key insights from README
- External Dog API used only to fetch breed data; no filtering/pagination handled there.
- Local DB only stores user-created breeds; external breeds are never persisted.
- Required endpoints: GET /dogs, GET /dogs?name=, GET /dogs/:id, POST /dogs, GET /temperaments.
- Tests: at least one model test, one route test, one component test.

##### Detail without overthinking
- Express folder as a component.
- Redux’s 3 pieces (actions, reducers, store) distinctly.
- Config (.env loading) feeding both server (DB creds, API key) and client (if any).
- Don’t omit the many-to-many join table for Temperaments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Layer
    subgraph "External Services" 
        style ExternalAPI fill:#D8BFD8,stroke:#9932CC,stroke-width:2px
        ExternalAPI(["TheDogAPI.com (REST)"]):::external
    end

    %% Client Layer
    subgraph "Frontend (React)" 
        style ClientLayer fill:#ADD8E6,stroke:#1E90FF,stroke-width:2px
        IDX["Index.js"]:::frontend
        APP["App.js"]:::frontend
        subgraph "Components" 
            CARD["Card"]:::component
            HOME["Home Page"]:::component
            DETAIL["Dog Detail"]:::component
            DETAILNAME["Dog Detail By Name"]:::component
            FORM["Create Form"]:::component
            LAND["Landing Page"]:::component
            PAGI["Pagination"]:::component
            SEARCH["Search Bar"]:::component
        end
        subgraph "Redux" 
            ACT["Actions"]:::redux
            RED["Reducers"]:::redux
            STORE["Store"]:::redux
        end
        subgraph "Assets & Tests"
            PUBLIC["public/*"]:::assets
            IMG["src/img"]:::assets
            APPTEST["App.test.js"]:::test
            SETUP["setupTests.js"]:::test
            REPORT["reportWebVitals.js"]:::util
        end
    end

    %% Server Layer
    subgraph "Backend (Node/Express)" 
        style ServerLayer fill:#98FB98,stroke:#2E8B57,stroke-width:2px
        ENTRY["index.js"]:::backend
        APPJS["app.js"]:::backend
        subgraph "Routes" 
            RINDEX["routes/index.js"]:::route
            RDOG["routes/dogs.js"]:::route
            RTEMP["routes/temperaments.js"]:::route
        end
        subgraph "Controllers" 
            CONT["controllers/index.js"]:::controller
        end
        subgraph "Models & ORM" 
            DOGM["Dog.js"]:::model
            TEMPM["Temperament.js"]:::model
            DB["db.js"]:::db
        end
        subgraph "Tests" 
            MODELTEST["dog.spec.js (models)"]:::test
            ROUTETEST["dog.spec.js (routes)"]:::test
        end
    end

    %% Database Layer
    subgraph "Postgres Database" 
        style DBLayer fill:#FFDAB9,stroke:#FF8C00,stroke-width:2px
        PG["Postgres"]:::database
    end

    %% Connections: Frontend
    IDX -->|"renders"| APP
    APP -->|"renders components"| CARD
    APP --> HOME
    HOME --> DETAIL
    HOME --> DETAILNAME
    HOME --> FORM
    HOME --> PAGI
    HOME --> SEARCH

    %% Redux flow
    CARD -->|"dispatches actions"| ACT
    SEARCH --> ACT
    FORM --> ACT
    ACT -->|"calls API"| STORE
    STORE -->|"makes HTTP"| ENTRY

    %% Server flow
    ENTRY --> APPJS
    APPJS --> RINDEX
    RINDEX --> RDOG
    RINDEX --> RTEMP
    RDOG --> CONT
    RTEMP --> CONT
    CONT --> DOGM
    CONT --> TEMPM
    DOGM --> DB
    TEMPM --> DB
    DB --> PG

    %% External API integration
    CONT -->|"fetchBreeds()"| ExternalAPI
    ExternalAPI --> CONT

    %% Tests connections
    MODELTEST --> DOGM
    ROUTETEST --> RDOG

    %% Click Events
    click APPJS "https://github.com/ezedealla/pi-dogs/blob/main/api/src/app.js"
    click ENTRY "https://github.com/ezedealla/pi-dogs/blob/main/api/index.js"
    click RINDEX "https://github.com/ezedealla/pi-dogs/blob/main/api/src/routes/index.js"
    click RDOG "https://github.com/ezedealla/pi-dogs/blob/main/api/src/routes/dogs.js"
    click RTEMP "https://github.com/ezedealla/pi-dogs/blob/main/api/src/routes/temperaments.js"
    click CONT "https://github.com/ezedealla/pi-dogs/blob/main/api/src/controllers/index.js"
    click DOGM "https://github.com/ezedealla/pi-dogs/blob/main/api/src/models/Dog.js"
    click TEMPM "https://github.com/ezedealla/pi-dogs/blob/main/api/src/models/Temperament.js"
    click DB "https://github.com/ezedealla/pi-dogs/blob/main/api/src/db.js"
    click MODELTEST "https://github.com/ezedealla/pi-dogs/blob/main/api/tests/models/dog.spec.js"
    click ROUTETEST "https://github.com/ezedealla/pi-dogs/blob/main/api/tests/routes/dog.spec.js"
    click IDX "https://github.com/ezedealla/pi-dogs/blob/main/client/src/index.js"
    click APP "https://github.com/ezedealla/pi-dogs/blob/main/client/src/App.js"
    click ACT "https://github.com/ezedealla/pi-dogs/blob/main/client/src/Redux/actions/index.js"
    click RED "https://github.com/ezedealla/pi-dogs/blob/main/client/src/Redux/reducer/index.js"
    click STORE "https://github.com/ezedealla/pi-dogs/blob/main/client/src/Redux/store/index.js"
    click CARD "https://github.com/ezedealla/pi-dogs/blob/main/client/src/components/Card/card.jsx"
    click HOME "https://github.com/ezedealla/pi-dogs/blob/main/client/src/components/Home/home.jsx"
    click DETAIL "https://github.com/ezedealla/pi-dogs/blob/main/client/src/components/DogDetail/DogDetail.jsx"
    click DETAILNAME "https://github.com/ezedealla/pi-dogs/blob/main/client/src/components/DogDetail/DogDetailByName.jsx"
    click FORM "https://github.com/ezedealla/pi-dogs/blob/main/client/src/components/Formulario/Formulario.jsx"
    click LAND "https://github.com/ezedealla/pi-dogs/blob/main/client/src/components/LandingPage/landingPage.jsx"
    click PAGI "https://github.com/ezedealla/pi-dogs/blob/main/client/src/components/Paginado/paginado.jsx"
    click SEARCH "https://github.com/ezedealla/pi-dogs/blob/main/client/src/components/SearchBar/searchbar.jsx"
    click APPTEST "https://github.com/ezedealla/pi-dogs/blob/main/client/src/App.test.js"
    click SETUP "https://github.com/ezedealla/pi-dogs/blob/main/client/src/setupTests.js"
    click REPORT "https://github.com/ezedealla/pi-dogs/blob/main/client/src/reportWebVitals.js"

    %% Styles
    classDef external fill:#D8BFD8,stroke:#9932CC
    classDef frontend fill:#ADD8E6,stroke:#1E90FF
    classDef component fill:#FFFFFF,stroke:#1E90FF
    classDef redux fill:#E0FFFF,stroke:#1E90FF
    classDef assets fill:#F0F8FF,stroke:#1E90FF
    classDef test fill:#FFE4E1,stroke:#FF4500,stroke-dasharray: 5 5
    classDef util fill:#F5F5DC,stroke:#1E90FF
    classDef backend fill:#98FB98,stroke:#2E8B57
    classDef route fill:#F0FFF0,stroke:#2E8B57
    classDef controller fill:#E6FFE6,stroke:#2E8B57
    classDef model fill:#F0FFF0,stroke:#2E8B57
    classDef db fill:#E6FFE6,stroke:#2E8B57
    classDef database fill:#FFDAB9,stroke:#FF8C00
```
