# kummethaharshavardhan/business_management_system-team-4 architecture

> Architecture diagram of the GitHub repository kummethaharshavardhan/business_management_system-team-4, 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/kummethaharshavardhan/business_management_system-team-4
- Repository: https://github.com/kummethaharshavardhan/business_management_system-team-4

## Overview

This is a browser-based business management application focused on sales, billing, invoices, and returns, with customer and product data integration. Users create sales from customer/product selections, then use sale IDs for invoices and returns; returns validate purchased and previously returned quantities before restoring stock. The graph covers the documented major workflows, using README statements where backend excerpts were unavailable; arrows otherwise rely on shown imports, routing, and calls.

Main entry points: [`client/src/App.jsx`](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/App.jsx) (App routes), [`client/src/services/sales.js`](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/sales.js) (Sales API client), [`client/src/services/invoice.js`](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/invoice.js) (Invoice API client), [`client/src/pages/Billing/Billing.jsx`](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Billing/Billing.jsx) (Billing screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routes<br/>[App.jsx]"]
  node_sales_ui["Sales screens<br/>[Sales.jsx]"]
  node_new_sale["New sale form<br/>[NewSale.jsx]"]
  node_billing_ui["Billing screen<br/>[Billing.jsx]"]
  node_invoices_ui["Invoice screens<br/>[Invoices.jsx]"]
  node_new_invoice["New invoice form<br/>[NewInvoice.jsx]"]
  node_returns_ui["Return screens<br/>[Returns.jsx]"]
  node_new_return["New return form<br/>[NewReturn.jsx]"]
  node_auth["Auth headers<br/>[authHeader.js]"]
  node_sales_service["Sales API client<br/>[sales.js]"]
  node_invoice_service["Invoice API client<br/>[invoice.js]"]
  node_return_service["Return API client<br/>[return.js]"]
  node_customer_service_client["Customer API client<br/>[customer.js]"]
  node_product_service_client["Product API client<br/>[product.js]"]
end

subgraph group_api["REST API"]
  node_server["Express application<br/>[server.js]"]
  node_sale_routes["Sales routes<br/>[saleRoutes.js]"]
  node_invoice_routes["Invoice routes<br/>[invoiceRoutes.js]"]
  node_return_routes["Return routes<br/>[returnRoutes.js]"]
  node_test_data_routes["Customer/product routes<br/>[testDataRoutes.js]"]
  node_auth_middleware["JWT verification<br/>[verifyToken.js]"]
  node_sale_validation["Sale validation<br/>[validateSale.js]"]
  node_stock_check["Stock check<br/>[checkStock.js]"]
end

subgraph group_domain["Business logic and data"]
  node_sale_controller["Sales controller<br/>[saleController.js]"]
  node_invoice_controller["Invoice controller"]
  node_return_controller["Return controller"]
  node_bill_calc["Bill calculation<br/>[calculateBill.js]"]
  node_stock_service["Inventory access<br/>[stockService.js]"]
  node_customer_service["Customer access<br/>[customerService.js]"]
  node_sale_model[("Sale records<br/>[sale.js]")]
  node_invoice_model[("Invoice records<br/>[invoice.js]")]
  node_return_model[("Return records<br/>[return.js]")]
end

node_user(("Business user"))
node_external_customer[("Customer data")]
node_external_product[("Product data")]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_sales_ui
node_app -->|"routes to"| node_new_sale
node_app -->|"routes to"| node_billing_ui
node_app -->|"routes to"| node_invoices_ui
node_app -->|"routes to"| node_new_invoice
node_app -->|"routes to"| node_returns_ui
node_app -->|"routes to"| node_new_return
node_new_sale -->|"creates sale"| node_sales_service
node_sales_ui -->|"loads sales"| node_sales_service
node_new_sale -->|"loads customers"| node_customer_service_client
node_new_sale -->|"loads products"| node_product_service_client
node_sales_service -->|"gets headers"| node_auth
node_invoice_service -->|"gets headers"| node_auth
node_new_invoice -->|"creates invoice"| node_invoice_service
node_invoices_ui -->|"loads invoices"| node_invoice_service
node_billing_ui -->|"uses invoices"| node_invoice_service
node_billing_ui -->|"uses sales"| node_sales_service
node_billing_ui -->|"loads customers"| node_customer_service_client
node_billing_ui -->|"loads products"| node_product_service_client
node_new_return -->|"submits return"| node_return_service
node_returns_ui -->|"loads returns"| node_return_service
node_new_return -->|"reads sales"| node_sales_service
node_new_return -->|"reads invoices"| node_invoice_service
node_new_return -->|"reads products"| node_product_service_client
node_returns_ui -->|"reads sales"| node_sales_service
node_returns_ui -->|"reads invoices"| node_invoice_service
node_returns_ui -->|"reads customers"| node_customer_service_client
node_server -->|"mounts routes"| node_sale_routes
node_server -->|"mounts routes"| node_invoice_routes
node_server -->|"mounts routes"| node_return_routes
node_server -->|"mounts routes"| node_test_data_routes
node_sale_routes -->|"verifies token"| node_auth_middleware
node_sale_routes -->|"validates sale"| node_sale_validation
node_sale_routes -->|"checks stock"| node_stock_check
node_sale_routes -->|"dispatches"| node_sale_controller
node_return_routes -->|"verifies token"| node_auth_middleware
node_return_routes -->|"dispatches"| node_return_controller
node_invoice_routes -->|"dispatches"| node_invoice_controller
node_test_data_routes -->|"verifies token"| node_auth_middleware
node_test_data_routes -->|"loads customers"| node_customer_service
node_test_data_routes -->|"loads products"| node_stock_service
node_sale_controller -->|"checks customer"| node_customer_service
node_sale_controller -->|"calculates bill"| node_bill_calc
node_sale_controller -->|"adjusts stock"| node_stock_service
node_sale_controller -->|"creates and reads"| node_sale_model
node_stock_check -->|"checks inventory"| node_stock_service
node_invoice_controller -->|"reads sale"| node_sale_model

click node_app "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/App.jsx"
click node_sales_ui "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Sales/Sales.jsx"
click node_new_sale "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Sales/NewSale/NewSale.jsx"
click node_billing_ui "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Billing/Billing.jsx"
click node_invoices_ui "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Invoices/Invoices.jsx"
click node_new_invoice "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Invoices/NewInvoice/NewInvoice.jsx"
click node_returns_ui "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Returns/Returns.jsx"
click node_new_return "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Returns/NewReturn/NewReturn.jsx"
click node_auth "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/authHeader.js"
click node_sales_service "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/sales.js"
click node_invoice_service "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/invoice.js"
click node_return_service "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/return.js"
click node_customer_service_client "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/customer.js"
click node_product_service_client "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/product.js"
click node_server "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/server.js"
click node_sale_routes "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/routes/saleRoutes.js"
click node_invoice_routes "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/routes/invoiceRoutes.js"
click node_return_routes "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/routes/returnRoutes.js"
click node_test_data_routes "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/routes/testDataRoutes.js"
click node_auth_middleware "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/middleware/verifyToken.js"
click node_sale_validation "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/middleware/validateSale.js"
click node_stock_check "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/middleware/checkStock.js"
click node_sale_controller "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/controller/saleController.js"
click node_invoice_controller "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/controller/invoiceController.js"
click node_return_controller "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/controller/returnController.js"
click node_bill_calc "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/utils/calculateBill.js"
click node_stock_service "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/services/stockService.js"
click node_customer_service "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/services/customerService.js"
click node_sale_model "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/model/sale.js"
click node_invoice_model "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/model/invoice.js"
click node_return_model "https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/model/return.js"

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_sales_ui,node_new_sale,node_billing_ui,node_invoices_ui,node_new_invoice,node_returns_ui,node_new_return,node_auth,node_sales_service,node_invoice_service,node_return_service,node_customer_service_client,node_product_service_client,node_user toneBlue
class node_server,node_sale_routes,node_invoice_routes,node_return_routes,node_test_data_routes,node_auth_middleware,node_sale_validation,node_stock_check,node_external_customer,node_external_product toneAmber
class node_sale_controller,node_invoice_controller,node_return_controller,node_bill_calc,node_stock_service,node_customer_service,node_sale_model,node_invoice_model,node_return_model toneMint
```

## Components

### Web client

- [App routes](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Sales screens](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Sales/Sales.jsx): `client/src/pages/Sales/Sales.jsx`
- [New sale form](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Sales/NewSale/NewSale.jsx): `client/src/pages/Sales/NewSale/NewSale.jsx`
- [Billing screen](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Billing/Billing.jsx): `client/src/pages/Billing/Billing.jsx`
- [Invoice screens](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Invoices/Invoices.jsx): `client/src/pages/Invoices/Invoices.jsx`
- [New invoice form](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Invoices/NewInvoice/NewInvoice.jsx): `client/src/pages/Invoices/NewInvoice/NewInvoice.jsx`
- [Return screens](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Returns/Returns.jsx): `client/src/pages/Returns/Returns.jsx`
- [New return form](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/pages/Returns/NewReturn/NewReturn.jsx): `client/src/pages/Returns/NewReturn/NewReturn.jsx`
- [Auth headers](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/authHeader.js): `client/src/services/authHeader.js`
- [Sales API client](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/sales.js): `client/src/services/sales.js`
- [Invoice API client](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/invoice.js): `client/src/services/invoice.js`
- [Return API client](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/return.js): `client/src/services/return.js`
- [Customer API client](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/customer.js): `client/src/services/customer.js`
- [Product API client](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/client/src/services/product.js): `client/src/services/product.js`

### REST API

- [Express application](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/server.js): `server/server.js`
- [Sales routes](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/routes/saleRoutes.js): `server/routes/saleRoutes.js`
- [Invoice routes](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/routes/invoiceRoutes.js): `server/routes/invoiceRoutes.js`
- [Return routes](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/routes/returnRoutes.js): `server/routes/returnRoutes.js`
- [Customer/product routes](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/routes/testDataRoutes.js): `server/routes/testDataRoutes.js`
- [JWT verification](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/middleware/verifyToken.js): `server/middleware/verifyToken.js`
- [Sale validation](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/middleware/validateSale.js): `server/middleware/validateSale.js`
- [Stock check](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/middleware/checkStock.js): `server/middleware/checkStock.js`

### Business logic and data

- [Sales controller](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/controller/saleController.js): `server/controller/saleController.js`
- [Invoice controller](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/controller/invoiceController.js): `server/controller/invoiceController.js`
- [Return controller](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/controller/returnController.js): `server/controller/returnController.js`
- [Bill calculation](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/utils/calculateBill.js): `server/utils/calculateBill.js`
- [Inventory access](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/services/stockService.js): `server/services/stockService.js`
- [Customer access](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/services/customerService.js): `server/services/customerService.js`
- [Sale records](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/model/sale.js): `server/model/sale.js`
- [Invoice records](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/model/invoice.js): `server/model/invoice.js`
- [Return records](https://github.com/kummethaharshavardhan/business_management_system-team-4/blob/main/server/model/return.js): `server/model/return.js`

### Other components

- **Business user**
- **Customer data**
- **Product data**

## Connections

- Business user → App routes: uses (evidence: `client/src/App.jsx`)
- App routes → Sales screens: routes to (evidence: `client/src/App.jsx`)
- App routes → New sale form: routes to (evidence: `client/src/App.jsx`)
- App routes → Billing screen: routes to (evidence: `client/src/App.jsx`)
- App routes → Invoice screens: routes to (evidence: `client/src/App.jsx`)
- App routes → New invoice form: routes to (evidence: `client/src/App.jsx`)
- App routes → Return screens: routes to (evidence: `client/src/App.jsx`)
- App routes → New return form: routes to (evidence: `client/src/App.jsx`)
- New sale form → Sales API client: creates sale (evidence: `client/src/pages/Sales/NewSale/NewSale.jsx`)
- Sales screens → Sales API client: loads sales (evidence: `client/src/pages/Sales/Sales.jsx`)
- New sale form → Customer API client: loads customers (evidence: `client/src/pages/Sales/NewSale/NewSale.jsx`)
- New sale form → Product API client: loads products (evidence: `client/src/pages/Sales/NewSale/NewSale.jsx`)
- Sales API client → Auth headers: gets headers (evidence: `client/src/services/sales.js`)
- Invoice API client → Auth headers: gets headers (evidence: `client/src/services/invoice.js`)
- New invoice form → Invoice API client: creates invoice (evidence: `client/src/pages/Invoices/NewInvoice/NewInvoice.jsx`)
- Invoice screens → Invoice API client: loads invoices (evidence: `client/src/pages/Invoices/Invoices.jsx`)
- Billing screen → Invoice API client: uses invoices (evidence: `client/src/pages/Billing/Billing.jsx`)
- Billing screen → Sales API client: uses sales (evidence: `client/src/pages/Billing/Billing.jsx`)
- Billing screen → Customer API client: loads customers (evidence: `client/src/pages/Billing/Billing.jsx`)
- Billing screen → Product API client: loads products (evidence: `client/src/pages/Billing/Billing.jsx`)
- New return form → Return API client: submits return (evidence: `client/src/pages/Returns/NewReturn/NewReturn.jsx`)
- Return screens → Return API client: loads returns (evidence: `client/src/pages/Returns/Returns.jsx`)
- New return form → Sales API client: reads sales (evidence: `client/src/pages/Returns/NewReturn/NewReturn.jsx`)
- New return form → Invoice API client: reads invoices (evidence: `client/src/pages/Returns/NewReturn/NewReturn.jsx`)
- New return form → Product API client: reads products (evidence: `client/src/pages/Returns/NewReturn/NewReturn.jsx`)
- Return screens → Sales API client: reads sales (evidence: `client/src/pages/Returns/Returns.jsx`)
- Return screens → Invoice API client: reads invoices (evidence: `client/src/pages/Returns/Returns.jsx`)
- Return screens → Customer API client: reads customers (evidence: `client/src/pages/Returns/Returns.jsx`)
- Express application → Sales routes: mounts routes (evidence: `server/server.js`)
- Express application → Invoice routes: mounts routes (evidence: `server/server.js`)
- Express application → Return routes: mounts routes (evidence: `server/server.js`)
- Express application → Customer/product routes: mounts routes (evidence: `server/server.js`)
- Sales routes → JWT verification: verifies token (evidence: `server/routes/saleRoutes.js`)
- Sales routes → Sale validation: validates sale (evidence: `server/routes/saleRoutes.js`)
- Sales routes → Stock check: checks stock (evidence: `server/routes/saleRoutes.js`)
- Sales routes → Sales controller: dispatches (evidence: `server/routes/saleRoutes.js`)
- Return routes → JWT verification: verifies token (evidence: `server/routes/returnRoutes.js`)
- Return routes → Return controller: dispatches (evidence: `server/routes/returnRoutes.js`)
- Invoice routes → Invoice controller: dispatches (evidence: `server/routes/invoiceRoutes.js`)
- Customer/product routes → JWT verification: verifies token (evidence: `server/routes/testDataRoutes.js`)
- Customer/product routes → Customer access: loads customers (evidence: `server/routes/testDataRoutes.js`)
- Customer/product routes → Inventory access: loads products (evidence: `server/routes/testDataRoutes.js`)
- Sales controller → Customer access: checks customer (evidence: `server/controller/saleController.js`)
- Sales controller → Bill calculation: calculates bill (evidence: `server/controller/saleController.js`)
- Sales controller → Inventory access: adjusts stock (evidence: `server/controller/saleController.js`)
- Sales controller → Sale records: creates and reads (evidence: `server/controller/saleController.js`)
- Stock check → Inventory access: checks inventory (evidence: `server/middleware/checkStock.js`)
- Invoice controller → Sale records: reads sale (evidence: `server/controller/invoiceController.js`)
