# yurirn/eco-admin-vista architecture

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

- Interactive diagram: https://gitdiagram.com/yurirn/eco-admin-vista
- Repository: https://github.com/yurirn/eco-admin-vista

## Overview

##### Main Components
a. User Interface (UI) Layer:
- Pages: Represent entry points to different application views (e.g., Login, Dashboard, Products, IngresoMercancia, Curvas, NotFound).
- Components: All the reusable UI and layout components, found under src/components. This includes both functional components (like DashboardHeader, DashboardSidebar) and UI widgets built with shadcn-ui (buttons, alerts, modals, etc.).
b. API Layer:
- API Modules: Under src/api, these files (api.ts, apiConfig.ts, categoriesApi.ts, productApi.ts, productsApi.ts, websitesApi.ts, etc.) encapsulate HTTP interactions, configuration, and type definitions.
c. State Management & Context:
- Context: For instance, the AuthContext (src/contexts/AuthContext.tsx) which likely manages authentication or session state across the application.
- Hooks: Custom hooks (src/hooks) such as useCurvasApi, useIngresoMercanciaApi, use-mobile, and use-toast, which abstract common logic and API interactions.
d. Utility & Library Components:
- Utility Functions: Found under src/lib and src/utils, which provide helper functions for various parts of the app.
e. Configuration & Build Tools:
- Tools: Vite configuration (vite.config.ts), TypeScript configurations (tsconfig.json, tsconfig.app.json, etc.), and Tailwind CSS config (tailwind.config.ts) outline the build and styling processes.
f. Public Assets: The static files (index.html, public folder) that serve as entry points and static resource directories.

##### Out Relationships and Interactions
- The main App (src/App.tsx) is likely the central entry point where routing is defined. From here, different pages are loaded based on the route.
- The pages rely on reusable components and leverage React’s routing with components like ProtectedRoute. Sketch out how the Dashboard, Login, Products, and other pages fit together.
- Utility functions and helper libraries complement the UI components by providing reusability and code logic without being a separate “runtime” layer; indicate these as supporting modules.

##### Architectural Patterns & Design Principles
- Componentization: The project adheres to a clean separation of concerns by separating UI components, pages, API calls, hooks, and contexts.
- Separation of Concerns: Clearly distinct layers for presentation (React components/pages), business logic (custom hooks and contexts), and data interactions (API modules).
- Reusability: Use of centralized UI libraries (shadcn-ui) and well-organized utility functions make the design modular and easily testable.
- Dependency Injection: Although not explicitly stated, the use of API configuration and context suggests a pattern where external services can be abstracted or injected.

## Diagram (Mermaid)

```mermaid
flowchart TD 
    %% Top Level Components
    App["Main App Container (src/App.tsx, src/main.tsx)"]:::app
    UILayer["UI Layer"]:::uiLayer
    API["API Service Layer"]:::api
    StateMgmt["State Management & Hooks"]:::state
    Util["Utility & Library Functions"]:::utils
    Build["Build & Configuration Tools"]:::build
    Public["Public Assets"]:::public

    %% UI Layer Submodules
    subgraph "UI Layer"
        Pages["Pages (src/pages)"]:::pages
        Reusable["Reusable Components (src/components)"]:::components
        UIToolkit["UI Toolkit - shadcn-ui (src/components/ui)"]:::uiToolkit
    end

    %% State Management Submodules
    subgraph "State Management & Hooks"
        AuthCtx["Auth Context (src/contexts/AuthContext.tsx)"]:::context
        Hooks["Custom Hooks (src/hooks)"]:::hooks
    end

    %% Build & Configuration Submodules
    subgraph "Build & Configuration Tools"
        Vite["Vite Config (vite.config.ts)"]:::config
        Tailwind["Tailwind Config (tailwind.config.ts)"]:::config
        TSConfig["TypeScript Config (tsconfig*.json)"]:::config
        OtherConf["Other Configs (package.json, postcss.config.js, eslint.config.js)"]:::config
    end

    %% Utility Layers Submodules
    subgraph "Utility Layers"
        Lib["Lib Functions (src/lib)"]:::utils
        Utils["Other Utils (src/utils)"]:::utils
    end

    %% Connections
    App -->|"defines routing"| Pages
    App -->|"defines routing"| Reusable
    App -->|"defines routing"| UIToolkit

    Pages -->|"HTTP calls/API requests"| API
    Reusable -->|"HTTP interactions"| API
    Reusable -->|"Uses Authentication"| AuthCtx
    Reusable -->|"Leverages custom logic"| Hooks
    UIToolkit -->|"Composes UI elements"| Reusable

    AuthCtx -->|"Provides auth state"| Pages
    Hooks -->|"Manages API interactions"| API

    Lib -->|"Support functions"| Reusable
    Utils -->|"Helper utilities"| Reusable

    Build -->|"Bundles and compiles"| App
    Public -->|"Serves static assets"| App

    %% Styles
    classDef app fill:#f9c,stroke:#333,stroke-width:2px;
    classDef uiLayer fill:#bbf,stroke:#333,stroke-width:2px;
    classDef pages fill:#ddf,stroke:#333,stroke-width:2px;
    classDef components fill:#cfc,stroke:#333,stroke-width:2px;
    classDef uiToolkit fill:#fcf,stroke:#333,stroke-width:2px;
    classDef api fill:#fdd,stroke:#333,stroke-width:2px;
    classDef state fill:#ffd,stroke:#333,stroke-width:2px;
    classDef context fill:#efe,stroke:#333,stroke-width:2px;
    classDef hooks fill:#eef,stroke:#333,stroke-width:2px;
    classDef utils fill:#ffe,stroke:#333,stroke-width:2px;
    classDef config fill:#def,stroke:#333,stroke-width:2px;
    classDef build fill:#def,stroke:#333,stroke-width:2px;
    classDef public fill:#fed,stroke:#333,stroke-width:2px;

    %% Click Events for Component Mapping
    click Pages "https://github.com/yurirn/eco-admin-vista/tree/main/src/pages"
    click Reusable "https://github.com/yurirn/eco-admin-vista/tree/main/src/components"
    click UIToolkit "https://github.com/yurirn/eco-admin-vista/tree/main/src/components/ui"
    click API "https://github.com/yurirn/eco-admin-vista/tree/main/src/api"
    click AuthCtx "https://github.com/yurirn/eco-admin-vista/blob/main/src/contexts/AuthContext.tsx"
    click Hooks "https://github.com/yurirn/eco-admin-vista/tree/main/src/hooks"
    click Lib "https://github.com/yurirn/eco-admin-vista/tree/main/src/lib"
    click Utils "https://github.com/yurirn/eco-admin-vista/tree/main/src/utils"
    click Vite "https://github.com/yurirn/eco-admin-vista/blob/main/vite.config.ts"
    click Tailwind "https://github.com/yurirn/eco-admin-vista/blob/main/tailwind.config.ts"
    click TSConfig "https://github.com/yurirn/eco-admin-vista/blob/main/tsconfig.json"
    click OtherConf "https://github.com/yurirn/eco-admin-vista/blob/main/package.json"
    click App "https://github.com/yurirn/eco-admin-vista/blob/main/src/App.tsx"
    click App "https://github.com/yurirn/eco-admin-vista/blob/main/src/main.tsx"
    click Public "https://github.com/yurirn/eco-admin-vista/tree/main/public"
```
