# maxi2771/nexoinventory architecture

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

- Interactive diagram: https://gitdiagram.com/maxi2771/nexoinventory
- Repository: https://github.com/maxi2771/nexoinventory

## Overview

##### Project type and purpose
- NexoInventory is a full-stack, single-page web application for real-time inventory management.
- Built with React (Vite) on the front end and Supabase (PostgreSQL + Auth + real-time APIs) on the back end.

##### File structure
- Top-level:
- src/ — front-end application code
- src/pages/ — route-level components (Dashboard, Login, Productos, Movimientos)
- src/components/ — reusable UI components (tables, modals, charts, forms)
- src/Contexts/ — React Context providers for global state (User, Productos, Movimientos)
- src/services/ — integration with Supabase (supabaseClient.js)
- config files: vite.config.js, tailwind.config.js, eslint.config.js
- Deployment: docs/ serves production build (Netlify continuous deployment)

##### Key insights from the README
- Uses React Router for client-side navigation with protected routes
- Context API + custom hooks (useFetch) manage data fetching and state
- Formik + Yup handle form state and validation
- Chart.js (via react-chartjs-2) for interactive charts on the Dashboard
- Supabase provides authentication, real-time data updates, and PostgreSQL storage
- Server-side pagination and filtering against the Supabase DB

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (React)"
        subgraph "UI Layer"
            Browser["Browser / Client (React SPA)"]:::ui
            Router["React Router"]:::ui
            PrivateRoute["PrivateRoute"]:::ui
            subgraph "Pages"
                Dashboard["Dashboard.jsx"]:::ui
                Login["Login.jsx"]:::ui
                ProductosPage["Productos.jsx"]:::ui
                MovimientosPage["Movimientos.jsx"]:::ui
            end
            subgraph "Components"
                Btn["Btn.jsx"]:::ui
                CardStat["CardStat.jsx"]:::ui
                DropdownBtn["DropdownButton.jsx"]:::ui
                Header["Header.jsx"]:::ui
                Layout["Layout.jsx"]:::ui
                Menu["Menu.jsx"]:::ui
                Modal["Modal.jsx"]:::ui
                PieChart["PieChart.jsx"]:::ui
                ProductForm["ProductForm.jsx"]:::ui
                SearchBar["SearchBar.jsx"]:::ui
                StockAlerts["StockAlerts.jsx"]:::ui
                StockIndicator["StockIndicator.jsx"]:::ui
                Table["Table.jsx"]:::ui
                TopProductsChart["TopProductsChart.jsx"]:::ui
                FormikYup["Formik + Yup"]:::ui
                ChartJS["Chart.js (react-chartjs-2)"]:::ui
                Tailwind["Tailwind CSS"]:::ui
            end
        end
        subgraph "State Layer"
            UserContext["UserContext.jsx"]:::state
            ProductosContext["ProductosContext.jsx"]:::state
            MovimientosContext["MovimientosContext.jsx"]:::state
            useFetch["useFetch.jsx"]:::state
        end
        subgraph "Service Layer"
            SupabaseClient["supabaseClient.js"]:::service
        end
    end

    subgraph "Backend as a Service"
        Auth["Supabase Auth"]:::external
        DB[(PostgreSQL + Realtime)]:::external
    end

    subgraph "Build & Deploy"
        Vite["Vite Dev Server\nvite.config.js"]:::config
        Docs["docs/ (Static CDN)"]:::config
    end

    %% Flows
    Browser --> Router
    Router --> Login
    Router --> PrivateRoute
    PrivateRoute --> Dashboard
    PrivateRoute --> ProductosPage
    PrivateRoute --> MovimientosPage
    Dashboard -->|"renders charts"| ChartJS
    Dashboard -->|"uses data"| ProductosContext
    Dashboard -->|"uses data"| MovimientosContext
    ProductosPage -->|"CRUD forms"| ProductForm
    ProductForm --> FormikYup
    ProductosPage --> ProductosContext
    MovimientosPage --> MovimientosContext
    Table --> ProductosContext
    PieChart --> ProductosContext
    TopProductsChart --> ProductosContext
    SearchBar --> ProductosContext
    StockAlerts --> UserContext
    Login --> UserContext

    UserContext --> SupabaseClient
    ProductosContext --> SupabaseClient
    MovimientosContext --> SupabaseClient
    useFetch --> SupabaseClient

    SupabaseClient --> Auth
    SupabaseClient --> DB
    SupabaseClient <-->|Realtime subscriptions| DB

    Vite --> Browser
    Docs --> Browser

    %% Click Events
    click Browser "https://github.com/maxi2771/nexoinventory/blob/main/src/main.jsx"
    click Browser "https://github.com/maxi2771/nexoinventory/blob/main/index.html"
    click Vite "https://github.com/maxi2771/nexoinventory/blob/main/vite.config.js"
    click Docs "https://github.com/maxi2771/nexoinventory/tree/main/docs/"
    click Router "https://github.com/maxi2771/nexoinventory/blob/main/src/App.jsx"
    click PrivateRoute "https://github.com/maxi2771/nexoinventory/blob/main/src/routes/PrivateRoute.jsx"
    click Dashboard "https://github.com/maxi2771/nexoinventory/blob/main/src/pages/Dashboard.jsx"
    click Login "https://github.com/maxi2771/nexoinventory/blob/main/src/pages/Login.jsx"
    click ProductosPage "https://github.com/maxi2771/nexoinventory/blob/main/src/pages/Productos.jsx"
    click MovimientosPage "https://github.com/maxi2771/nexoinventory/blob/main/src/pages/Movimientos.jsx"
    click Btn "https://github.com/maxi2771/nexoinventory/blob/main/src/components/Btn.jsx"
    click CardStat "https://github.com/maxi2771/nexoinventory/blob/main/src/components/CardStat.jsx"
    click DropdownBtn "https://github.com/maxi2771/nexoinventory/blob/main/src/components/DropdownButton .jsx"
    click Header "https://github.com/maxi2771/nexoinventory/blob/main/src/components/Header.jsx"
    click Layout "https://github.com/maxi2771/nexoinventory/blob/main/src/components/Layout.jsx"
    click Menu "https://github.com/maxi2771/nexoinventory/blob/main/src/components/Menu.jsx"
    click Modal "https://github.com/maxi2771/nexoinventory/blob/main/src/components/Modal.jsx"
    click PieChart "https://github.com/maxi2771/nexoinventory/blob/main/src/components/PieChart.jsx"
    click ProductForm "https://github.com/maxi2771/nexoinventory/blob/main/src/components/ProductForm.jsx"
    click SearchBar "https://github.com/maxi2771/nexoinventory/blob/main/src/components/SearchBar.jsx"
    click StockAlerts "https://github.com/maxi2771/nexoinventory/blob/main/src/components/StockAlerts.jsx"
    click StockIndicator "https://github.com/maxi2771/nexoinventory/blob/main/src/components/StockIndicator.jsx"
    click Table "https://github.com/maxi2771/nexoinventory/blob/main/src/components/Table.jsx"
    click TopProductsChart "https://github.com/maxi2771/nexoinventory/blob/main/src/components/TopProductsChart.jsx"
    click UserContext "https://github.com/maxi2771/nexoinventory/blob/main/src/Contexts/UserContext.jsx"
    click ProductosContext "https://github.com/maxi2771/nexoinventory/blob/main/src/Contexts/ProductosContext.jsx"
    click MovimientosContext "https://github.com/maxi2771/nexoinventory/blob/main/src/Contexts/MovimientosContext.jsx"
    click useFetch "https://github.com/maxi2771/nexoinventory/blob/main/src/Contexts/hooks/useFetch.jsx"
    click SupabaseClient "https://github.com/maxi2771/nexoinventory/blob/main/src/services/supabaseClient.js"
    click Tailwind "https://github.com/maxi2771/nexoinventory/blob/main/tailwind.config.js"
    click FormikYup "https://github.com/maxi2771/nexoinventory/blob/main/eslint.config.js"

    classDef ui fill:#cce5ff,stroke:#339af0
    classDef state fill:#d4f5d4,stroke:#28a745
    classDef service fill:#ffe5b4,stroke:#f0a500
    classDef external fill:#e2e2e2,stroke:#999
    classDef config fill:#fff3bf,stroke:#f59f00
```
