# amrualyan/inventory-system architecture

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

- Interactive diagram: https://gitdiagram.com/amrualyan/inventory-system
- Repository: https://github.com/amrualyan/inventory-system

## Overview

##### Project type and purpose
- This is a single-page administrative dashboard built with React and Vite.
- Its purpose is to let Admins and Managers manage products, categories, budgets, reports, and user profiles.
- It relies entirely on Firebase (Authentication, Firestore or Realtime Database, possibly Storage) as its backend.

##### File structure
- Top-level:
- package.json, vite.config.js, index.html – define the build setup with Vite and React.
- src/main.jsx – application entry point.
- src/components – reusable UI widgets (Header, Sidebar, ContentArea, ProtectedRoute, etc.).
- src/pages – route components organized by role (Admin, Manager) and public pages (Login, Signup, Root).
- src/layouts – layout wrappers for AdminLayout and ManagerLayout.
- src/context – global state via AuthContext for user & authentication data.
- src/firebase & src/firebase.js – Firebase initialization and exports of auth, database, etc.
- src/hooks – custom hooks (useAuth to access context, useIsMobile for responsive behavior).
- src/styles & src/assets – CSS files and images used by components.

##### README for additional insights
- Confirms minimal React + Vite setup with ESLint and Fast Refresh plugins.
- No custom backend—Firebase is the de facto serverless layer.

## Diagram (Mermaid)

