# weskat/stockmanager architecture

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

- Interactive diagram: https://gitdiagram.com/weskat/stockmanager
- Repository: https://github.com/weskat/stockmanager

## Overview

##### Main Components Identification

a) Frontend Layer:
- Client-Side Components (React/Next.js)
- Pages (/app directory - Next.js App Router)
- UI Components (Shadcn UI library)
- Styling (Tailwind CSS)

b) API Layer:
- Next.js API Routes (/app/api)
- Stock Management Endpoint

c) Data Layer:
- CSV Data Source
- Data Processing Utilities

**┌─────────────────────────────────────────────────────────────┐**
- Client Layer                            │
- ┌─────────────┐  ┌─────────────┐    ┌─────────────┐      │
- Pages     │  │   Layout    │    │     UI      │      │
- Overview │  │  - Header   │    │ Components  │      │
- Home     │  │  - Footer   │    │ (Shadcn UI) │      │
- ┘  └─────────────┘    └─────────────┘      │
- ┘

- ▼                 ▼
**┌─────────────────────────────────────────────────────────────┐**
- API Layer                               │
- ┌─────────────────────────────────────────┐               │
- /api/stock Route              │               │
- ┘               │
- ┘

- ▼
**┌─────────────────────────────────────────────────────────────┐**
- Data Layer                              │
- ┌─────────────┐    ┌─────────────────────────────┐        │
- CSV Data   │ -> │     Data Processing         │        │
- Source     │    │  (convertCsvData.ts,        │        │
- divideProductsInSegments) │        │
- ┘    └─────────────────────────────┘        │
- ┘

##### Important Details

a) Client Layer:
- Next.js App Router structure
- Main pages: Overview and Home
- Component hierarchy with Layout components
- UI component library integration

b) API Layer:
- API route handling stock data
- Connection between client and API

c) Data Layer:
- Demonstrate CSV data flow
- Data transformation utilities

##### Flow Indicators

- Data flow from CSV to API
- API responses to client
- Component relationships
- Data processing pipeline

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Pages --> |renders| Layout
        Pages --> |uses| UIComponents
        Layout --> |uses| UIComponents

        subgraph Pages
            Home["Home Page"]
            Overview["Overview Page"]
            Loading["Loading States"]
        end

        subgraph Layout
            RootLayout["Root Layout"]
            Header["Header"]
            Footer["Footer"]
        end

        subgraph UIComponents
            ShadcnUI["Shadcn UI Components"]
            ProductTable["Product Table"]
            GlobalStyles["Global Styles"]
            CustomFonts["Custom Fonts"]
        end
    end

    subgraph APILayer
        StockAPI["Stock Management API"]
        Pages --> |requests| StockAPI
    end

    subgraph DataLayer
        CsvSource["CSV Data Source"]
        CsvConverter["CSV Data Converter"]
        ProductSegmentation["Product Segmentation"]
        TypeDefs["Product Type Definitions"]

        CsvSource --> |input| CsvConverter
        CsvConverter --> |processes| ProductSegmentation
        TypeDefs --> |types| CsvConverter
    end

    StockAPI --> |reads| DataLayer

    %% Click events for component mapping
    click Home "https://github.com/weskat/StockManager/blob/main/app/page.tsx"
    click Overview "https://github.com/weskat/StockManager/blob/main/app/overview/page.tsx"
    click Header "https://github.com/weskat/StockManager/blob/main/components/layout/Header/Header.tsx"
    click Footer "https://github.com/weskat/StockManager/blob/main/components/layout/Footer/Footer.tsx"
    click RootLayout "https://github.com/weskat/StockManager/blob/main/app/layout.tsx"
    click ShadcnUI "https://github.com/weskat/StockManager/tree/main/components/shadcn/ui/"
    click ProductTable "https://github.com/weskat/StockManager/blob/main/components/ui/ProductTable/ProductTable.tsx"
    click StockAPI "https://github.com/weskat/StockManager/blob/main/app/api/stock/route.ts"
    click CsvSource "https://github.com/weskat/StockManager/blob/main/data/stock-data.csv"
    click CsvConverter "https://github.com/weskat/StockManager/blob/main/lib/convertCsvData.ts"
    click ProductSegmentation "https://github.com/weskat/StockManager/blob/main/lib/divideProductsInSegments.ts"
    click GlobalStyles "https://github.com/weskat/StockManager/blob/main/app/globals.css"
    click CustomFonts "https://github.com/weskat/StockManager/tree/main/styles/fonts/NeueMontreal/"
    click TypeDefs "https://github.com/weskat/StockManager/blob/main/types/Product.type.ts"
    click Loading "https://github.com/weskat/StockManager/blob/main/app/loading.tsx"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef frontend fill:#dbeafe,stroke:#2563eb
    classDef api fill:#dcfce7,stroke:#16a34a
    classDef data fill:#ffedd5,stroke:#ea580c
    
    class Home,Overview,Layout,UIComponents,Header,Footer,RootLayout,ShadcnUI,ProductTable,GlobalStyles,CustomFonts,Loading frontend
    class StockAPI api
    class CsvSource,CsvConverter,ProductSegmentation,TypeDefs data
```
