# guillerg01/phase_system_admin architecture

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

- Interactive diagram: https://gitdiagram.com/guillerg01/phase_system_admin
- Repository: https://github.com/guillerg01/phase_system_admin

## Overview

##### Project type and purpose
- This is a Next.js (v13+) full‑stack web application (front‑end focused) that exposes two main sections:
- A public “landing” area with basic marketing pages
- An authenticated “admin” dashboard (drivers, payments, reservations, tariffs)
- The UI fetches and displays data via REST‑style API services (ApiClientService and specific EntityApiServices)

##### File structure
- Top‑level Next.js files: next.config.ts, tsconfig.json, postcss.config.mjs
- “public” folder holds static assets for landing pages
- “src/app” implements Next.js App Router with two route segments:
- (landing) – unauthenticated marketing pages
- admin – protected dashboard pages
- “src/components”: reusable React components by feature (Auth, LandingPage, admin subfolders, generic tables, modals, buttons, etc.)
- “src/context”: React Context providers (AuthContext, selected‑items)
- “src/hooks”: custom hooks for data fetching and table state
- “src/services”: abstraction over REST API calls (ApiClientService, DriverApiServices, etc.)
- “src/utils”: shared utilities (formatters, pdf generator, toastify, loading spinners)

##### README
- Confirms Next.js scaffold via create‑next‑app
- Mentions frontend optimizations (next/font) and Vercel deployment
- No backend code; all API surfaces are consumed remotely

