# henry-cv/pi_ctd_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/henry-cv/pi_ctd_frontend
- Repository: https://github.com/henry-cv/pi_ctd_frontend

## Overview

##### Main Components Identification
- Entry Point & Bundler: Represent the entry point (index.html, main.jsx) and Vite configuration (vite.config.js, bun.lock/package-lock.json).
- Routing System: Illustrate the routing layer (src/Routes) that houses multiple route configurations such as AppRoutes, AuthRoutes, PrivateRoutes, PublicRoute, and specific routes (Categories, etc.). This layer directs navigation and access control.
- Layouts: Include the layout component(s) (e.g., UserLayout.jsx) that provide common structure (headers, footers, sidebars) used by the various pages.
- Pages: Identify the high-level pages (e.g., ActivityDetail, Dashboard, BookingDetail, FilterProducts, Terms, UserProfile, Login, Register, home) which are essentially container components tied to routes.
- UI Components: Detail the rich set of reusable functional components in src/components. These include everything from BookingCalendars, ActivityCards, NavDash, to modals (AccessRequiredModal, ModalAviso) and filter components (e.g., CategoryFilter, DateRangeFilter).
- Global State & Hooks:
- Global Context: Include src/gContext/globalContext.jsx which likely provides global state management.
- Reducer: Represent the reducer (src/reducer/reducer.js) that manages state transitions.
- Custom Hooks: Mark hooks like useActivitiesData and useActivitiesFilter which encapsulate data fetching and filtering logic.
- Service Layer: Highlight the service modules (src/services/apiService.js, availabilityService.js, emailService.js) that manage communication with backend services/APIs.
- Constants and Utilities: Add the layer for constants (data, lists, modals info) and utilities (src/utils/utils.js) used across the project.

##### Relationships and Interactions
- Component Interaction: Illustrate how UI components are nested within Pages and Layouts. For example, the Dashboard page may include components such as DashActividades, DashAjustes, and others.
- State and API Integration: Show connections from UI components/hooks to the global context and reducer for state updates, and further tie these updates to API services which fetch data from the backend.

