# pisamatech/pisamaapp architecture

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

- Interactive diagram: https://gitdiagram.com/pisamatech/pisamaapp
- Repository: https://github.com/pisamatech/pisamaapp

## Overview

##### Project Type and Purpose
- This is a single‐page application (SPA) built with React and Vite, acting as a full-stack frontend that communicates with a Supabase backend for authentication, data storage (reservations, billing, profiles), and real-time updates.

##### Main Architectural Components
a. Build & Dev Toolchain
- Vite: development server and build bundler (vite.config.js)
- ESLint/PostCSS/Tailwind: linting and styling configurations
b. Entry Point & App Shell
- src/main.jsx → renders <App /> into index.html
- src/App.jsx → top-level router + layout
c. UI Layer
- src/pages: page‐level views (Admin, CalendarDiario, Dashboard, etc.)
- src/components: reusable, atomic components (forms, dialogs, calendar widgets)
- src/components/ui: design system primitives (buttons, inputs, cards, etc.)
d. State Management
- src/stores: client‐side state (authStore, calendarStore, uiStore)
- React hooks (src/hooks) for encapsulating common logic (async handling, calendar state)
e. Service Layer
- src/services: business logic wrappers (adminService, billingService, reservationLogic, etc.)
- All services consume the Supabase client or fetch APIs
f. Data Layer / External Services
- src/supabase: Supabase client configuration + data access (profileService, reservationService)
- External: Supabase APIs (Auth, Postgres), email template (mail.html)

##### Component Relationships & Data Flow
- The browser loads Vite’s dev/build output (index.html + bundled JS).
- main.jsx initializes React root → App.jsx.
- App.jsx configures routes; user navigates to different pages under src/pages.
- Pages import UI components from src/components and UI primitives.
- UI events (e.g., “make reservation”) call handlers in src/hooks or directly invoke service layer (src/services).
- Services call Supabase client (src/supabase/index.js), which sends REST/Realtime requests to Supabase backend.
- Responses update local stores (Zustand-like or plain JS) in src/stores.
- Stores emit updates; React components re-render accordingly.

##### Architectural Patterns & Design Principles
- Separation of Concerns:
- UI vs. business logic vs. data access vs. state management
- Component Composition: small, reusable UI building blocks in src/components/ui
- Unidirectional Data Flow: actions → services → data layer → stores → UI
- Modular Folder Structure: grouping by “feature” (calendar, reservation, billing)
- Hooks for cross-cutting concerns (async, mobile detection, theme toggling)

