# dicrey/petsheaven architecture

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

- Interactive diagram: https://gitdiagram.com/dicrey/petsheaven
- Repository: https://github.com/dicrey/petsheaven

## Overview

##### Main Components
- Front-end Client: Built with React (using Vite), it consists of various components such as navigation bars, forms (login, registration, pet-related forms), error handling (Loader, NotFound), and pages like the Veterinaria page. All UI-related assets (styles, public files) are kept within this directory.
- Back-end Server: A Node.js server (with an index.js entry point) that defines several routes (global.route.js, pets.route.js, user.route.js) and uses service modules (DataBase.js, Global.services.js, Pets.services.js, Users.services.js) to decouple business logic.
- Database: SQL scripts (dataBase.sql) and stored procedures (under the proc folder) that likely define the schema and operations to support the pet management functionalities.
- External Services: Note the front-end’s supabaseClient.js which hints at integration with Supabase (for authentication, storage, or real-time data) or similar services.

##### Relationships and Interactions
- Client–Server Communication: The front-end sends HTTP requests to the back-end routes; these requests trigger the corresponding services which encapsulate business logic.
- Server–Database Interaction: The back-end (via its dedicated DataBase.js service) connects with the database to execute queries and stored procedures for retrieving or modifying pet, user, and global data.
- Third-party/External Service Interaction: If Supabase or another external service is used, indicate a direct connection from the front-end or back-end to this service.

##### Crucial Architectural Patterns and Design Principles
- Separation of Concerns: The back-end is divided into routes and services, ensuring that HTTP request handling, business logic, and data handling are separated.
- Modularization: Both the front-end (with multiple well-organized components) and the back-end (with dedicated services for pets, users, and global operations) reflect a modular architecture.
- Layered Architecture: The system can be visualized in layers – presentation layer (front-end interface), application layer (backend routes and services), and data layer (database).

##### Relevant Technologies and Frameworks
- Front-end: React (JSX components), Vite for development/build tooling, and CSS for styling.
- Back-end: Node.js (with JavaScript), Express-like routing (as inferred from the route files), and service abstractions.
- Database: SQL-based relational database with stored procedures.
- Integration Example: Supabase (as indicated by the presence of supabaseClient.js).

## Diagram (Mermaid)

