# chandrakanth2704/smart-medical-inventory-management-system architecture

> Architecture diagram of the GitHub repository chandrakanth2704/smart-medical-inventory-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chandrakanth2704/smart-medical-inventory-management-system
- Repository: https://github.com/chandrakanth2704/smart-medical-inventory-management-system

## Overview

Smart Medical Inventory Management System is a dual-role web application for managing medicine stock and customer purchases. Admins maintain medicines, suppliers, purchases, inventory and sales, then review reports; customers browse medicines, manage a cart and account details, and place and track orders. Next.js pages and route handlers implement the workflows, with MySQL for relational records and MongoDB/GridFS for medicine images. The graph preserves documented capabilities, but unsampled page-to-API wiring is not asserted.

Main entry points: [`frontend/lib/auth.ts`](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/lib/auth.ts) (Session and role checks), [`frontend/lib/mongodb.ts`](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/lib/mongodb.ts) (MongoDB and GridFS), [`frontend/app/api/medicines/route.ts`](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/medicines/route.ts) (Medicine management API), [`frontend/app/store/page.tsx`](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/page.tsx) (Medicine catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and dashboard"]
  node_dashboard["Admin dashboard"]
  node_authpages["Sign-in and registration<br/>[page.tsx]"]
  node_authapi["Authentication routes<br/>[route.ts]"]
  node_authlib["Session and role checks<br/>[auth.ts]"]
end

subgraph group_catalog["Medicine catalog"]
  node_medlist["Medicine catalog<br/>[page.tsx]"]
  node_addcart["Add to cart"]
  node_cartbar["Floating cart"]
  node_gallery["Medicine image gallery"]
  node_wishlistbutton["Save to wishlist"]
  node_accountmenu["Store account menu"]
end

subgraph group_operations["Inventory operations"]
  node_medicineapi["Medicine management API<br/>[route.ts]"]
  node_imagesapi["Medicine image API<br/>[route.ts]"]
  node_inventory["Stock and adjustments<br/>[route.ts]"]
  node_purchases["Purchases<br/>[route.ts]"]
  node_suppliers["Supplier management<br/>[route.ts]"]
  node_sales["Sales<br/>[route.ts]"]
  node_reports["Reports<br/>[route.ts]"]
  node_dashboardpages["Admin workspaces<br/>[page.tsx]"]
end

subgraph group_customers["Customer shopping"]
  node_checkout["Cart and checkout<br/>[page.tsx]"]
  node_customerorders["Customer orders<br/>[route.ts]"]
  node_delivery["Delivery details<br/>[route.ts]"]
  node_wishlistapi["Wishlist API<br/>[route.ts]"]
end

subgraph group_data["Data stores"]
  node_mysql[("MySQL relational data<br/>[mysql.ts]")]
  node_mongodb[("MongoDB and GridFS<br/>[mongodb.ts]")]
end

node_admin(("Admin"))
node_customer(("Customer"))

node_admin -->|"manages operations"| node_dashboard
node_customer -->|"browses medicines"| node_medlist
node_customer -->|"places orders"| node_checkout
node_authapi -->|"checks sessions"| node_authlib
node_medicineapi -->|"checks roles"| node_authlib
node_purchases -->|"checks roles"| node_authlib
node_sales -->|"checks roles"| node_authlib
node_reports -->|"checks roles"| node_authlib
node_medicineapi -->|"reads image metadata"| node_mongodb
node_imagesapi -->|"stores image files"| node_mongodb
node_medlist -->|"loads image metadata"| node_mongodb
node_customerorders -->|"checks customer role"| node_authlib
node_delivery -->|"checks customer role"| node_authlib

click node_dashboard "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/(dashboard)/dashboard-shell.tsx"
click node_authpages "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/login/page.tsx"
click node_authapi "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/auth/login/route.ts"
click node_authlib "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/lib/auth.ts"
click node_medlist "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/page.tsx"
click node_addcart "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/add-to-cart-button.tsx"
click node_cartbar "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/floating-cart-bar.tsx"
click node_gallery "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/medicine-image-gallery.tsx"
click node_wishlistbutton "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/save-to-wishlist-button.tsx"
click node_accountmenu "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/store-account-menu.tsx"
click node_medicineapi "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/medicines/route.ts"
click node_imagesapi "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/medicines/%5Bid%5D/images/route.ts"
click node_inventory "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/inventory/route.ts"
click node_purchases "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/purchases/route.ts"
click node_suppliers "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/suppliers/route.ts"
click node_sales "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/sales/route.ts"
click node_reports "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/reports/route.ts"
click node_dashboardpages "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/(dashboard)/inventory/page.tsx"
click node_checkout "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/checkout/page.tsx"
click node_customerorders "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/customer/orders/route.ts"
click node_delivery "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/customer/delivery-details/route.ts"
click node_wishlistapi "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/customer/wishlist/route.ts"
click node_mysql "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/lib/mysql.ts"
click node_mongodb "https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/lib/mongodb.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_dashboard,node_authpages,node_authapi,node_authlib toneBlue
class node_medlist,node_addcart,node_cartbar,node_gallery,node_wishlistbutton,node_accountmenu toneAmber
class node_medicineapi,node_imagesapi,node_inventory,node_purchases,node_suppliers,node_sales,node_reports,node_dashboardpages toneMint
class node_checkout,node_customerorders,node_delivery,node_wishlistapi toneRose
class node_mysql,node_mongodb,node_admin,node_customer toneIndigo
```

## Components

### Access and dashboard

- [Admin dashboard](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/(dashboard)/dashboard-shell.tsx): `frontend/app/(dashboard)/dashboard-shell.tsx`
- [Sign-in and registration](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/login/page.tsx): `frontend/app/login/page.tsx`
- [Authentication routes](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/auth/login/route.ts): `frontend/app/api/auth/login/route.ts`
- [Session and role checks](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/lib/auth.ts): `frontend/lib/auth.ts`

### Medicine catalog

- [Medicine catalog](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/page.tsx): `frontend/app/store/page.tsx`
- [Add to cart](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/add-to-cart-button.tsx): `frontend/app/store/add-to-cart-button.tsx`
- [Floating cart](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/floating-cart-bar.tsx): `frontend/app/store/floating-cart-bar.tsx`
- [Medicine image gallery](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/medicine-image-gallery.tsx): `frontend/app/store/medicine-image-gallery.tsx`
- [Save to wishlist](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/save-to-wishlist-button.tsx): `frontend/app/store/save-to-wishlist-button.tsx`
- [Store account menu](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/store/store-account-menu.tsx): `frontend/app/store/store-account-menu.tsx`

### Inventory operations

- [Medicine management API](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/medicines/route.ts): `frontend/app/api/medicines/route.ts`
- [Medicine image API](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/medicines/%5Bid%5D/images/route.ts): `frontend/app/api/medicines/[id]/images/route.ts`
- [Stock and adjustments](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/inventory/route.ts): `frontend/app/api/inventory/route.ts`
- [Purchases](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/purchases/route.ts): `frontend/app/api/purchases/route.ts`
- [Supplier management](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/suppliers/route.ts): `frontend/app/api/suppliers/route.ts`
- [Sales](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/sales/route.ts): `frontend/app/api/sales/route.ts`
- [Reports](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/reports/route.ts): `frontend/app/api/reports/route.ts`
- [Admin workspaces](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/(dashboard)/inventory/page.tsx): `frontend/app/(dashboard)/inventory/page.tsx`

### Customer shopping

- [Cart and checkout](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/checkout/page.tsx): `frontend/app/checkout/page.tsx`
- [Customer orders](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/customer/orders/route.ts): `frontend/app/api/customer/orders/route.ts`
- [Delivery details](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/customer/delivery-details/route.ts): `frontend/app/api/customer/delivery-details/route.ts`
- [Wishlist API](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/app/api/customer/wishlist/route.ts): `frontend/app/api/customer/wishlist/route.ts`

### Data stores

- [MySQL relational data](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/lib/mysql.ts): `frontend/lib/mysql.ts`
- [MongoDB and GridFS](https://github.com/chandrakanth2704/smart-medical-inventory-management-system/blob/main/frontend/lib/mongodb.ts): `frontend/lib/mongodb.ts`

### Other components

- **Admin**
- **Customer**

## Connections

- Admin → Admin dashboard: manages operations (evidence: `README.md`)
- Customer → Medicine catalog: browses medicines (evidence: `README.md`)
- Customer → Cart and checkout: places orders (evidence: `README.md`)
- Authentication routes → Session and role checks: checks sessions (evidence: `frontend/lib/auth.ts`)
- Medicine management API → Session and role checks: checks roles (evidence: `frontend/app/api/medicines/route.ts`)
- Purchases → Session and role checks: checks roles (evidence: `frontend/app/api/purchases/route.ts`)
- Sales → Session and role checks: checks roles (evidence: `frontend/app/api/sales/route.ts`)
- Reports → Session and role checks: checks roles (evidence: `frontend/app/api/reports/route.ts`)
- Medicine management API → MongoDB and GridFS: reads image metadata (evidence: `frontend/app/api/medicines/route.ts`)
- Medicine image API → MongoDB and GridFS: stores image files (evidence: `frontend/app/api/medicines/[id]/images/route.ts`)
- Medicine catalog → MongoDB and GridFS: loads image metadata (evidence: `frontend/app/store/page.tsx`)
- Customer orders → Session and role checks: checks customer role (evidence: `frontend/app/api/customer/orders/route.ts`)
- Delivery details → Session and role checks: checks customer role (evidence: `frontend/app/api/customer/delivery-details/route.ts`)