##### Essential Elements to Capture
- Entry point and routing (Vite → main.jsx → App.jsx → <Routes>)
- UI component hierarchy (pages → components → ui primitives)
- State stores and how they’re updated
- Service layer as abstraction over Supabase client
- Supabase as the external data/auth backend
- Development/build support (ESLint, Tailwind, Vite)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interaction
    USER((User)):::user

    %% Build & Dev Toolchain
    subgraph "Build & Dev Toolchain"
        direction TB
        VITE["Vite Configuration"]:::dev
        TAILWIND["TailwindCSS Configuration"]:::dev
        POSTCSS["PostCSS Configuration"]:::dev
        ESLINT["ESLint Configuration"]:::dev
    end

    %% Browser/App Runtime
    subgraph "Browser / App Runtime"
        direction TB

        %% Entry Point & App Shell
        subgraph "Entry Point & App Shell"
            direction TB
            INDEX_HTML["index.html"]:::dev
            MAIN["src/main.jsx"]:::dev
            APP["src/App.jsx"]:::dev
        end

        %% UI Layer
        subgraph "UI Layer"
            direction TB
            PAGES["Pages"]:::ui
            COMPONENTS["Components"]:::ui
            PRIMITIVES["UI Primitives"]:::ui
        end

        %% State Management
        subgraph "State Management"
            direction TB
            AUTH_STORE["authStore.js"]:::state
            CALENDAR_STORE["calendarStore.js"]:::state
            UI_STORE["uiStore.js"]:::state
        end

        %% Service Layer
        subgraph "Service Layer"
            direction TB
            ADMIN_SERVICE["adminService.js"]:::service
            BILLING_SERVICE["billingService.js"]:::service
            DASHBOARD_SERVICE["dashboardService.js"]:::service
            RESERVATION_LOGIC["reservationLogic.js"]:::service
        end

        %% Hooks & Utilities
        subgraph "Hooks & Utils"
            direction TB
            USE_ASYNC["useAsyncHandler.js"]:::utils
            USE_CALENDAR_STATE["useCalendarState.js"]:::utils
            USE_RESERVATION_HANDLER["useReservationHandler.js"]:::utils
            USE_MOBILE["use-mobile.jsx"]:::utils
            UTILS["Utility Functions"]:::utils
            STYLES["Global Styles"]:::utils
            VALIDATIONS["Validation Schemas"]:::utils
            EMAIL_TEMPLATE["mail.html"]:::utils
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SUPABASE_CLIENT["Supabase Client"]:::external
        PROFILE_SERVICE["profileService.js"]:::external
        RESERVATION_SERVICE["reservationService.js"]:::external
        SUPABASE_API[(Supabase Auth & Postgres)]:::external
    end

    %% Connections
    USER -->|"interacts with"| PAGES
    VITE -->|builds| INDEX_HTML
    INDEX_HTML -->|loads| MAIN
    MAIN -->|renders| APP
    APP -->|routes to| PAGES
    PAGES -->|uses| COMPONENTS
    COMPONENTS -->|uses| PRIMITIVES
    PAGES -->|dispatches events| USE_ASYNC
    COMPONENTS -->|dispatches events| USE_RESERVATION_HANDLER
    USE_ASYNC -->|calls| SERVICE_LAYER_CALL[SERVICE Layer]
    USE_RESERVATION_HANDLER -->|calls| RESERVATION_LOGIC
    SERVICE_LAYER_CALL -->|invokes| ADMIN_SERVICE
    SERVICE_LAYER_CALL -->|invokes| BILLING_SERVICE
    SERVICE_LAYER_CALL -->|invokes| DASHBOARD_SERVICE
    SERVICE_LAYER_CALL -->|invokes| RESERVATION_LOGIC
    RESERVATION_LOGIC -->|uses| SUPABASE_CLIENT
    ADMIN_SERVICE -->|uses| SUPABASE_CLIENT
    BILLING_SERVICE -->|uses| SUPABASE_CLIENT
    DASHBOARD_SERVICE -->|uses| SUPABASE_CLIENT
    SUPABASE_CLIENT -->|calls| PROFILE_SERVICE
    SUPABASE_CLIENT -->|calls| RESERVATION_SERVICE
    PROFILE_SERVICE -->|requests| SUPABASE_API
    RESERVATION_SERVICE -->|requests| SUPABASE_API
    SUPABASE_API -->|responds| AUTH_STORE
    SUPABASE_API -->|responds| CALENDAR_STORE
    SUPABASE_API -->|responds| UI_STORE
    AUTH_STORE -->|updates| PAGES
    CALENDAR_STORE -->|updates| COMPONENTS
    UI_STORE -->|updates| PRIMITIVES

    %% Click Events
    click VITE "https://github.com/pisamatech/pisamaapp/blob/main/vite.config.js"
    click TAILWIND "https://github.com/pisamatech/pisamaapp/blob/main/tailwind.config.js"
    click POSTCSS "https://github.com/pisamatech/pisamaapp/blob/main/postcss.config.js"
    click ESLINT "https://github.com/pisamatech/pisamaapp/blob/main/eslint.config.js"
    click INDEX_HTML "https://github.com/pisamatech/pisamaapp/blob/main/index.html"
    click MAIN "https://github.com/pisamatech/pisamaapp/blob/main/src/main.jsx"
    click APP "https://github.com/pisamatech/pisamaapp/blob/main/src/App.jsx"
    click PAGES "https://github.com/pisamatech/pisamaapp/tree/main/src/pages"
    click COMPONENTS "https://github.com/pisamatech/pisamaapp/tree/main/src/components"
    click PRIMITIVES "https://github.com/pisamatech/pisamaapp/tree/main/src/components/ui"
    click AUTH_STORE "https://github.com/pisamatech/pisamaapp/blob/main/src/stores/authStore.js"
    click CALENDAR_STORE "https://github.com/pisamatech/pisamaapp/blob/main/src/stores/calendarStore.js"
    click UI_STORE "https://github.com/pisamatech/pisamaapp/blob/main/src/stores/uiStore.js"
    click USE_ASYNC "https://github.com/pisamatech/pisamaapp/blob/main/src/hooks/useAsyncHandler.js"
    click USE_CALENDAR_STATE "https://github.com/pisamatech/pisamaapp/blob/main/src/hooks/useCalendarState.js"
    click USE_RESERVATION_HANDLER "https://github.com/pisamatech/pisamaapp/blob/main/src/hooks/useReservationHandler.js"
    click USE_MOBILE "https://github.com/pisamatech/pisamaapp/blob/main/src/hooks/use-mobile.jsx"
    click UTILS "https://github.com/pisamatech/pisamaapp/blob/main/src/lib/utils.js"
    click STYLES "https://github.com/pisamatech/pisamaapp/blob/main/src/index.css"
    click VALIDATIONS "https://github.com/pisamatech/pisamaapp/blob/main/src/validations/validationSchemas.js"
    click EMAIL_TEMPLATE "https://github.com/pisamatech/pisamaapp/blob/main/src/mail.html"
    click ADMIN_SERVICE "https://github.com/pisamatech/pisamaapp/blob/main/src/services/adminService.js"
    click BILLING_SERVICE "https://github.com/pisamatech/pisamaapp/blob/main/src/services/billingService.js"
    click DASHBOARD_SERVICE "https://github.com/pisamatech/pisamaapp/blob/main/src/services/dashboardService.js"
    click RESERVATION_LOGIC "https://github.com/pisamatech/pisamaapp/blob/main/src/services/reservationLogic.js"
    click SUPABASE_CLIENT "https://github.com/pisamatech/pisamaapp/blob/main/src/supabase/index.js"
    click PROFILE_SERVICE "https://github.com/pisamatech/pisamaapp/blob/main/src/supabase/profileService.js"
    click RESERVATION_SERVICE "https://github.com/pisamatech/pisamaapp/blob/main/src/supabase/reservationService.js"

    %% Styles
    classDef ui fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef state fill:#E8F5E9,stroke:#1B5E20,color:#2E7D32
    classDef service fill:#FFF3E0,stroke:#E65100,color:#EF6C00
    classDef external fill:#FFEBEE,stroke:#B71C1C,color:#C62828
    classDef dev fill:#ECEFF1,stroke:#37474F,color:#455A64
    classDef utils fill:#FFFDE7,stroke:#F9A825,color:#F57F17
    classDef user fill:#EDE7F6,stroke:#512DA8,color:#4527A0
```
