# gerald-hub123/medsms architecture

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

- Interactive diagram: https://gitdiagram.com/gerald-hub123/medsms
- Repository: https://github.com/gerald-hub123/medsms

## Overview

MedSMS is a PHP medical-supplies management application for administrators, manufacturers, and hospital managers (called retailers in the code). Its main visible workflow lets a hospital manager review and search orders, then inspect invoices; manufacturers manage products and process orders, while administrators maintain users and reference data. The sampled pages issue SQL directly rather than using a visible data-access layer. Other order, invoice, stock, and catalog capabilities are represented from filenames, but their internal links are not verified in the excerpts.

Main entry points: [`add_product.php`](https://github.com/gerald-hub123/medsms/blob/main/add_product.php) (Product catalog), [`view_invoice.php`](https://github.com/gerald-hub123/medsms/blob/main/view_invoice.php) (Invoice search), [`add_manufacturer.php`](https://github.com/gerald-hub123/medsms/blob/main/add_manufacturer.php) (Account management), [`add_hospital_manager.php`](https://github.com/gerald-hub123/medsms/blob/main/add_hospital_manager.php) (Hospital accounts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_accounts["Accounts and setup"]
  node_account_admin["Account management"]
  node_hospital_admin["Hospital accounts"]
  node_reference_data["Area and category setup<br/>[add_area.php]"]
end

subgraph group_catalog["Catalog and stock"]
  node_catalog_manage["Product catalog<br/>[add_product.php]"]
  node_stock["Stock management<br/>[manage_stock.php]"]
  node_catalog_view["Product browsing<br/>[view_products.php]"]
end

subgraph group_orders["Orders"]
  node_order_entry["Order entry<br/>[order_items.php]"]
  node_order_insert["Order submission"]
  node_order_review["Order review<br/>[view_orders.php]"]
  node_order_confirm["Order confirmation<br/>[confirm_order.php]"]
  node_retailer_orders["My orders<br/>[view_my_orders.php]"]
end

subgraph group_billing["Invoices"]
  node_invoice_generate["Invoice generation"]
  node_invoice_insert["Invoice creation<br/>[insert_invoice.php]"]
  node_invoice_admin["Invoice search<br/>[view_invoice.php]"]
  node_invoice_retailer["My invoices"]
end

subgraph group_shared["Shared runtime"]
  node_jquery["jQuery browser library<br/>[jquery.js]"]
end

node_admin(("Administrator"))
node_manufacturer(("Manufacturer"))
node_hospital(("Hospital manager"))
node_db[("Application database")]

node_admin -.->|"manages accounts"| node_account_admin
node_admin -->|"adds managers"| node_hospital_admin
node_manufacturer -->|"manages products"| node_catalog_manage
node_manufacturer -->|"reviews orders"| node_order_review
node_hospital -->|"searches orders"| node_retailer_orders
node_hospital -->|"searches invoices"| node_invoice_retailer
node_catalog_manage -->|"writes products"| node_db
node_catalog_manage -->|"reads categories"| node_db
node_account_admin -->|"writes accounts"| node_db
node_hospital_admin -->|"reads areas"| node_db
node_retailer_orders -->|"queries orders"| node_db
node_order_review -->|"queries orders"| node_db
node_invoice_admin -->|"queries invoices"| node_db
node_invoice_retailer -->|"queries invoices"| node_db
node_manufacturer -.->|"confirms orders"| node_order_confirm
node_hospital -.->|"creates orders"| node_order_entry
node_order_entry -.->|"submits items"| node_order_insert
node_order_insert -.->|"stores orders"| node_db
node_order_confirm -.->|"updates status"| node_db
node_invoice_generate -.->|"prepares invoice"| node_invoice_insert
node_invoice_insert -.->|"stores invoice"| node_db
node_invoice_admin -->|"loads library"| node_jquery

click node_account_admin "https://github.com/gerald-hub123/medsms/blob/main/add_manufacturer.php"
click node_hospital_admin "https://github.com/gerald-hub123/medsms/blob/main/add_hospital_manager.php"
click node_reference_data "https://github.com/gerald-hub123/medsms/blob/main/add_area.php"
click node_catalog_manage "https://github.com/gerald-hub123/medsms/blob/main/add_product.php"
click node_stock "https://github.com/gerald-hub123/medsms/blob/main/manage_stock.php"
click node_catalog_view "https://github.com/gerald-hub123/medsms/blob/main/view_products.php"
click node_order_entry "https://github.com/gerald-hub123/medsms/blob/main/order_items.php"
click node_order_insert "https://github.com/gerald-hub123/medsms/blob/main/insert_man_order.php"
click node_order_review "https://github.com/gerald-hub123/medsms/blob/main/view_orders.php"
click node_order_confirm "https://github.com/gerald-hub123/medsms/blob/main/confirm_order.php"
click node_retailer_orders "https://github.com/gerald-hub123/medsms/blob/main/view_my_orders.php"
click node_invoice_generate "https://github.com/gerald-hub123/medsms/blob/main/generate_invoice.php"
click node_invoice_insert "https://github.com/gerald-hub123/medsms/blob/main/insert_invoice.php"
click node_invoice_admin "https://github.com/gerald-hub123/medsms/blob/main/view_invoice.php"
click node_invoice_retailer "https://github.com/gerald-hub123/medsms/blob/main/view_my_invoices.php"
click node_jquery "https://github.com/gerald-hub123/medsms/blob/main/jquery.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_account_admin,node_hospital_admin,node_reference_data toneBlue
class node_catalog_manage,node_stock,node_catalog_view,node_db toneAmber
class node_order_entry,node_order_insert,node_order_review,node_order_confirm,node_retailer_orders toneMint
class node_invoice_generate,node_invoice_insert,node_invoice_admin,node_invoice_retailer toneRose
class node_jquery,node_admin,node_manufacturer,node_hospital toneIndigo
```

## Components

### Accounts and setup

- [Account management](https://github.com/gerald-hub123/medsms/blob/main/add_manufacturer.php): `add_manufacturer.php`
- [Hospital accounts](https://github.com/gerald-hub123/medsms/blob/main/add_hospital_manager.php): `add_hospital_manager.php`
- [Area and category setup](https://github.com/gerald-hub123/medsms/blob/main/add_area.php): `add_area.php`

### Catalog and stock

- [Product catalog](https://github.com/gerald-hub123/medsms/blob/main/add_product.php): `add_product.php`
- [Stock management](https://github.com/gerald-hub123/medsms/blob/main/manage_stock.php): `manage_stock.php`
- [Product browsing](https://github.com/gerald-hub123/medsms/blob/main/view_products.php): `view_products.php`

### Orders

- [Order entry](https://github.com/gerald-hub123/medsms/blob/main/order_items.php): `order_items.php`
- [Order submission](https://github.com/gerald-hub123/medsms/blob/main/insert_man_order.php): `insert_man_order.php`
- [Order review](https://github.com/gerald-hub123/medsms/blob/main/view_orders.php): `view_orders.php`
- [Order confirmation](https://github.com/gerald-hub123/medsms/blob/main/confirm_order.php): `confirm_order.php`
- [My orders](https://github.com/gerald-hub123/medsms/blob/main/view_my_orders.php): `view_my_orders.php`

### Invoices

- [Invoice generation](https://github.com/gerald-hub123/medsms/blob/main/generate_invoice.php): `generate_invoice.php`
- [Invoice creation](https://github.com/gerald-hub123/medsms/blob/main/insert_invoice.php): `insert_invoice.php`
- [Invoice search](https://github.com/gerald-hub123/medsms/blob/main/view_invoice.php): `view_invoice.php`
- [My invoices](https://github.com/gerald-hub123/medsms/blob/main/view_my_invoices.php): `view_my_invoices.php`

### Shared runtime

- [jQuery browser library](https://github.com/gerald-hub123/medsms/blob/main/jquery.js): `jquery.js`

### Other components

- **Administrator**
- **Manufacturer**
- **Hospital manager**
- **Application database**

## Connections

- Administrator → Account management: manages accounts
- Administrator → Hospital accounts: adds managers (evidence: `add_hospital_manager.php`)
- Manufacturer → Product catalog: manages products (evidence: `add_product.php`)
- Manufacturer → Order review: reviews orders (evidence: `view_orders.php`)
- Hospital manager → My orders: searches orders (evidence: `view_my_orders.php`)
- Hospital manager → My invoices: searches invoices (evidence: `view_my_invoices.php`)
- Product catalog → Application database: writes products (evidence: `add_product.php`)
- Product catalog → Application database: reads categories (evidence: `add_product.php`)
- Account management → Application database: writes accounts (evidence: `add_manufacturer.php`)
- Hospital accounts → Application database: reads areas (evidence: `add_hospital_manager.php`)
- My orders → Application database: queries orders (evidence: `view_my_orders.php`)
- Order review → Application database: queries orders (evidence: `view_orders.php`)
- Invoice search → Application database: queries invoices (evidence: `view_invoice.php`)
- My invoices → Application database: queries invoices (evidence: `view_my_invoices.php`)
- Manufacturer → Order confirmation: confirms orders
- Hospital manager → Order entry: creates orders
- Order entry → Order submission: submits items
- Order submission → Application database: stores orders
- Order confirmation → Application database: updates status
- Invoice generation → Invoice creation: prepares invoice
- Invoice creation → Application database: stores invoice
- Invoice search → jQuery browser library: loads library (evidence: `view_invoice.php`)