```mermaid
flowchart TD 
    subgraph "Front-End (React/Vite)"
        FE_App["App (Root Component)"]:::frontend
        FE_NavUser["User Navigation (NavBar)"]:::frontend
        FE_NavAdmin["Admin Navigation (NavBarAdmi)"]:::frontend
        FE_Login["Login Form"]:::frontend
        FE_Register["Registration Form"]:::frontend
        FE_Forgot["Forgot Password Form"]:::frontend
        FE_Pet["Pet Form"]:::frontend
        FE_Appointment["Appointment Form"]:::frontend
        FE_HomeAdmin["Home Admin Page"]:::frontend
        FE_GesUsuario["GesUsuario (User Management)"]:::frontend
        FE_Loader["Loader"]:::frontend
        FE_NotFound["NotFound"]:::frontend
        FE_Error["ErrorInternalServer"]:::frontend
        FE_Veterinaria["Veterinaria Page"]:::frontend
    end

    subgraph "Back-End (Node.js API)"
        BE_Server["Server Entry (index.js)"]:::backend
        
        subgraph "API Routes"
            BE_GlobalRoutes["Global Routes"]:::backend
            BE_PetsRoutes["Pets Routes"]:::backend
            BE_UserRoutes["User Routes"]:::backend
        end

        subgraph "Services"
            BE_DBService["Database Service"]:::backend
            BE_GlobalServices["Global Services"]:::backend
            BE_PetsServices["Pets Services"]:::backend
            BE_UsersServices["Users Services"]:::backend
        end
    end

    subgraph "Database (SQL)"
        DB_Schema1["SQL Schema (dataBase.sql)"]:::database
        DB_Schema2["SQL Schema (registros.sql)"]:::database
        subgraph "Stored Procedures"
            DB_GlobalProc["Global Procedures"]:::database
            DB_PetsProc["Pets Procedures"]:::database
            DB_UserProc["User Procedures"]:::database
        end
    end

    subgraph "External Services"
        Ext_Supabase["Supabase Client"]:::external
    end

    %% Connections
    FE_App -->|"HTTP_API_Calls"| BE_Server
    BE_Server -->|"routes_delegation"| BE_GlobalRoutes
    BE_Server -->|"routes_delegation"| BE_PetsRoutes
    BE_Server -->|"routes_delegation"| BE_UserRoutes

    BE_GlobalRoutes -->|"calls"| BE_GlobalServices
    BE_PetsRoutes -->|"calls"| BE_PetsServices
    BE_UserRoutes -->|"calls"| BE_UsersServices

    BE_GlobalServices -->|"DB_query"| BE_DBService
    BE_PetsServices -->|"DB_query"| BE_DBService
    BE_UsersServices -->|"DB_query"| BE_DBService

    BE_DBService -->|"executes_SQL"| DB_Schema1
    BE_DBService -->|"executes_SQL"| DB_Schema2
    BE_DBService -->|"executes_Procedures"| DB_GlobalProc
    BE_DBService -->|"executes_Procedures"| DB_PetsProc
    BE_DBService -->|"executes_Procedures"| DB_UserProc

    FE_App -->|"auth_storage_calls"| Ext_Supabase

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;

    %% Click Events
    click FE_App "https://github.com/dicrey/petsheaven/blob/main/front-end/src/App.jsx"
    click FE_NavUser "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/BarrasNavegacion/NavBar.jsx"
    click FE_NavAdmin "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/BarrasNavegacion/NavBarAdmi.jsx"
    click FE_Login "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/Formularios/LoginForm.jsx"
    click FE_Register "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/Formularios/Registro.jsx"
    click FE_Forgot "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/Formularios/ForgotPassword.jsx"
    click FE_Pet "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/Formularios/FormularioMascotas.jsx"
    click FE_Appointment "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/Formularios/Citas.jsx"
    click FE_HomeAdmin "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/InterfazAdmin/HomeAdmin.jsx"
    click FE_GesUsuario "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/InterfazAdmin/GesUsuario.jsx"
    click FE_Loader "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/Errores/Loader.jsx"
    click FE_NotFound "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/Errores/NotFound.jsx"
    click FE_Error "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/Errores/ErrorInternalServer.jsx"
    click FE_Veterinaria "https://github.com/dicrey/petsheaven/blob/main/front-end/src/Componentes/VeterinariaPage.jsx"
    click Ext_Supabase "https://github.com/dicrey/petsheaven/blob/main/front-end/src/supabaseClient.js"

    click BE_Server "https://github.com/dicrey/petsheaven/blob/main/back-end/index.js"
    click BE_GlobalRoutes "https://github.com/dicrey/petsheaven/blob/main/back-end/routes/global.route.js"
    click BE_PetsRoutes "https://github.com/dicrey/petsheaven/blob/main/back-end/routes/pets.route.js"
    click BE_UserRoutes "https://github.com/dicrey/petsheaven/blob/main/back-end/routes/user.route.js"
    click BE_DBService "https://github.com/dicrey/petsheaven/blob/main/back-end/services/DataBase.js"
    click BE_GlobalServices "https://github.com/dicrey/petsheaven/blob/main/back-end/services/Global.services.js"
    click BE_PetsServices "https://github.com/dicrey/petsheaven/blob/main/back-end/services/Pets.services.js"
    click BE_UsersServices "https://github.com/dicrey/petsheaven/blob/main/back-end/services/Users.services.js"

    click DB_Schema1 "https://github.com/dicrey/petsheaven/blob/main/database/dataBase.sql"
    click DB_Schema2 "https://github.com/dicrey/petsheaven/blob/main/database/registros.sql"
    click DB_GlobalProc "https://github.com/dicrey/petsheaven/blob/main/database/proc/global_proc.sql"
    click DB_PetsProc "https://github.com/dicrey/petsheaven/blob/main/database/proc/pets_proc.sql"
    click DB_UserProc "https://github.com/dicrey/petsheaven/blob/main/database/proc/user_proc.sql"
```