```mermaid
flowchart TB
    Browser["Browser"]:::frontend
    subgraph React_SPA["React SPA"]
        direction TB
        EntryPoint["src/main.jsx"]:::frontend
        AppComp["src/App.jsx"]:::frontend
        subgraph State_Routing["State & Routing"]
            AuthCtx["AuthContext"]:::frontend
            Protected["ProtectedRoute"]:::frontend
        end
        subgraph Hooks["Custom Hooks"]
            HookAuth["useAuth"]:::frontend
            HookMobile["useIsMobile"]:::frontend
        end
        subgraph Layouts["Layouts"]
            AdminLay["AdminLayout"]:::frontend
            ManagerLay["ManagerLayout"]:::frontend
        end
        subgraph Pages["Pages"]
            subgraph Admin_Pages["Admin Pages"]
                AdminProf["AdminProfile"]:::frontend
                BudgetPage["Budget"]:::frontend
                ReportsPage["Reports"]:::frontend
            end
            subgraph Manager_Pages["Manager Pages"]
                ManagerProf["ManagerProfile"]:::frontend
                ProductsPage["Products"]:::frontend
            end
            subgraph Public_Pages["Public & Shared Pages"]
                LoginPage["Login"]:::frontend
                SignupPage["Signup"]:::frontend
                RootPage["Root"]:::frontend
                ProfilePage["Profile"]:::frontend
            end
        end
        subgraph UI_Components["UI Components"]
            Header["Header"]:::frontend
            Sidebar["Sidebar"]:::frontend
            ContentArea["ContentArea"]:::frontend
            Inventory["Inventory"]:::frontend
            AddCat["AddCategory"]:::frontend
            AddProd["AddProductWidget"]:::frontend
            SeedProd["SeedProductComponent"]:::frontend
            CustomBar["CustomBar"]:::frontend
            ThemeSwitch["ThemeSwitch"]:::frontend
            ProfileWidget["Profile Widget"]:::frontend
            ReauthModal["ReauthModal"]:::frontend
            ScrollTop["ScrollToTop"]:::frontend
        end
    end

    ViteDev["Vite Dev Server"]:::dev
    StaticHost["Static Host"]:::dev

    subgraph Firebase_Init["Firebase Initialization"]
        FirebaseInit1["src/firebase.js"]:::firebase
        FirebaseInit2["src/firebase/firebase.js"]:::firebase
    end
    FirebaseAuth["Firebase Auth"]:::firebase
    FirebaseDB["Firebase Database"]:::firebase
    FirebaseStorage["Firebase Storage"]:::firebase

    %% Connections
    Browser -->|loads assets| EntryPoint
    Browser -->|serves assets| ViteDev
    Browser -->|serves assets| StaticHost
    EntryPoint -->|bootstraps| AppComp
    AppComp -->|provides| AuthCtx
    AppComp -->|wraps routes| Protected
    AuthCtx -->|auth calls| FirebaseAuth
    Protected -->|guards| Pages
    HookAuth -->|used by| AuthCtx
    HookMobile -->|used by| UI_Components
    AdminLay -->|wraps| Admin_Pages
    ManagerLay -->|wraps| Manager_Pages
    Pages -->|render| UI_Components
    Pages -->|db ops| FirebaseDB
    UI_Components -->|storage ops| FirebaseStorage
    FirebaseInit1 -->|configures| FirebaseAuth
    FirebaseInit1 -->|configures| FirebaseDB
    FirebaseInit1 -->|configures| FirebaseStorage
    FirebaseInit2 -->|configures| FirebaseAuth
    FirebaseInit2 -->|configures| FirebaseDB
    FirebaseInit2 -->|configures| FirebaseStorage

    %% Click Events
    click EntryPoint "https://github.com/amrualyan/inventory-system/blob/main/src/main.jsx"
    click AppComp "https://github.com/amrualyan/inventory-system/blob/main/src/App.jsx"
    click ViteDev "https://github.com/amrualyan/inventory-system/blob/main/vite.config.js"
    click StaticHost "https://github.com/amrualyan/inventory-system/blob/main/index.html"
    click FirebaseInit1 "https://github.com/amrualyan/inventory-system/blob/main/src/firebase.js"
    click FirebaseInit2 "https://github.com/amrualyan/inventory-system/blob/main/src/firebase/firebase.js"
    click AuthCtx "https://github.com/amrualyan/inventory-system/blob/main/src/context/AuthContext.jsx"
    click Protected "https://github.com/amrualyan/inventory-system/blob/main/src/components/ProtectedRoute.jsx"
    click HookAuth "https://github.com/amrualyan/inventory-system/blob/main/src/hooks/useAuth.js"
    click HookMobile "https://github.com/amrualyan/inventory-system/blob/main/src/hooks/useIsMobile.js"
    click AdminLay "https://github.com/amrualyan/inventory-system/blob/main/src/layouts/AdminLayout.jsx"
    click ManagerLay "https://github.com/amrualyan/inventory-system/blob/main/src/layouts/ManagerLayout.jsx"
    click AdminProf "https://github.com/amrualyan/inventory-system/blob/main/src/pages/Admin/AdminProfile.jsx"
    click BudgetPage "https://github.com/amrualyan/inventory-system/blob/main/src/pages/Admin/Budget.jsx"
    click ReportsPage "https://github.com/amrualyan/inventory-system/blob/main/src/pages/Admin/Reports.jsx"
    click ManagerProf "https://github.com/amrualyan/inventory-system/blob/main/src/pages/Manager/ManagerProfile.jsx"
    click ProductsPage "https://github.com/amrualyan/inventory-system/blob/main/src/pages/Manager/Products.jsx"
    click LoginPage "https://github.com/amrualyan/inventory-system/blob/main/src/pages/Login.jsx"
    click SignupPage "https://github.com/amrualyan/inventory-system/blob/main/src/pages/Signup.jsx"
    click RootPage "https://github.com/amrualyan/inventory-system/blob/main/src/pages/Root.jsx"
    click ProfilePage "https://github.com/amrualyan/inventory-system/blob/main/src/pages/Profile.jsx"
    click Header "https://github.com/amrualyan/inventory-system/blob/main/src/components/Header.jsx"
    click Sidebar "https://github.com/amrualyan/inventory-system/blob/main/src/components/Sidebar.jsx"
    click ContentArea "https://github.com/amrualyan/inventory-system/blob/main/src/components/ContentArea.jsx"
    click Inventory "https://github.com/amrualyan/inventory-system/blob/main/src/components/Inventory.jsx"
    click AddCat "https://github.com/amrualyan/inventory-system/blob/main/src/components/AddCategory.jsx"
    click AddProd "https://github.com/amrualyan/inventory-system/blob/main/src/components/AddProductWidget.jsx"
    click SeedProd "https://github.com/amrualyan/inventory-system/blob/main/src/components/SeedProductComponent.jsx"
    click CustomBar "https://github.com/amrualyan/inventory-system/blob/main/src/components/CustomBar.jsx"
    click ThemeSwitch "https://github.com/amrualyan/inventory-system/blob/main/src/components/ThemeSwitch.jsx"
    click ProfileWidget "https://github.com/amrualyan/inventory-system/blob/main/src/components/profileWidget.jsx"
    click ReauthModal "https://github.com/amrualyan/inventory-system/blob/main/src/components/ReauthModal.jsx"
    click ScrollTop "https://github.com/amrualyan/inventory-system/blob/main/src/components/ScrollToTop.jsx"

    %% Styles
    classDef frontend fill:#BBDEFB,stroke:#2196F3
    classDef firebase fill:#C8E6C9,stroke:#388E3C
    classDef dev fill:#FFF9C4,stroke:#FBC02D,stroke-dasharray: 5 5
```
