# gwankhede/krushi-app architecture

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

- Interactive diagram: https://gitdiagram.com/gwankhede/krushi-app
- Repository: https://github.com/gwankhede/krushi-app

## Overview

Krushi Smart Billing is a full-stack retail billing and inventory application. Owners, managers, and staff use the frontend to manage products, customers, sales, purchases, settings, and analytics; the backend exposes corresponding APIs and persists business data. The graph highlights the documented product areas and the sampled sales, purchasing, and product-management behavior. Some frontend-to-API wiring and unsampled controller internals are not shown in the excerpts, so those links are omitted or marked unverified.

Main entry points: [`Backends/src/app.js`](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/app.js) (Express API), [`Backends/src/middleware/auth.js`](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/middleware/auth.js) (JWT authentication), [`Frontend/src/routes/index.tsx`](https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/routes/index.tsx) (Page routing), [`Backends/src/controllers/saleController.js`](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/saleController.js) (Sales processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["Web application<br/>[App.tsx]"]
  node_routes_ui["Page routing<br/>[index.tsx]"]
  node_products_ui["Product workspace<br/>[Products.tsx]"]
  node_billing_ui["Billing workspace<br/>[Billing.tsx]"]
  node_purchase_ui["Purchase workspace<br/>[Purchase.tsx]"]
  node_reports_ui["Reports and dashboard<br/>[Report.tsx]"]
  node_pdf["Invoice PDF export<br/>[PDFGenerator.tsx]"]
  node_api_client["API client<br/>[api.tsx]"]
end

subgraph group_inventory["Inventory and purchasing"]
  node_product_controller["Product management"]
  node_category_controller["Category management"]
  node_purchase_controller["Purchase processing"]
  node_supplier_controller["Supplier management"]
end

subgraph group_transactions["Billing and customers"]
  node_sale_controller["Sales processing<br/>[saleController.js]"]
  node_customer_controller["Customer management"]
  node_invoice_number["Invoice numbering<br/>[invoice.js]"]
end

subgraph group_operations["Business operations"]
  node_dashboard_controller["Dashboard analytics"]
  node_report_controller["Business reports"]
  node_settings_controller["Business settings"]
end

subgraph group_backend["Backend API"]
  node_api_server["Express API<br/>[app.js]"]
  node_auth_routes["Authentication routes<br/>[auth.js]"]
  node_product_routes["Product routes<br/>[products.js]"]
  node_sales_routes["Sales routes<br/>[sales.js]"]
  node_purchase_routes["Purchase routes<br/>[purchases.js]"]
  node_report_routes["Report routes<br/>[reports.js]"]
  node_settings_routes["Settings routes<br/>[settings.js]"]
  node_auth["JWT authentication<br/>[auth.js]"]
end

node_staff(("Business staff"))
node_database[("PostgreSQL database")]
node_google_search["Google image search"]

node_staff -->|"uses"| node_app
node_app -->|"renders"| node_routes_ui
node_routes_ui -.->|"routes to"| node_products_ui
node_routes_ui -.->|"routes to"| node_billing_ui
node_routes_ui -.->|"routes to"| node_purchase_ui
node_routes_ui -.->|"routes to"| node_reports_ui
node_products_ui -.->|"requests data"| node_product_controller
node_billing_ui -.->|"requests data"| node_api_client
node_purchase_ui -.->|"requests data"| node_api_client
node_reports_ui -.->|"requests data"| node_api_client
node_billing_ui -->|"exports invoices"| node_pdf
node_api_client -.->|"calls API"| node_api_server
node_api_server -->|"mounts routes"| node_auth_routes
node_api_server -->|"mounts routes"| node_product_routes
node_api_server -->|"mounts routes"| node_sales_routes
node_api_server -->|"mounts routes"| node_purchase_routes
node_api_server -->|"mounts routes"| node_report_routes
node_api_server -->|"mounts routes"| node_settings_routes
node_auth_routes -.->|"authenticates"| node_auth
node_product_routes -->|"dispatches to"| node_product_controller
node_product_routes -->|"authenticates"| node_auth
node_sales_routes -->|"dispatches to"| node_sale_controller
node_sales_routes -->|"authenticates"| node_auth
node_purchase_routes -->|"dispatches to"| node_purchase_controller
node_purchase_routes -->|"authenticates"| node_auth
node_report_routes -->|"dispatches to"| node_report_controller
node_report_routes -->|"authenticates"| node_auth
node_settings_routes -->|"dispatches to"| node_settings_controller
node_settings_routes -->|"authenticates"| node_auth
node_product_controller -->|"reads and writes"| node_database
node_category_controller -->|"reads and writes"| node_database
node_customer_controller -->|"reads and writes"| node_database
node_purchase_controller -->|"records purchases"| node_database
node_purchase_controller -->|"updates stock"| node_database
node_sale_controller -->|"records sales"| node_database
node_sale_controller -->|"updates stock"| node_database
node_sale_controller -->|"generates number"| node_invoice_number
node_dashboard_controller -->|"reads metrics"| node_database
node_report_controller -.->|"queries reports"| node_database
node_settings_controller -->|"updates settings"| node_database
node_supplier_controller -.->|"manages suppliers"| node_database
node_product_controller -.->|"searches images"| node_google_search

click node_app "https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/App.tsx"
click node_routes_ui "https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/routes/index.tsx"
click node_products_ui "https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/pages/Products.tsx"
click node_billing_ui "https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/pages/Billing.tsx"
click node_purchase_ui "https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/pages/Purchase.tsx"
click node_reports_ui "https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/pages/Report.tsx"
click node_pdf "https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/components/PDFGenerator.tsx"
click node_api_client "https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/services/api.tsx"
click node_api_server "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/app.js"
click node_auth_routes "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/auth.js"
click node_product_routes "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/products.js"
click node_sales_routes "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/sales.js"
click node_purchase_routes "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/purchases.js"
click node_report_routes "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/reports.js"
click node_settings_routes "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/settings.js"
click node_auth "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/middleware/auth.js"
click node_product_controller "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/productController.js"
click node_category_controller "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/categoryController.js"
click node_purchase_controller "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/purchaseController.js"
click node_sale_controller "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/saleController.js"
click node_customer_controller "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/customerController.js"
click node_dashboard_controller "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/dashboardController.js"
click node_report_controller "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/reportController.js"
click node_settings_controller "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/settingsController.js"
click node_supplier_controller "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/supplierController.js"
click node_invoice_number "https://github.com/gwankhede/krushi-app/blob/main/Backends/src/utils/invoice.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_routes_ui,node_products_ui,node_billing_ui,node_purchase_ui,node_reports_ui,node_pdf,node_api_client toneBlue
class node_product_controller,node_category_controller,node_purchase_controller,node_supplier_controller,node_database toneAmber
class node_sale_controller,node_customer_controller,node_invoice_number toneMint
class node_dashboard_controller,node_report_controller,node_settings_controller toneRose
class node_api_server,node_auth_routes,node_product_routes,node_sales_routes,node_purchase_routes,node_report_routes,node_settings_routes,node_auth,node_staff,node_google_search toneIndigo
```

## Components

### Frontend experience

- [Web application](https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/App.tsx): `Frontend/src/App.tsx`
- [Page routing](https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/routes/index.tsx): `Frontend/src/routes/index.tsx`
- [Product workspace](https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/pages/Products.tsx): `Frontend/src/pages/Products.tsx`
- [Billing workspace](https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/pages/Billing.tsx): `Frontend/src/pages/Billing.tsx`
- [Purchase workspace](https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/pages/Purchase.tsx): `Frontend/src/pages/Purchase.tsx`
- [Reports and dashboard](https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/pages/Report.tsx): `Frontend/src/pages/Report.tsx`
- [Invoice PDF export](https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/components/PDFGenerator.tsx): `Frontend/src/components/PDFGenerator.tsx`
- [API client](https://github.com/gwankhede/krushi-app/blob/main/Frontend/src/services/api.tsx): `Frontend/src/services/api.tsx`

### Inventory and purchasing

- [Product management](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/productController.js): `Backends/src/controllers/productController.js`
- [Category management](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/categoryController.js): `Backends/src/controllers/categoryController.js`
- [Purchase processing](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/purchaseController.js): `Backends/src/controllers/purchaseController.js`
- [Supplier management](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/supplierController.js): `Backends/src/controllers/supplierController.js`

### Billing and customers

- [Sales processing](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/saleController.js): `Backends/src/controllers/saleController.js`
- [Customer management](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/customerController.js): `Backends/src/controllers/customerController.js`
- [Invoice numbering](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/utils/invoice.js): `Backends/src/utils/invoice.js`

### Business operations

- [Dashboard analytics](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/dashboardController.js): `Backends/src/controllers/dashboardController.js`
- [Business reports](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/reportController.js): `Backends/src/controllers/reportController.js`
- [Business settings](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/controllers/settingsController.js): `Backends/src/controllers/settingsController.js`

### Backend API

- [Express API](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/app.js): `Backends/src/app.js`
- [Authentication routes](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/auth.js): `Backends/src/routes/auth.js`
- [Product routes](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/products.js): `Backends/src/routes/products.js`
- [Sales routes](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/sales.js): `Backends/src/routes/sales.js`
- [Purchase routes](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/purchases.js): `Backends/src/routes/purchases.js`
- [Report routes](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/reports.js): `Backends/src/routes/reports.js`
- [Settings routes](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/routes/settings.js): `Backends/src/routes/settings.js`
- [JWT authentication](https://github.com/gwankhede/krushi-app/blob/main/Backends/src/middleware/auth.js): `Backends/src/middleware/auth.js`

### Other components

- **Business staff**
- **PostgreSQL database**
- **Google image search**

## Connections

- Business staff → Web application: uses (evidence: `README.md`)
- Web application → Page routing: renders (evidence: `Frontend/src/App.tsx`)
- Page routing → Product workspace: routes to
- Page routing → Billing workspace: routes to
- Page routing → Purchase workspace: routes to
- Page routing → Reports and dashboard: routes to
- Product workspace → Product management: requests data
- Billing workspace → API client: requests data
- Purchase workspace → API client: requests data
- Reports and dashboard → API client: requests data
- Billing workspace → Invoice PDF export: exports invoices
- API client → Express API: calls API
- Express API → Authentication routes: mounts routes (evidence: `Backends/src/app.js`)
- Express API → Product routes: mounts routes (evidence: `Backends/src/app.js`)
- Express API → Sales routes: mounts routes (evidence: `Backends/src/app.js`)
- Express API → Purchase routes: mounts routes (evidence: `Backends/src/app.js`)
- Express API → Report routes: mounts routes (evidence: `Backends/src/app.js`)
- Express API → Settings routes: mounts routes (evidence: `Backends/src/app.js`)
- Authentication routes → JWT authentication: authenticates
- Product routes → Product management: dispatches to (evidence: `Backends/src/routes/products.js`)
- Product routes → JWT authentication: authenticates (evidence: `Backends/src/routes/products.js`)
- Sales routes → Sales processing: dispatches to (evidence: `Backends/src/routes/sales.js`)
- Sales routes → JWT authentication: authenticates (evidence: `Backends/src/routes/sales.js`)
- Purchase routes → Purchase processing: dispatches to (evidence: `Backends/src/routes/purchases.js`)
- Purchase routes → JWT authentication: authenticates (evidence: `Backends/src/routes/purchases.js`)
- Report routes → Business reports: dispatches to (evidence: `Backends/src/routes/reports.js`)
- Report routes → JWT authentication: authenticates (evidence: `Backends/src/routes/reports.js`)
- Settings routes → Business settings: dispatches to (evidence: `Backends/src/routes/settings.js`)
- Settings routes → JWT authentication: authenticates (evidence: `Backends/src/routes/settings.js`)
- Product management → PostgreSQL database: reads and writes (evidence: `Backends/src/controllers/productController.js`)
- Category management → PostgreSQL database: reads and writes (evidence: `Backends/src/controllers/categoryController.js`)
- Customer management → PostgreSQL database: reads and writes (evidence: `Backends/src/controllers/customerController.js`)
- Purchase processing → PostgreSQL database: records purchases (evidence: `Backends/src/controllers/purchaseController.js`)
- Purchase processing → PostgreSQL database: updates stock (evidence: `Backends/src/controllers/purchaseController.js`)
- Sales processing → PostgreSQL database: records sales (evidence: `Backends/src/controllers/saleController.js`)
- Sales processing → PostgreSQL database: updates stock (evidence: `Backends/src/controllers/saleController.js`)
- Sales processing → Invoice numbering: generates number (evidence: `Backends/src/controllers/saleController.js`)
- Dashboard analytics → PostgreSQL database: reads metrics (evidence: `Backends/src/controllers/dashboardController.js`)
- Business reports → PostgreSQL database: queries reports
- Business settings → PostgreSQL database: updates settings (evidence: `Backends/src/controllers/settingsController.js`)
- Supplier management → PostgreSQL database: manages suppliers
- Product management → Google image search: searches images
