# mohitnamdev22/shelfsmart-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/mohitnamdev22/shelfsmart-frontend
- Repository: https://github.com/mohitnamdev22/shelfsmart-frontend

## Overview

##### Main Components
- Client-Side Application (ShelfSmart Frontend)
- Routing & Page Components:
- Pages: Dashboard, Inventory, Login, Registration, Report, Suppliers, UserActivity – Each representing a separate view of the system.
- UI Components:
- Common components like Navbar, Sidebar, Layout, AIAccordion, and Skeleton which are reused across the pages.
- Assets & Static Files:
- Entry Points & Configurations:
- main.jsx and App.jsx: The starting point of the application and routing configuration.
- Configuration files (tailwind.config.js, vite.config.js, eslint.config.js) that set up project-specific tooling.

##### Relationships and Interactions
- The user interacts with the application UI (components like Navbar, Sidebar, and various pages).
- The App.jsx file manages routing between the different pages (using React Router).
- Pages communicate with the backend API via an API client (Axios), which uses the base URL defined in the environment variable (VITE_API_URL).
- Shared components (e.g., Layout) wrap pages to provide a consistent look and navigational structure.
- Data flows from the backend (handling inventory, user authentication, reports) into UI components for rendering, while user actions (like login, add/edit inventory) generate API calls.

##### Architectural Patterns and Design Principles
- Single Page Application (SPA): The application dynamically updates the UI without full page reloads.
- Component-Based Architecture: Components are grouped into reusable UI elements (under “src/components”) and page-specific components (under “src/pages”).
- Separation of Concerns: Clear delineation between static files (public) and application logic (src folder), plus build and configuration files at the root.
- Responsive and Modular Design: Use of Tailwind CSS and components promotes a responsive, modular approach.

##### Relevant Technologies, Frameworks, and Libraries
- React & React Router for building the SPA and handling routing.
- Vite for rapid development and build tooling.
- Tailwind CSS for styling.
- Axios for API requests.
- Chart.js (via react-chartjs-2) for generating charts in the Dashboard.
- React-Toastify for notifications.
- React-Select for dropdowns and enhanced select elements.
- PapaParse for CSV parsing tasks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User Interaction"]:::user

    subgraph "Entry Points"
        A1["Entry Point (main.jsx)"]:::entry
        A2["App Component & Routing (App.jsx)"]:::entry
    end

    subgraph "Pages"
        P1["Dashboard Page"]:::page
        P2["Inventory Page"]:::page
        P3["Login Page"]:::page
        P4["Registration Page"]:::page
        P5["Report Page"]:::page
        P6["Suppliers Page"]:::page
        P7["UserActivity Page"]:::page
    end

    subgraph "Shared UI Components"
        S1["Layout"]:::shared
        S2["Navbar"]:::shared
        S3["Sidebar"]:::shared
        S4["AIAccordion"]:::shared
        S5["Skeleton"]:::shared
    end

    subgraph "Infrastructure"
        I1["Static Assets (Public)"]:::asset
        I2["API Client (Axios with VITE_API_URL)"]:::external
    end

    %% Connections for Entry Points and Routing
    U -->|"initiates"| A1
    A1 -->|"loads"| A2

    %% Connect App Routing to Shared Layout and Pages
    A2 -->|"renders"| S1
    S1 -->|"wraps"| P1
    S1 -->|"wraps"| P2
    S1 -->|"wraps"| P3
    S1 -->|"wraps"| P4
    S1 -->|"wraps"| P5
    S1 -->|"wraps"| P6
    S1 -->|"wraps"| P7

    %% Shared UI Components composition
    S1 -->|"includes"| S2
    S1 -->|"includes"| S3
    S1 -->|"includes"| S4
    S1 -->|"includes"| S5

    %% Static Assets used by layout
    I1 -->|"assetsUsed"| S1

    %% Data flow between Pages and API Client
    P1 -->|"request"| I2
    P2 -->|"request"| I2
    P3 -->|"request"| I2
    P4 -->|"request"| I2
    P5 -->|"request"| I2
    P6 -->|"request"| I2
    P7 -->|"request"| I2

    I2 -->|"response"| P1
    I2 -->|"response"| P2
    I2 -->|"response"| P3
    I2 -->|"response"| P4
    I2 -->|"response"| P5
    I2 -->|"response"| P6
    I2 -->|"response"| P7

    %% Click Events
    click A1 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/main.jsx"
    click A2 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/App.jsx"
    click P1 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/pages/Dashboard.jsx"
    click P2 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/pages/Inventory.jsx"
    click P3 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/pages/Login.jsx"
    click P4 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/pages/Registration.jsx"
    click P5 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/pages/Report.jsx"
    click P6 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/pages/Suppliers.jsx"
    click P7 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/pages/UserActivity.jsx"
    click S4 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/components/AIAccordion.jsx"
    click S1 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/components/Layout.jsx"
    click S2 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/components/Navbar.jsx"
    click S3 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/components/Sidebar.jsx"
    click S5 "https://github.com/mohitnamdev22/shelfsmart-frontend/blob/main/src/components/Skeleton.jsx"
    click I1 "https://github.com/mohitnamdev22/shelfsmart-frontend/tree/main/public"

    %% Styles
    classDef entry fill:#f9d423,stroke:#333,stroke-width:2px;
    classDef page fill:#f59e42,stroke:#333,stroke-width:2px;
    classDef shared fill:#8ee4af,stroke:#333,stroke-width:2px;
    classDef asset fill:#a1c4fd,stroke:#333,stroke-width:2px;
    classDef external fill:#ff9a9e,stroke:#333,stroke-width:2px;
    classDef user fill:#d4a5a5,stroke:#333,stroke-width:2px;
```