##### Architectural Patterns and Design Principles
- Component-Based Architecture: Emphasize the modular design – each UI element is built as its own component for reusability.
- Separation of Concerns: Distinguish clearly between presentation (components and pages), business logic (services, hooks, utilities), and state management (global context and reducer).
- Routing and Layouts: Utilizing separate layers for different types of routes (public vs. private) and diverse layouts that may vary by user type or functionality.
- Declarative Data Flow: The data flows from services -> hooks & context -> components -> views, ensuring clarity on how state is updated and maintained.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Entry Point & Bundler"
         E1["index.html"]:::entry
         E2["main.jsx"]:::entry
         E3["vite.config.js"]:::entry
    end

    subgraph "Routing System"
         R1["AppRoutes.jsx"]:::routing
         R2["AuthRoutes.jsx"]:::routing
         R3["PrivateRoutes.jsx"]:::routing
         R4["PublicRoute.jsx"]:::routing
         R5["Categories.jsx"]:::routing
    end

    subgraph "Layouts"
         L1["UserLayout.jsx"]:::layout
    end

    subgraph "Pages"
         P1["ActivityDetail.jsx"]:::pages
         P2["BookingDetail.jsx"]:::pages
         P3["Dashboard.jsx"]:::pages
         P4["FilterProducts.jsx"]:::pages
         P5["Terms.jsx"]:::pages
         P6["UserProfile.jsx"]:::pages
         P7["Login.jsx"]:::pages
         P8["Register.jsx"]:::pages
         P9["home.jsx"]:::pages
    end

    subgraph "UI Components"
         subgraph "Modals"
             C1["AccessRequiredModal.jsx"]:::components
             C2["ModalAviso.jsx"]:::components
         end
         subgraph "Activity/Booking"
             C3["ActivityCard.jsx"]:::components
             C4["Activities.jsx"]:::components
             C5["BookingCalendar.jsx"]:::components
             C6["BookingModal.jsx"]:::components
         end
         subgraph "Dashboard Components"
             C7["DashActividades.jsx"]:::components
             C8["DashAjustes.jsx"]:::components
             C9["DashCategorias.jsx"]:::components
             C10["DashCharacteristics.jsx"]:::components
             C11["DashPolicies.jsx"]:::components
             C12["DashSearch.jsx"]:::components
         end
         subgraph "Filters"
             C13["CategoryFilter.jsx"]:::components
             C14["DateRangeFilter.jsx"]:::components
             C15["DurationFilter.jsx"]:::components
             C16["LanguageFilter.jsx"]:::components
             C17["PriceRangeFilter.jsx"]:::components
             C18["RatingFilter.jsx"]:::components
             C19["SearchFilter.jsx"]:::components
         end
    end

    subgraph "Global State & Hooks"
         S1["globalContext.jsx"]:::state
         S2["reducer.js"]:::state
         S3["useActivitiesData.js"]:::state
         S4["useActivitiesFilter.js"]:::state
    end

    subgraph "Service Layer"
         SV1["apiService.js"]:::services
         SV2["availabilityService.js"]:::services
         SV3["emailService.js"]:::services
    end

    subgraph "Assets and Styles"
         A1["Assets (Directory)"]:::assets
         A2["mainStyles.css"]:::assets
         A3["PolicyPage.css"]:::assets
         A4["Styles (Directory)"]:::assets
    end

    subgraph "Constants and Utilities"
         U1["Constants (Directory)"]:::utilities
         U2["ListSidebar.jsx"]:::utilities
         U3["utils.js"]:::utilities
    end

    %% Data flow from Entry Point to Routing
    E1 --> R1
    E2 --> R1
    E3 --> R1

    %% Routing directs to Layouts
    R1 --> L1
    R2 --> L1
    R3 --> L1
    R4 --> L1
    R5 --> L1

    %% Layouts lead to Pages
    L1 --> P1
    L1 --> P2
    L1 --> P3
    L1 --> P4
    L1 --> P5
    L1 --> P6
    L1 --> P7
    L1 --> P8
    L1 --> P9

    %% Pages incorporate UI Components
    P1 --> C3
    P2 --> C5
    P3 --> C7
    P3 --> C8
    P3 --> C9
    P3 --> C10
    P3 --> C11
    P3 --> C12
    P4 --> C13
    P4 --> C14
    P4 --> C15
    P4 --> C16
    P4 --> C17
    P4 --> C18
    P4 --> C19
    P7 --> C1
    P7 --> C2
    P8 --> C1
    P8 --> C2

    %% UI Components communicate with Global State & Hooks
    C3 --> S1
    C4 --> S1
    C5 --> S1
    C6 --> S1
    C7 --> S1
    C8 --> S1
    C9 --> S1
    C10 --> S1
    C11 --> S1
    C12 --> S1
    C13 --> S1
    C14 --> S1
    C15 --> S1
    C16 --> S1
    C17 --> S1
    C18 --> S1
    C19 --> S1

    %% Global State triggers Service Layer calls
    S1 --> SV1
    S2 --> SV1
    S3 --> SV1
    S4 --> SV1

    %% Pages and Components rely on Assets and Styles
    P1 --> A2
    P5 --> A3
    C1 --> A4

    %% Pages and Components utilize Constants and Utilities
    P1 --> U1
    P1 --> U3
    C3 --> U3

    %% Assets and Utilities interconnect
    A2 --> A4
    U1 --> U3

    %% Additional hooks interactions from UI Components
    C4 --> S3
    C7 --> S4
    C8 --> S4

    %% Click Events
    click E1 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/index.html"
    click E2 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/main.jsx"
    click E3 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/vite.config.js"

    click R1 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/Routes/AppRoutes.jsx"
    click R2 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/Routes/AuthRoutes.jsx"
    click R3 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/Routes/PrivateRoutes.jsx"
    click R4 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/Routes/PublicRoute.jsx"
    click R5 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/Routes/Categories.jsx"

    click L1 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/Layouts/UserLayout.jsx"

    click P1 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/pages/ActivityDetail.jsx"
    click P2 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/pages/BookingDetail.jsx"
    click P3 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/pages/Dashboard.jsx"
    click P4 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/pages/FilterProducts.jsx"
    click P5 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/pages/Terms.jsx"
    click P6 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/pages/UserProfile.jsx"
    click P7 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/pages/auth/Login.jsx"
    click P8 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/pages/auth/Register.jsx"
    click P9 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/pages/home.jsx"

    click C1 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/AccessRequiredModal.jsx"
    click C2 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/ModalAviso.jsx"
    click C3 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/ActivityCard.jsx"
    click C4 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/Activities.jsx"
    click C5 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/BookingCalendar.jsx"
    click C6 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/BookingModal.jsx"
    click C7 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/DashActividades.jsx"
    click C8 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/DashAjustes.jsx"
    click C9 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/DashCategorias.jsx"
    click C10 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/DashCharacteristics.jsx"
    click C11 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/DashPolicies.jsx"
    click C12 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/DashSearch.jsx"
    click C13 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/filters/CategoryFilter.jsx"
    click C14 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/filters/DateRangeFilter.jsx"
    click C15 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/filters/DurationFilter.jsx"
    click C16 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/filters/LanguageFilter.jsx"
    click C17 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/filters/PriceRangeFilter.jsx"
    click C18 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/filters/RatingFilter.jsx"
    click C19 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/components/filters/SearchFilter.jsx"

    click S1 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/gContext/globalContext.jsx"
    click S2 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/reducer/reducer.js"
    click S3 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/hooks/useActivitiesData.js"
    click S4 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/hooks/useActivitiesFilter.js"

    click SV1 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/services/apiService.js"
    click SV2 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/services/availabilityService.js"
    click SV3 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/services/emailService.js"

    click A1 "https://github.com/henry-cv/pi_ctd_frontend/tree/dev/src/assets"
    click A2 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/css/global/mainStyles.css"
    click A3 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/css/pages/PolicyPage.css"
    click A4 "https://github.com/henry-cv/pi_ctd_frontend/tree/dev/src/styles"

    click U1 "https://github.com/henry-cv/pi_ctd_frontend/tree/dev/src/constants"
    click U2 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/constants/ListSidebar.jsx"
    click U3 "https://github.com/henry-cv/pi_ctd_frontend/blob/dev/src/utils/utils.js"

    %% Style Definitions
    classDef entry fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef routing fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef layout fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef pages fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef components fill:#ccffff,stroke:#333,stroke-width:2px;
    classDef state fill:#ffcc99,stroke:#333,stroke-width:2px;
    classDef services fill:#ffebcc,stroke:#333,stroke-width:2px;
    classDef assets fill:#e6e6e6,stroke:#333,stroke-width:2px;
    classDef utilities fill:#d9d9d9,stroke:#333,stroke-width:2px;
```
