# saiteja9154/pharma-nexus architecture

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

- Interactive diagram: https://gitdiagram.com/saiteja9154/pharma-nexus
- Repository: https://github.com/saiteja9154/pharma-nexus

## Overview

Pharma Nexus is a pharmacy procurement ERP with an autonomous restocking and bargaining agent. Its principal workflow observes inventory, calculates demand and expiry-safe quantities, discovers and scores vendor offers, negotiates a price, validates the deal, then commits a purchase order and stock update. The graph preserves the UI’s inventory, vendor, agent, negotiation, and purchase-order views as well as the internal decision tools. The README documents the end-to-end stages; sampled source confirms selected calls and UI composition, but not every API route or internal agent transition.

Main entry points: [`frontend/src/App.jsx`](https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/App.jsx) (ERP App), [`backend/agent/store_agent.py`](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/agent/store_agent.py) (Store Agent), [`backend/main.py`](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/main.py) (REST API), [`backend/database/db.py`](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/database/db.py) (SQLite ERP)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["ERP Interface"]
  node_app["ERP App<br/>[App.jsx]"]
  node_inventory_view["Inventory View<br/>[Inventory.jsx]"]
  node_vendors_view["Vendor Directory<br/>[Vendors.jsx]"]
  node_agent_view["Agent Control<br/>[AgentControl.jsx]"]
  node_negotiation_view["Negotiation View<br/>[Negotiation.jsx]"]
  node_orders_view["Purchase Orders<br/>[PurchaseOrders.jsx]"]
end

subgraph group_api["Backend API"]
  node_api_router["REST API<br/>[main.py]"]
end

subgraph group_agent["Procurement Agent"]
  node_agent_controller["Store Agent<br/>[store_agent.py]"]
end

subgraph group_tools["Decision Tools"]
  node_inventory_tools["Inventory Planning<br/>[inventory_tools.py]"]
  node_vendor_tools["Vendor Catalog<br/>[vendor_tools.py]"]
  node_deal_scoring["Deal Scoring<br/>[deal_scoring.py]"]
  node_negotiation_tools["Bargaining Engine"]
  node_validator["Deal Validator<br/>[validator.py]"]
  node_po_tools["Order Execution"]
end

subgraph group_data["ERP Data"]
  node_database[("SQLite ERP<br/>[db.py]")]
  node_seed["Baseline Data<br/>[seed.py]"]
end

node_staff(("Pharmacy Staff"))

node_staff -->|"uses"| node_app
node_app -->|"renders"| node_inventory_view
node_app -->|"renders"| node_vendors_view
node_app -->|"renders"| node_agent_view
node_app -->|"renders"| node_negotiation_view
node_app -->|"renders"| node_orders_view
node_app -->|"uses REST"| node_api_router
node_api_router -->|"starts procurement"| node_agent_controller
node_api_router -->|"routes inventory"| node_inventory_tools
node_api_router -->|"routes vendors"| node_vendor_tools
node_agent_controller -->|"observes demand"| node_inventory_tools
node_agent_controller -->|"finds offers"| node_vendor_tools
node_agent_controller -->|"ranks offers"| node_deal_scoring
node_agent_controller -->|"negotiates deals"| node_negotiation_tools
node_agent_controller -->|"validates deal"| node_validator
node_agent_controller -->|"executes accepted"| node_po_tools
node_inventory_tools -->|"reads and updates"| node_database
node_vendor_tools -->|"reads and updates"| node_database
node_po_tools -->|"commits order"| node_database
node_seed -->|"initializes data"| node_database

