# adriankiv/stockflow architecture

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

- Interactive diagram: https://gitdiagram.com/adriankiv/stockflow
- Repository: https://github.com/adriankiv/stockflow

## Overview

StockFlow is a mini inventory-and-sales app: warehouse staff manage products and stock, inspect movement history, and create or cancel orders that consume or restore stock. The principal path is React UI → Go API → PostgreSQL, with separate product and order operations and a stock-movement ledger. The README documents transactional stock behavior and schema capabilities; source excerpts show frontend component calls and API route registration. Backend handler-to-storage details are not excerpted, so those documented data relationships are cited to the README.

Main entry points: [`frontend/src/App.tsx`](https://github.com/adriankiv/stockflow/blob/main/frontend/src/App.tsx) (Inventory dashboard), [`backend/cmd/api/main.go`](https://github.com/adriankiv/stockflow/blob/main/backend/cmd/api/main.go) (API server), [`frontend/src/api/client.ts`](https://github.com/adriankiv/stockflow/blob/main/frontend/src/api/client.ts) (API client), [`frontend/src/utils.ts`](https://github.com/adriankiv/stockflow/blob/main/frontend/src/utils.ts) (Input validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Inventory UI"]
  node_entry["React entry<br/>[main.tsx]"]
  node_app["Inventory dashboard<br/>[App.tsx]"]
  node_products_ui["Product table<br/>[tproduct.tsx]"]
  node_summary_ui["Summary cards<br/>[sumcard.tsx]"]
  node_adjust_ui["Stock adjustment<br/>[adjuststock.tsx]"]
  node_movement_ui["Movement history<br/>[movements.tsx]"]
  node_orders_ui["Order panel<br/>[orderp.tsx]"]
  node_client["API client<br/>[client.ts]"]
  node_api_types["API data types<br/>[types.ts]"]
  node_validation["Input validation<br/>[utils.ts]"]
end

subgraph group_api["Go API"]
  node_server["API server<br/>[main.go]"]
  node_cors["CORS middleware<br/>[cors.go]"]
  node_product_ops["Product operations"]
  node_order_ops["Order operations<br/>[orders_handler.go]"]
  node_db_config["Database connection<br/>[db.go]"]
  node_db_runtime["Migration runner<br/>[migrate.go]"]
end

subgraph group_data["Inventory Data"]
  node_migrations["Schema and seed"]
  node_postgres[("PostgreSQL")]
end

node_staff(("Warehouse staff"))

node_staff -->|"uses"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"renders"| node_products_ui
node_app -->|"renders"| node_summary_ui
node_app -->|"renders"| node_adjust_ui
node_app -->|"renders"| node_movement_ui
node_app -->|"renders"| node_orders_ui
node_app -->|"requests"| node_client
node_products_ui -->|"formats with"| node_validation
node_summary_ui -->|"formats with"| node_validation
node_adjust_ui -->|"submits adjustment"| node_client
node_adjust_ui -->|"validates with"| node_validation
node_movement_ui -->|"loads history"| node_client
node_orders_ui -->|"submits orders"| node_client
node_orders_ui -->|"validates with"| node_validation
node_client -->|"HTTP requests"| node_server
node_server -->|"registers"| node_cors
node_server -->|"routes products"| node_product_ops
node_server -->|"routes orders"| node_order_ops
node_server -->|"connects"| node_db_config
node_server -->|"runs migrations"| node_db_runtime
node_db_runtime -->|"applies"| node_migrations
node_db_config -->|"connects"| node_postgres
node_product_ops -->|"reads and writes"| node_postgres
node_order_ops -->|"transactional writes"| node_postgres

click node_entry "https://github.com/adriankiv/stockflow/blob/main/frontend/src/main.tsx"
click node_app "https://github.com/adriankiv/stockflow/blob/main/frontend/src/App.tsx"
click node_products_ui "https://github.com/adriankiv/stockflow/blob/main/frontend/src/components/tproduct.tsx"
click node_summary_ui "https://github.com/adriankiv/stockflow/blob/main/frontend/src/components/sumcard.tsx"
click node_adjust_ui "https://github.com/adriankiv/stockflow/blob/main/frontend/src/components/adjuststock.tsx"
click node_movement_ui "https://github.com/adriankiv/stockflow/blob/main/frontend/src/components/movements.tsx"
click node_orders_ui "https://github.com/adriankiv/stockflow/blob/main/frontend/src/components/orderp.tsx"
click node_client "https://github.com/adriankiv/stockflow/blob/main/frontend/src/api/client.ts"
click node_api_types "https://github.com/adriankiv/stockflow/blob/main/frontend/src/api/types.ts"
click node_validation "https://github.com/adriankiv/stockflow/blob/main/frontend/src/utils.ts"
click node_server "https://github.com/adriankiv/stockflow/blob/main/backend/cmd/api/main.go"
click node_cors "https://github.com/adriankiv/stockflow/blob/main/backend/internal/middleware/cors.go"
click node_product_ops "https://github.com/adriankiv/stockflow/blob/main/backend/internal/handler/products_handler.go"
click node_order_ops "https://github.com/adriankiv/stockflow/blob/main/backend/internal/handler/orders_handler.go"
click node_db_config "https://github.com/adriankiv/stockflow/blob/main/backend/internal/config/db.go"
click node_migrations "https://github.com/adriankiv/stockflow/tree/main/backend/migrations"
click node_db_runtime "https://github.com/adriankiv/stockflow/blob/main/backend/internal/database/migrate.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_app,node_products_ui,node_summary_ui,node_adjust_ui,node_movement_ui,node_orders_ui,node_client,node_api_types,node_validation toneBlue
class node_server,node_cors,node_product_ops,node_order_ops,node_db_config,node_db_runtime toneAmber
class node_migrations,node_postgres toneMint
class node_staff toneIndigo
```

## Components

### Inventory UI

- [React entry](https://github.com/adriankiv/stockflow/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Inventory dashboard](https://github.com/adriankiv/stockflow/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Product table](https://github.com/adriankiv/stockflow/blob/main/frontend/src/components/tproduct.tsx): `frontend/src/components/tproduct.tsx`
- [Summary cards](https://github.com/adriankiv/stockflow/blob/main/frontend/src/components/sumcard.tsx): `frontend/src/components/sumcard.tsx`
- [Stock adjustment](https://github.com/adriankiv/stockflow/blob/main/frontend/src/components/adjuststock.tsx): `frontend/src/components/adjuststock.tsx`
- [Movement history](https://github.com/adriankiv/stockflow/blob/main/frontend/src/components/movements.tsx): `frontend/src/components/movements.tsx`
- [Order panel](https://github.com/adriankiv/stockflow/blob/main/frontend/src/components/orderp.tsx): `frontend/src/components/orderp.tsx`
- [API client](https://github.com/adriankiv/stockflow/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [API data types](https://github.com/adriankiv/stockflow/blob/main/frontend/src/api/types.ts): `frontend/src/api/types.ts`
- [Input validation](https://github.com/adriankiv/stockflow/blob/main/frontend/src/utils.ts): `frontend/src/utils.ts`

### Go API

- [API server](https://github.com/adriankiv/stockflow/blob/main/backend/cmd/api/main.go): `backend/cmd/api/main.go`
- [CORS middleware](https://github.com/adriankiv/stockflow/blob/main/backend/internal/middleware/cors.go): `backend/internal/middleware/cors.go`
- [Product operations](https://github.com/adriankiv/stockflow/blob/main/backend/internal/handler/products_handler.go): `backend/internal/handler/products_handler.go`
- [Order operations](https://github.com/adriankiv/stockflow/blob/main/backend/internal/handler/orders_handler.go): `backend/internal/handler/orders_handler.go`
- [Database connection](https://github.com/adriankiv/stockflow/blob/main/backend/internal/config/db.go): `backend/internal/config/db.go`
- [Migration runner](https://github.com/adriankiv/stockflow/blob/main/backend/internal/database/migrate.go): `backend/internal/database/migrate.go`

### Inventory Data

- [Schema and seed](https://github.com/adriankiv/stockflow/tree/main/backend/migrations): `backend/migrations`
- **PostgreSQL**

### Other components

- **Warehouse staff**

## Connections

- Warehouse staff → React entry: uses (evidence: `README.md`)
- React entry → Inventory dashboard: renders (evidence: `frontend/src/main.tsx`)
- Inventory dashboard → Product table: renders (evidence: `frontend/src/App.tsx`)
- Inventory dashboard → Summary cards: renders (evidence: `frontend/src/App.tsx`)
- Inventory dashboard → Stock adjustment: renders (evidence: `frontend/src/App.tsx`)
- Inventory dashboard → Movement history: renders (evidence: `frontend/src/App.tsx`)
- Inventory dashboard → Order panel: renders (evidence: `frontend/src/App.tsx`)
- Inventory dashboard → API client: requests (evidence: `frontend/src/App.tsx`)
- Product table → Input validation: formats with (evidence: `frontend/src/utils.ts`)
- Summary cards → Input validation: formats with (evidence: `frontend/src/components/sumcard.tsx`)
- Stock adjustment → API client: submits adjustment (evidence: `frontend/src/components/adjuststock.tsx`)
- Stock adjustment → Input validation: validates with (evidence: `frontend/src/components/adjuststock.tsx`)
- Movement history → API client: loads history (evidence: `frontend/src/components/movements.tsx`)
- Order panel → API client: submits orders (evidence: `frontend/src/components/orderp.tsx`)
- Order panel → Input validation: validates with (evidence: `frontend/src/components/orderp.tsx`)
- API client → API server: HTTP requests (evidence: `README.md`)
- API server → CORS middleware: registers (evidence: `backend/cmd/api/main.go`)
- API server → Product operations: routes products (evidence: `backend/cmd/api/main.go`)
- API server → Order operations: routes orders (evidence: `backend/cmd/api/main.go`)
- API server → Database connection: connects (evidence: `backend/cmd/api/main.go`)
- API server → Migration runner: runs migrations (evidence: `backend/cmd/api/main.go`)
- Migration runner → Schema and seed: applies (evidence: `README.md`)
- Database connection → PostgreSQL: connects (evidence: `README.md`)
- Product operations → PostgreSQL: reads and writes (evidence: `README.md`)
- Order operations → PostgreSQL: transactional writes (evidence: `README.md`)