##### Detail without over‑splitting
- Related components (e.g., all “admin/*” components under one cluster)
- Cross‑cutting concerns (authentication, global utils)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Next.js Core
    subgraph "Next.js Core" 
        direction TB
        AppRouter["App Router"]:::core
        SSR_SSG["SSR / SSG Pipelines"]:::core
        GlobalLayout["Global Layout"]:::core
        GlobalStyles["Global Styles"]:::core
    end

    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        subgraph "Public Landing Pages" 
            direction TB
            LandingSeg["(landing) Pages"]:::ui
        end
        subgraph "Admin Dashboard Pages"
            direction TB
            AdminSeg["admin Pages"]:::ui
        end
        subgraph "Shared UI Components"
            direction TB
            GenericTable["GenericTable"]:::ui
            GenericTableItem["GenericTableItem"]:::ui
            Buttons["Buttons"]:::ui
            Inputs["Inputs"]:::ui
            DeleteModal["DeleteModal"]:::ui
            BasicModal["ModalBasic"]:::ui
        end
    end

    %% State & Context
    subgraph "State & Context" 
        direction TB
        AuthContext["AuthContext"]:::state
        SelectedItemsCtx["SelectedItemsContext"]:::state
    end

    %% Services & Hooks
    subgraph "Services & Hooks"
        direction TB
        subgraph "API Services"
            direction TB
            ApiClient["ApiClientService"]:::service
            EntityService["EntityApiService"]:::service
            DriverService["DriverApiServices"]:::service
            PaymentService["PaymentApiServices"]:::service
            ReservationService["ReservationApiServices"]:::service
            TariffService["TariffApiServices"]:::service
        end
        subgraph "Custom Hooks"
            direction TB
            HookDrivers["useGetDrivers"]:::service
            HookLocations["useGetLocationsByID"]:::service
            HookTariffHistory["useGetTariffHistory"]:::service
            HookTableStore["useGenerictableStore"]:::service
        end
    end

    %% Utilities
    subgraph "Utilities"
        direction TB
        Formatters["formatters"]:::utils
        PDFGen["pdfGenerator"]:::utils
        Toastify["toastify"]:::utils
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        RESTAPI["Remote REST API"]:::external
        AuthProvider["Auth Provider"]:::external
        CDN["Vercel/CDN"]:::external
    end

    %% Connections
    AppRouter -->|renders| LandingSeg
    AppRouter -->|renders| AdminSeg
    AppRouter -->|uses| GlobalLayout
    AppRouter -->|uses| GlobalStyles

    LandingSeg -->|uses| GenericTable
    LandingSeg -->|uses| Buttons
    AdminSeg -->|uses| GenericTable
    AdminSeg -->|uses| DeleteModal
    AdminSeg -->|uses| BasicModal

    GenericTableItem -->|child of| GenericTable
    Buttons -->|child of| Inputs

    AuthContext -->|provides token to| ApiClient
    SelectedItemsCtx -->|manages state for| GenericTable

    LandingSeg -->|calls| HookLocations
    AdminSeg -->|calls| HookDrivers
    AdminSeg -->|calls| HookTableStore
    AdminSeg -->|calls| HookTariffHistory

    HookDrivers -->|calls| DriverService
    HookLocations -->|calls| EntityService
    HookTariffHistory -->|calls| TariffService
    HookTableStore -->|calls| ReservationService

    DriverService -->|extends| EntityService
    PaymentService -->|extends| EntityService
    ReservationService -->|extends| EntityService
    TariffService -->|extends| EntityService

    EntityService -->|uses| ApiClient
    ApiClient -->|HTTP to| RESTAPI
    ApiClient -->|auth via| AuthProvider

    Formatters -->|used by| LandingSeg
    PDFGen -->|used by| AdminSeg
    Toastify -->|used by| AdminSeg

    AppRouter -->|deployed on| CDN

    %% Click Events
    click AppRouter "https://github.com/guillerg01/phase_system_admin/tree/main/src/app"
    click LandingSeg "https://github.com/guillerg01/phase_system_admin/tree/main/src/app/(landing)"
    click AdminSeg "https://github.com/guillerg01/phase_system_admin/tree/main/src/app/admin"
    click GlobalLayout "https://github.com/guillerg01/phase_system_admin/blob/main/src/app/layout.tsx"
    click GlobalStyles "https://github.com/guillerg01/phase_system_admin/blob/main/src/app/globals.css"
    click AuthContext "https://github.com/guillerg01/phase_system_admin/blob/main/src/context/AuthContext.tsx"
    click SelectedItemsCtx "https://github.com/guillerg01/phase_system_admin/blob/main/src/context/selected-items-context.tsx"
    click ApiClient "https://github.com/guillerg01/phase_system_admin/blob/main/src/services/ApiClientService.ts"
    click EntityService "https://github.com/guillerg01/phase_system_admin/blob/main/src/services/EntityApiService.ts"
    click DriverService "https://github.com/guillerg01/phase_system_admin/blob/main/src/services/DriverApiServices.ts"
    click PaymentService "https://github.com/guillerg01/phase_system_admin/blob/main/src/services/PaymentApiServices.ts"
    click ReservationService "https://github.com/guillerg01/phase_system_admin/blob/main/src/services/ReservationApiServices.ts"
    click TariffService "https://github.com/guillerg01/phase_system_admin/blob/main/src/services/TariffApiServices.ts"
    click HookDrivers "https://github.com/guillerg01/phase_system_admin/blob/main/src/hooks/useGetDrivers.ts"
    click HookLocations "https://github.com/guillerg01/phase_system_admin/blob/main/src/hooks/useGetLocationsByID.ts"
    click HookTariffHistory "https://github.com/guillerg01/phase_system_admin/blob/main/src/hooks/useGetTariffHistory.ts"
    click HookTableStore "https://github.com/guillerg01/phase_system_admin/blob/main/src/hooks/useGenerictableStore.ts"
    click GenericTable "https://github.com/guillerg01/phase_system_admin/blob/main/src/components/table/GenericTable.tsx"
    click GenericTableItem "https://github.com/guillerg01/phase_system_admin/blob/main/src/components/table/GenericTableItem.tsx"
    click Buttons "https://github.com/guillerg01/phase_system_admin/blob/main/src/components/Buttons/buttons.tsx"
    click Inputs "https://github.com/guillerg01/phase_system_admin/blob/main/src/components/Buttons/inputs.tsx"
    click DeleteModal "https://github.com/guillerg01/phase_system_admin/blob/main/src/components/modalGeneric/DeleteModal.tsx"
    click BasicModal "https://github.com/guillerg01/phase_system_admin/blob/main/src/components/modalGeneric/modal-basic.tsx"
    click Formatters "https://github.com/guillerg01/phase_system_admin/blob/main/src/utils/formatters.ts"
    click PDFGen "https://github.com/guillerg01/phase_system_admin/blob/main/src/utils/pdfGenerator.ts"
    click Toastify "https://github.com/guillerg01/phase_system_admin/blob/main/src/utils/toast_hot/toastify.ts"

    %% Styles
    classDef core fill:#e0f0ff,stroke:#009,stroke-width:1px
    classDef ui fill:#e0ffe0,stroke:#090,stroke-width:1px
    classDef state fill:#fff4e0,stroke:#fa0,stroke-width:1px
    classDef service fill:#f4e0ff,stroke:#909,stroke-width:1px
    classDef external fill:#f0f0f0,stroke:#666,stroke-width:1px
    classDef utils fill:#ffffe0,stroke:#cc0,stroke-width:1px
```
