# youssefshaheen63/smart_inventory_backend architecture

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

- Interactive diagram: https://gitdiagram.com/youssefshaheen63/smart_inventory_backend
- Repository: https://github.com/youssefshaheen63/smart_inventory_backend

## Overview

This is a NestJS, multi-tenant inventory and procurement application, with user and warehouse administration, forecasting, notifications, AI agents, and knowledge-grounded assistance. A representative workflow is an authenticated tenant user managing SKUs, warehouse stock, and purchase orders through API controllers and domain services. The graph also shows the RAG assistant’s documented retrieval and embedding path. Most service internals were not excerpted, so relationships beyond the cited controller calls and RAG implementation are omitted; there is no README content to add further capability details.

Main entry points: [`src/rag/rag.controller.ts`](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/rag/rag.controller.ts) (Knowledge Assistant API), [`src/rag/rag.service.ts`](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/rag/rag.service.ts) (Knowledge Retrieval), [`src/auth/auth.controller.ts`](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/auth/auth.controller.ts) (Auth API), [`src/auth/auth.service.ts`](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/auth/auth.service.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity &amp; Tenancy"]
  node_auth_api["Auth API<br/>[auth.controller.ts]"]
  node_auth_service["Authentication<br/>[auth.service.ts]"]
  node_users["User Management<br/>[users.service.ts]"]
  node_tenants["Tenant Management<br/>[tenants.service.ts]"]
end

subgraph group_operations["Inventory Operations"]
  node_warehouses["Warehouse Management"]
  node_sku_api["SKU Catalog API<br/>[sku.controller.ts]"]
  node_sku_service["SKU Catalog<br/>[sku.service.ts]"]
  node_stock_levels["Stock Levels"]
  node_stock_movements["Stock Movements"]
end

subgraph group_procurement["Procurement &amp; Planning"]
  node_vendors["Vendor Catalog"]
  node_purchase_orders["Purchase Orders"]
  node_forecasts["Forecasting"]
end

subgraph group_intelligence["AI &amp; Knowledge"]
  node_rag_api["Knowledge Assistant API<br/>[rag.controller.ts]"]
  node_rag_service["Knowledge Retrieval<br/>[rag.service.ts]"]
  node_embeddings["Text Embeddings"]
  node_agent_tools["Agent Tools"]
  node_vector_store[("PostgreSQL Vector Store")]
end

subgraph group_communication["Notifications"]
  node_notifications["Notifications"]
end

node_tenant_user(("Tenant User"))

node_tenant_user -->|"authenticates"| node_auth_api
node_auth_api -->|"delegates to"| node_auth_service
node_auth_service -->|"looks up users"| node_users
node_tenant_user -->|"manages SKUs"| node_sku_api
node_sku_api -->|"delegates to"| node_sku_service
node_tenant_user -->|"manages warehouses"| node_warehouses
node_tenant_user -->|"manages stock"| node_stock_levels
node_tenant_user -->|"records movements"| node_stock_movements
node_tenant_user -->|"manages catalog"| node_vendors
node_tenant_user -->|"manages orders"| node_purchase_orders
node_tenant_user -->|"requests forecasts"| node_forecasts
node_tenant_user -->|"asks questions"| node_rag_api
node_rag_api -->|"searches knowledge"| node_rag_service
node_rag_service -->|"embeds text"| node_embeddings
node_rag_service -->|"queries vectors"| node_vector_store
node_rag_api -->|"executes tools"| node_agent_tools

click node_auth_api "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/auth/auth.controller.ts"
click node_auth_service "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/auth/auth.service.ts"
click node_users "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/users/users.service.ts"
click node_tenants "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/tenants/tenants.service.ts"
click node_warehouses "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/warehouses/warehouses.controller.ts"
click node_sku_api "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/sku/sku.controller.ts"
click node_sku_service "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/sku/sku.service.ts"
click node_stock_levels "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/inventory/stock-levels/stock-levels.service.ts"
click node_stock_movements "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/inventory/stock-movements/stock-movement.service.ts"
click node_vendors "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/vendors/vendor-catalog-entries.controller.ts"
click node_purchase_orders "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/purchase-orders/purchase-orders.controller.ts"
click node_forecasts "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/forecasts/forecast.controller.ts"
click node_rag_api "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/rag/rag.controller.ts"
click node_rag_service "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/rag/rag.service.ts"
click node_embeddings "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/rag/embedding.service.ts"
click node_agent_tools "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/agents/tool-executor.service.ts"
click node_notifications "https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/notifications/notifications.service.ts"

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_auth_api,node_auth_service,node_users,node_tenants,node_tenant_user toneBlue
class node_warehouses,node_sku_api,node_sku_service,node_stock_levels,node_stock_movements toneAmber
class node_vendors,node_purchase_orders,node_forecasts toneMint
class node_rag_api,node_rag_service,node_embeddings,node_agent_tools,node_vector_store toneRose
class node_notifications toneIndigo
```

## Components

### Identity & Tenancy

- [Auth API](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Authentication](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [User Management](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/users/users.service.ts): `src/users/users.service.ts`
- [Tenant Management](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/tenants/tenants.service.ts): `src/tenants/tenants.service.ts`

### Inventory Operations

- [Warehouse Management](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/warehouses/warehouses.controller.ts): `src/warehouses/warehouses.controller.ts`
- [SKU Catalog API](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/sku/sku.controller.ts): `src/sku/sku.controller.ts`
- [SKU Catalog](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/sku/sku.service.ts): `src/sku/sku.service.ts`
- [Stock Levels](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/inventory/stock-levels/stock-levels.service.ts): `src/inventory/stock-levels/stock-levels.service.ts`
- [Stock Movements](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/inventory/stock-movements/stock-movement.service.ts): `src/inventory/stock-movements/stock-movement.service.ts`

### Procurement & Planning

- [Vendor Catalog](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/vendors/vendor-catalog-entries.controller.ts): `src/vendors/vendor-catalog-entries.controller.ts`
- [Purchase Orders](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/purchase-orders/purchase-orders.controller.ts): `src/purchase-orders/purchase-orders.controller.ts`
- [Forecasting](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/forecasts/forecast.controller.ts): `src/forecasts/forecast.controller.ts`

### AI & Knowledge

- [Knowledge Assistant API](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/rag/rag.controller.ts): `src/rag/rag.controller.ts`
- [Knowledge Retrieval](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/rag/rag.service.ts): `src/rag/rag.service.ts`
- [Text Embeddings](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/rag/embedding.service.ts): `src/rag/embedding.service.ts`
- [Agent Tools](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/agents/tool-executor.service.ts): `src/agents/tool-executor.service.ts`
- **PostgreSQL Vector Store**

### Notifications

- [Notifications](https://github.com/youssefshaheen63/smart_inventory_backend/blob/main/src/notifications/notifications.service.ts): `src/notifications/notifications.service.ts`

### Other components

- **Tenant User**

## Connections

- Tenant User → Auth API: authenticates
- Auth API → Authentication: delegates to (evidence: `src/auth/auth.service.ts`)
- Authentication → User Management: looks up users (evidence: `src/auth/auth.service.ts`)
- Tenant User → SKU Catalog API: manages SKUs (evidence: `src/sku/sku.controller.ts`)
- SKU Catalog API → SKU Catalog: delegates to (evidence: `src/sku/sku.controller.ts`)
- Tenant User → Warehouse Management: manages warehouses (evidence: `src/warehouses/warehouses.controller.ts`)
- Tenant User → Stock Levels: manages stock
- Tenant User → Stock Movements: records movements
- Tenant User → Vendor Catalog: manages catalog (evidence: `src/vendors/vendor-catalog-entries.controller.ts`)
- Tenant User → Purchase Orders: manages orders (evidence: `src/purchase-orders/purchase-orders.controller.ts`)
- Tenant User → Forecasting: requests forecasts (evidence: `src/forecasts/forecast.controller.ts`)
- Tenant User → Knowledge Assistant API: asks questions (evidence: `src/rag/rag.controller.ts`)
- Knowledge Assistant API → Knowledge Retrieval: searches knowledge (evidence: `src/rag/rag.controller.ts`)
- Knowledge Retrieval → Text Embeddings: embeds text (evidence: `src/rag/rag.service.ts`)
- Knowledge Retrieval → PostgreSQL Vector Store: queries vectors (evidence: `src/rag/rag.service.ts`)
- Knowledge Assistant API → Agent Tools: executes tools (evidence: `src/rag/rag.controller.ts`)