click node_app "https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/App.jsx"
click node_inventory_view "https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/pages/Inventory.jsx"
click node_vendors_view "https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/pages/Vendors.jsx"
click node_agent_view "https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/pages/AgentControl.jsx"
click node_negotiation_view "https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/pages/Negotiation.jsx"
click node_orders_view "https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/pages/PurchaseOrders.jsx"
click node_api_router "https://github.com/saiteja9154/pharma-nexus/blob/main/backend/main.py"
click node_agent_controller "https://github.com/saiteja9154/pharma-nexus/blob/main/backend/agent/store_agent.py"
click node_inventory_tools "https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/inventory_tools.py"
click node_vendor_tools "https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/vendor_tools.py"
click node_deal_scoring "https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/deal_scoring.py"
click node_negotiation_tools "https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/negotiation_tools.py"
click node_validator "https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/validator.py"
click node_po_tools "https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/purchase_order_tools.py"
click node_database "https://github.com/saiteja9154/pharma-nexus/blob/main/backend/database/db.py"
click node_seed "https://github.com/saiteja9154/pharma-nexus/blob/main/backend/database/seed.py"

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_app,node_inventory_view,node_vendors_view,node_agent_view,node_negotiation_view,node_orders_view toneBlue
class node_api_router toneAmber
class node_agent_controller toneMint
class node_inventory_tools,node_vendor_tools,node_deal_scoring,node_negotiation_tools,node_validator,node_po_tools toneRose
class node_database,node_seed,node_staff toneIndigo
```

## Components

### ERP Interface

- [ERP App](https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Inventory View](https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/pages/Inventory.jsx): `frontend/src/pages/Inventory.jsx`
- [Vendor Directory](https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/pages/Vendors.jsx): `frontend/src/pages/Vendors.jsx`
- [Agent Control](https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/pages/AgentControl.jsx): `frontend/src/pages/AgentControl.jsx`
- [Negotiation View](https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/pages/Negotiation.jsx): `frontend/src/pages/Negotiation.jsx`
- [Purchase Orders](https://github.com/saiteja9154/pharma-nexus/blob/main/frontend/src/pages/PurchaseOrders.jsx): `frontend/src/pages/PurchaseOrders.jsx`

### Backend API

- [REST API](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/main.py): `backend/main.py`

### Procurement Agent

- [Store Agent](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/agent/store_agent.py): `backend/agent/store_agent.py`

### Decision Tools

- [Inventory Planning](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/inventory_tools.py): `backend/tools/inventory_tools.py`
- [Vendor Catalog](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/vendor_tools.py): `backend/tools/vendor_tools.py`
- [Deal Scoring](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/deal_scoring.py): `backend/tools/deal_scoring.py`
- [Bargaining Engine](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/negotiation_tools.py): `backend/tools/negotiation_tools.py`
- [Deal Validator](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/validator.py): `backend/tools/validator.py`
- [Order Execution](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/tools/purchase_order_tools.py): `backend/tools/purchase_order_tools.py`

### ERP Data

- [SQLite ERP](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/database/db.py): `backend/database/db.py`
- [Baseline Data](https://github.com/saiteja9154/pharma-nexus/blob/main/backend/database/seed.py): `backend/database/seed.py`

### Other components

- **Pharmacy Staff**

## Connections

- Pharmacy Staff → ERP App: uses (evidence: `README.md`)
- ERP App → Inventory View: renders (evidence: `frontend/src/App.jsx`)
- ERP App → Vendor Directory: renders (evidence: `frontend/src/App.jsx`)
- ERP App → Agent Control: renders (evidence: `frontend/src/App.jsx`)
- ERP App → Negotiation View: renders (evidence: `frontend/src/App.jsx`)
- ERP App → Purchase Orders: renders (evidence: `frontend/src/App.jsx`)
- ERP App → REST API: uses REST (evidence: `README.md`)
- REST API → Store Agent: starts procurement (evidence: `README.md`)
- REST API → Inventory Planning: routes inventory (evidence: `backend/main.py`)
- REST API → Vendor Catalog: routes vendors (evidence: `backend/main.py`)
- Store Agent → Inventory Planning: observes demand (evidence: `backend/agent/store_agent.py`)
- Store Agent → Vendor Catalog: finds offers (evidence: `backend/agent/store_agent.py`)
- Store Agent → Deal Scoring: ranks offers (evidence: `backend/agent/store_agent.py`)
- Store Agent → Bargaining Engine: negotiates deals (evidence: `backend/agent/store_agent.py`)
- Store Agent → Deal Validator: validates deal (evidence: `backend/agent/store_agent.py`)
- Store Agent → Order Execution: executes accepted (evidence: `README.md`)
- Inventory Planning → SQLite ERP: reads and updates (evidence: `backend/tools/inventory_tools.py`)
- Vendor Catalog → SQLite ERP: reads and updates (evidence: `backend/tools/vendor_tools.py`)
- Order Execution → SQLite ERP: commits order (evidence: `README.md`)
- Baseline Data → SQLite ERP: initializes data (evidence: `backend/database/seed.py`)
