# kirush29/stockpilot architecture

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

- Interactive diagram: https://gitdiagram.com/kirush29/stockpilot
- Repository: https://github.com/kirush29/stockpilot

## Overview

StockPilot is an inventory and procurement platform whose users work through web and mobile clients against a central API. Its main replenishment journey moves from inventory optimization through demand forecasting and supplier evaluation to a procurement proposal, deterministic checks, human approval, and purchase-order processing. The README documents this workflow and the major business capabilities; the supplied excerpts expose only selected implementation details, so some documented links are shown with README evidence rather than inferred from unsampled code.

Main entry points: [`backend/StockPilot.Api/Program.cs`](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Program.cs) (ASP.NET Core API), [`agentic-ai/agents/supplier_evaluation/decision_engine.py`](https://github.com/kirush29/stockpilot/blob/main/agentic-ai/agents/supplier_evaluation/decision_engine.py) (Supplier Evaluation), [`backend/StockPilot.Api/Shared/Agents/Orchestrator/ReplenishmentOrchestrator.cs`](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Shared/Agents/Orchestrator/ReplenishmentOrchestrator.cs) (Replenishment Orchestrator), [`backend/StockPilot.Api/Modules/Procurement/Agents/ProcurementCoordinator/ProcurementCoordinatorAgent.cs`](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Procurement/Agents/ProcurementCoordinator/ProcurementCoordinatorAgent.cs) (Procurement Coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Client Applications"]
  node_web["React Management UI<br/>[App.jsx]"]
  node_mobile["Flutter Operations UI<br/>[MainActivity.kt]"]
end

subgraph group_operations["Inventory and Sales"]
  node_inventory["Inventory Operations<br/>[Inventory.cs]"]
  node_optimization["Inventory Optimizer"]
  node_sales["Sales Recording<br/>[SalesService.cs]"]
  node_forecast["Demand Forecast Agent"]
end

subgraph group_sourcing["Supplier Management"]
  node_supplier["Supplier and Quotation Management<br/>[SupplierService.cs]"]
  node_supplier_eval["Supplier Evaluation<br/>[decision_engine.py]"]
end

subgraph group_procurement["Procurement Workflow"]
  node_orchestrator["Replenishment Orchestrator"]
  node_procurement_agent["Procurement Coordinator"]
  node_rules["Business Rule Checks"]
  node_proposal["Procurement Proposal"]
  node_approval["Human Approval"]
  node_orders["Purchase Orders"]
end

subgraph group_platform["API and Platform"]
  node_api["ASP.NET Core API<br/>[Program.cs]"]
  node_auth["Identity and Access<br/>[AuthController.cs]"]
  node_audit["Workflow Audit and Monitoring"]
  node_database[("PostgreSQL Database<br/>[AppDbContext.cs]")]
end

node_user(("Business User"))
node_llm(("External AI Service"))

node_user -->|"uses"| node_web
node_user -->|"uses"| node_mobile
node_web -->|"sends requests"| node_api
node_mobile -->|"sends requests"| node_api
node_api -->|"routes authentication"| node_auth
node_api -->|"routes business operations"| node_inventory
node_api -->|"routes business operations"| node_sales
node_api -->|"routes business operations"| node_supplier
node_api -->|"routes workflows"| node_orchestrator
node_inventory -->|"analyzes stock"| node_optimization
node_optimization -->|"informs replenishment"| node_forecast
node_sales -->|"provides demand history"| node_forecast
node_forecast -->|"informs supplier choice"| node_supplier_eval
node_supplier -->|"provides quotations"| node_supplier_eval
node_supplier_eval -.->|"requests evaluation"| node_llm
node_supplier_eval -->|"returns recommendation"| node_orchestrator
node_orchestrator -->|"dispatches workflow"| node_procurement_agent
node_procurement_agent -->|"checks proposal"| node_rules
node_procurement_agent -->|"prepares proposal"| node_proposal
node_rules -->|"validates for review"| node_proposal
node_proposal -->|"awaits decision"| node_approval
node_approval -->|"converts approved proposal"| node_orders
node_orchestrator -->|"records workflow"| node_audit
node_api -->|"persists platform data"| node_database

click node_web "https://github.com/kirush29/stockpilot/blob/main/web/src/App.jsx"
click node_mobile "https://github.com/kirush29/stockpilot/blob/main/mobile/android/app/src/main/kotlin/com/stockpilot/stockpilot_mobile/MainActivity.kt"
click node_api "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Program.cs"
click node_auth "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Inventory/Controllers/AuthController.cs"
click node_inventory "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Inventory/Domain/Entities/Inventory.cs"
click node_optimization "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Inventory/Infrastructure/Services/InventoryOptimizationService.cs"
click node_sales "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/SalesDemand/Application/Sales/Services/SalesService.cs"
click node_forecast "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/SalesDemand/Agents/DemandForecastAgent/DemandForecastAgent.cs"
click node_supplier "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Suppliers/Application/Services/SupplierService.cs"
click node_supplier_eval "https://github.com/kirush29/stockpilot/blob/main/agentic-ai/agents/supplier_evaluation/decision_engine.py"
click node_orchestrator "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Shared/Agents/Orchestrator/ReplenishmentOrchestrator.cs"
click node_procurement_agent "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Procurement/Agents/ProcurementCoordinator/ProcurementCoordinatorAgent.cs"
click node_rules "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Procurement/Application/Services/ProcurementBusinessRuleService.cs"
click node_proposal "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Procurement/Application/Services/ProcurementProposalService.cs"
click node_approval "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Procurement/Controllers/ProposalsController.cs"
click node_orders "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Procurement/Application/Services/PurchaseOrderService.cs"
click node_audit "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Shared/Agents/AgentRunsController.cs"
click node_database "https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Shared/Data/AppDbContext.cs"

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_web,node_mobile,node_user toneBlue
class node_inventory,node_optimization,node_sales,node_forecast toneAmber
class node_supplier,node_supplier_eval toneMint
class node_orchestrator,node_procurement_agent,node_rules,node_proposal,node_approval,node_orders toneRose
class node_api,node_auth,node_audit,node_database,node_llm toneIndigo
```

## Components

### Client Applications

- [React Management UI](https://github.com/kirush29/stockpilot/blob/main/web/src/App.jsx): `web/src/App.jsx`
- [Flutter Operations UI](https://github.com/kirush29/stockpilot/blob/main/mobile/android/app/src/main/kotlin/com/stockpilot/stockpilot_mobile/MainActivity.kt): `mobile/android/app/src/main/kotlin/com/stockpilot/stockpilot_mobile/MainActivity.kt`

### Inventory and Sales

- [Inventory Operations](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Inventory/Domain/Entities/Inventory.cs): `backend/StockPilot.Api/Modules/Inventory/Domain/Entities/Inventory.cs`
- [Inventory Optimizer](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Inventory/Infrastructure/Services/InventoryOptimizationService.cs): `backend/StockPilot.Api/Modules/Inventory/Infrastructure/Services/InventoryOptimizationService.cs`
- [Sales Recording](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/SalesDemand/Application/Sales/Services/SalesService.cs): `backend/StockPilot.Api/Modules/SalesDemand/Application/Sales/Services/SalesService.cs`
- [Demand Forecast Agent](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/SalesDemand/Agents/DemandForecastAgent/DemandForecastAgent.cs): `backend/StockPilot.Api/Modules/SalesDemand/Agents/DemandForecastAgent/DemandForecastAgent.cs`

### Supplier Management

- [Supplier and Quotation Management](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Suppliers/Application/Services/SupplierService.cs): `backend/StockPilot.Api/Modules/Suppliers/Application/Services/SupplierService.cs`
- [Supplier Evaluation](https://github.com/kirush29/stockpilot/blob/main/agentic-ai/agents/supplier_evaluation/decision_engine.py): `agentic-ai/agents/supplier_evaluation/decision_engine.py`

### Procurement Workflow

- [Replenishment Orchestrator](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Shared/Agents/Orchestrator/ReplenishmentOrchestrator.cs): `backend/StockPilot.Api/Shared/Agents/Orchestrator/ReplenishmentOrchestrator.cs`
- [Procurement Coordinator](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Procurement/Agents/ProcurementCoordinator/ProcurementCoordinatorAgent.cs): `backend/StockPilot.Api/Modules/Procurement/Agents/ProcurementCoordinator/ProcurementCoordinatorAgent.cs`
- [Business Rule Checks](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Procurement/Application/Services/ProcurementBusinessRuleService.cs): `backend/StockPilot.Api/Modules/Procurement/Application/Services/ProcurementBusinessRuleService.cs`
- [Procurement Proposal](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Procurement/Application/Services/ProcurementProposalService.cs): `backend/StockPilot.Api/Modules/Procurement/Application/Services/ProcurementProposalService.cs`
- [Human Approval](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Procurement/Controllers/ProposalsController.cs): `backend/StockPilot.Api/Modules/Procurement/Controllers/ProposalsController.cs`
- [Purchase Orders](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Procurement/Application/Services/PurchaseOrderService.cs): `backend/StockPilot.Api/Modules/Procurement/Application/Services/PurchaseOrderService.cs`

### API and Platform

- [ASP.NET Core API](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Program.cs): `backend/StockPilot.Api/Program.cs`
- [Identity and Access](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Modules/Inventory/Controllers/AuthController.cs): `backend/StockPilot.Api/Modules/Inventory/Controllers/AuthController.cs`
- [Workflow Audit and Monitoring](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Shared/Agents/AgentRunsController.cs): `backend/StockPilot.Api/Shared/Agents/AgentRunsController.cs`
- [PostgreSQL Database](https://github.com/kirush29/stockpilot/blob/main/backend/StockPilot.Api/Shared/Data/AppDbContext.cs): `backend/StockPilot.Api/Shared/Data/AppDbContext.cs`

### Other components

- **Business User**
- **External AI Service**

## Connections

- Business User → React Management UI: uses (evidence: `README.md`)
- Business User → Flutter Operations UI: uses (evidence: `README.md`)
- React Management UI → ASP.NET Core API: sends requests (evidence: `README.md`)
- Flutter Operations UI → ASP.NET Core API: sends requests (evidence: `README.md`)
- ASP.NET Core API → Identity and Access: routes authentication (evidence: `backend/StockPilot.Api/Program.cs`)
- ASP.NET Core API → Inventory Operations: routes business operations (evidence: `README.md`)
- ASP.NET Core API → Sales Recording: routes business operations (evidence: `README.md`)
- ASP.NET Core API → Supplier and Quotation Management: routes business operations (evidence: `README.md`)
- ASP.NET Core API → Replenishment Orchestrator: routes workflows (evidence: `backend/StockPilot.Api/Program.cs`)
- Inventory Operations → Inventory Optimizer: analyzes stock (evidence: `README.md`)
- Inventory Optimizer → Demand Forecast Agent: informs replenishment (evidence: `README.md`)
- Sales Recording → Demand Forecast Agent: provides demand history (evidence: `README.md`)
- Demand Forecast Agent → Supplier Evaluation: informs supplier choice (evidence: `README.md`)
- Supplier and Quotation Management → Supplier Evaluation: provides quotations (evidence: `README.md`)
- Supplier Evaluation → External AI Service: requests evaluation
- Supplier Evaluation → Replenishment Orchestrator: returns recommendation (evidence: `README.md`)
- Replenishment Orchestrator → Procurement Coordinator: dispatches workflow (evidence: `README.md`)
- Procurement Coordinator → Business Rule Checks: checks proposal (evidence: `README.md`)
- Procurement Coordinator → Procurement Proposal: prepares proposal (evidence: `README.md`)
- Business Rule Checks → Procurement Proposal: validates for review (evidence: `README.md`)
- Procurement Proposal → Human Approval: awaits decision (evidence: `backend/StockPilot.Api/Modules/Procurement/Controllers/ProposalsController.cs`)
- Human Approval → Purchase Orders: converts approved proposal (evidence: `backend/StockPilot.Api/Modules/Procurement/Controllers/ProposalsController.cs`)
- Replenishment Orchestrator → Workflow Audit and Monitoring: records workflow (evidence: `README.md`)
- ASP.NET Core API → PostgreSQL Database: persists platform data (evidence: `README.md`)
