# nwgkgit/pharma architecture

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

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

## Overview

This Expo pharmacy app lets staff browse stock, place orders that reduce quantities and create transaction history, and manage inventory by adding, editing, or deleting medicines. Navigation leads from the tab bar into the home, transaction, and inventory-management screens; context providers expose medicine and transaction state to those flows. Medicine records use SQLite, while transaction history is persisted in AsyncStorage. The README also highlights expiration dates and quantity tracking; source excerpts are limited, so only documented capabilities and visible calls are linked.

Main entry points: [`components/navigation/AddStackNavigator.js`](https://github.com/nwgkgit/pharma/blob/main/components/navigation/AddStackNavigator.js) (Inventory routes), [`components/contexts/MedicineContext.js`](https://github.com/nwgkgit/pharma/blob/main/components/contexts/MedicineContext.js) (Medicine state), [`components/navigation/BottomTabNavigator.js`](https://github.com/nwgkgit/pharma/blob/main/components/navigation/BottomTabNavigator.js) (Main tabs), [`components/screens/DeleteMedicineScreen.js`](https://github.com/nwgkgit/pharma/blob/main/components/screens/DeleteMedicineScreen.js) (Select stock to delete)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_navigation["App navigation"]
  node_app["App providers<br/>[App.js]"]
  node_tabs["Main tabs"]
  node_addnav["Inventory routes"]
end

subgraph group_inventory["Inventory management"]
  node_addscreen["Inventory actions<br/>[AddScreen.js]"]
  node_newform["New medicine form<br/>[NewMedicineForm.js]"]
  node_editsearch["Find medicine to edit<br/>[EditSearch.js]"]
  node_editform["Edit medicine form"]
  node_existingsearch["Find existing stock<br/>[AddExistSearch.js]"]
  node_existingform["Add existing stock"]
  node_deletescreen["Select stock to delete"]
  node_deletecard["Deletion selection card<br/>[MedicineCardDel.js]"]
  node_deletemodal["Delete confirmation<br/>[DeleteModal.js]"]
  node_medicinecard["Stock and quantity card<br/>[MedicineCard.jsx]"]
  node_simplecard["Medicine selection card"]
end

subgraph group_sales["Orders and history"]
  node_home["Stock browser<br/>[HomeScreen.js]"]
  node_order["Order confirmation<br/>[OrderModal.jsx]"]
  node_transactionscreen["Transaction history"]
  node_transactioncard["Transaction display<br/>[TransactionCard.js]"]
end

subgraph group_state["State and persistence"]
  node_medicinecontext["Medicine state<br/>[MedicineContext.js]"]
  node_transactioncontext["Transaction state"]
  node_sqlite[("Inventory SQLite<br/>[database.js]")]
  node_asyncstorage[("Transaction storage")]
end

node_staff(("Pharmacy staff"))

node_staff -->|"uses app"| node_tabs
node_app -->|"renders"| node_tabs
node_app -->|"provides state"| node_medicinecontext
node_app -->|"provides state"| node_transactioncontext
node_tabs -->|"routes to"| node_home
node_tabs -->|"routes to"| node_transactionscreen
node_tabs -->|"routes to"| node_addnav
node_addnav -->|"routes to"| node_addscreen
node_addnav -->|"routes to"| node_editsearch
node_addnav -->|"routes to"| node_editform
node_addnav -->|"routes to"| node_newform
node_addnav -->|"routes to"| node_existingsearch
node_addnav -->|"routes to"| node_existingform
node_addnav -->|"routes to"| node_deletescreen
node_home -->|"reads stock"| node_medicinecontext
node_home -->|"renders"| node_medicinecard
node_home -->|"opens order"| node_order
node_order -->|"updates quantities"| node_medicinecontext
node_order -->|"records sale"| node_transactioncontext
node_transactionscreen -->|"reads history"| node_transactioncontext
node_transactionscreen -->|"renders"| node_transactioncard
node_editsearch -->|"reads stock"| node_medicinecontext
node_editsearch -->|"renders"| node_simplecard
node_existingsearch -->|"reads stock"| node_medicinecontext
node_existingsearch -->|"renders"| node_simplecard
node_deletescreen -->|"reads stock"| node_medicinecontext
node_deletescreen -->|"renders"| node_deletecard
node_deletescreen -->|"opens confirmation"| node_deletemodal
node_medicinecontext -->|"reads and writes"| node_sqlite
node_transactioncontext -->|"loads and saves"| node_asyncstorage

click node_app "https://github.com/nwgkgit/pharma/blob/main/App.js"
click node_tabs "https://github.com/nwgkgit/pharma/blob/main/components/navigation/BottomTabNavigator.js"
click node_addnav "https://github.com/nwgkgit/pharma/blob/main/components/navigation/AddStackNavigator.js"
click node_home "https://github.com/nwgkgit/pharma/blob/main/components/screens/HomeScreen.js"
click node_order "https://github.com/nwgkgit/pharma/blob/main/components/OrderModal.jsx"
click node_transactionscreen "https://github.com/nwgkgit/pharma/blob/main/components/screens/TransactionScreen.js"
click node_transactioncard "https://github.com/nwgkgit/pharma/blob/main/components/TransactionCard.js"
click node_addscreen "https://github.com/nwgkgit/pharma/blob/main/components/screens/AddScreen.js"
click node_newform "https://github.com/nwgkgit/pharma/blob/main/components/NewMedicineForm.js"
click node_editsearch "https://github.com/nwgkgit/pharma/blob/main/components/EditSearch.js"
click node_editform "https://github.com/nwgkgit/pharma/blob/main/components/EditMedicineForm.js"
click node_existingsearch "https://github.com/nwgkgit/pharma/blob/main/components/AddExistSearch.js"
click node_existingform "https://github.com/nwgkgit/pharma/blob/main/components/screens/AddExistingMedicineForm.js"
click node_deletescreen "https://github.com/nwgkgit/pharma/blob/main/components/screens/DeleteMedicineScreen.js"
click node_deletecard "https://github.com/nwgkgit/pharma/blob/main/components/MedicineCardDel.js"
click node_deletemodal "https://github.com/nwgkgit/pharma/blob/main/components/DeleteModal.js"
click node_medicinecard "https://github.com/nwgkgit/pharma/blob/main/components/MedicineCard.jsx"
click node_simplecard "https://github.com/nwgkgit/pharma/blob/main/components/MedicineCardWithoutAmount.js"
click node_medicinecontext "https://github.com/nwgkgit/pharma/blob/main/components/contexts/MedicineContext.js"
click node_transactioncontext "https://github.com/nwgkgit/pharma/blob/main/components/contexts/TransactionContext.js"
click node_sqlite "https://github.com/nwgkgit/pharma/blob/main/database/database.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_tabs,node_addnav toneBlue
class node_addscreen,node_newform,node_editsearch,node_editform,node_existingsearch,node_existingform,node_deletescreen,node_deletecard,node_deletemodal,node_medicinecard,node_simplecard toneAmber
class node_home,node_order,node_transactionscreen,node_transactioncard toneMint
class node_medicinecontext,node_transactioncontext,node_sqlite,node_asyncstorage toneRose
class node_staff toneIndigo
```

## Components

### App navigation

- [App providers](https://github.com/nwgkgit/pharma/blob/main/App.js): `App.js`
- [Main tabs](https://github.com/nwgkgit/pharma/blob/main/components/navigation/BottomTabNavigator.js): `components/navigation/BottomTabNavigator.js`
- [Inventory routes](https://github.com/nwgkgit/pharma/blob/main/components/navigation/AddStackNavigator.js): `components/navigation/AddStackNavigator.js`

### Inventory management

- [Inventory actions](https://github.com/nwgkgit/pharma/blob/main/components/screens/AddScreen.js): `components/screens/AddScreen.js`
- [New medicine form](https://github.com/nwgkgit/pharma/blob/main/components/NewMedicineForm.js): `components/NewMedicineForm.js`
- [Find medicine to edit](https://github.com/nwgkgit/pharma/blob/main/components/EditSearch.js): `components/EditSearch.js`
- [Edit medicine form](https://github.com/nwgkgit/pharma/blob/main/components/EditMedicineForm.js): `components/EditMedicineForm.js`
- [Find existing stock](https://github.com/nwgkgit/pharma/blob/main/components/AddExistSearch.js): `components/AddExistSearch.js`
- [Add existing stock](https://github.com/nwgkgit/pharma/blob/main/components/screens/AddExistingMedicineForm.js): `components/screens/AddExistingMedicineForm.js`
- [Select stock to delete](https://github.com/nwgkgit/pharma/blob/main/components/screens/DeleteMedicineScreen.js): `components/screens/DeleteMedicineScreen.js`
- [Deletion selection card](https://github.com/nwgkgit/pharma/blob/main/components/MedicineCardDel.js): `components/MedicineCardDel.js`
- [Delete confirmation](https://github.com/nwgkgit/pharma/blob/main/components/DeleteModal.js): `components/DeleteModal.js`
- [Stock and quantity card](https://github.com/nwgkgit/pharma/blob/main/components/MedicineCard.jsx): `components/MedicineCard.jsx`
- [Medicine selection card](https://github.com/nwgkgit/pharma/blob/main/components/MedicineCardWithoutAmount.js): `components/MedicineCardWithoutAmount.js`

### Orders and history

- [Stock browser](https://github.com/nwgkgit/pharma/blob/main/components/screens/HomeScreen.js): `components/screens/HomeScreen.js`
- [Order confirmation](https://github.com/nwgkgit/pharma/blob/main/components/OrderModal.jsx): `components/OrderModal.jsx`
- [Transaction history](https://github.com/nwgkgit/pharma/blob/main/components/screens/TransactionScreen.js): `components/screens/TransactionScreen.js`
- [Transaction display](https://github.com/nwgkgit/pharma/blob/main/components/TransactionCard.js): `components/TransactionCard.js`

### State and persistence

- [Medicine state](https://github.com/nwgkgit/pharma/blob/main/components/contexts/MedicineContext.js): `components/contexts/MedicineContext.js`
- [Transaction state](https://github.com/nwgkgit/pharma/blob/main/components/contexts/TransactionContext.js): `components/contexts/TransactionContext.js`
- [Inventory SQLite](https://github.com/nwgkgit/pharma/blob/main/database/database.js): `database/database.js`
- **Transaction storage**

### Other components

- **Pharmacy staff**

## Connections

- Pharmacy staff → Main tabs: uses app (evidence: `components/navigation/BottomTabNavigator.js`)
- App providers → Main tabs: renders (evidence: `App.js`)
- App providers → Medicine state: provides state (evidence: `App.js`)
- App providers → Transaction state: provides state (evidence: `App.js`)
- Main tabs → Stock browser: routes to (evidence: `components/navigation/BottomTabNavigator.js`)
- Main tabs → Transaction history: routes to (evidence: `components/navigation/BottomTabNavigator.js`)
- Main tabs → Inventory routes: routes to (evidence: `components/navigation/BottomTabNavigator.js`)
- Inventory routes → Inventory actions: routes to (evidence: `components/navigation/AddStackNavigator.js`)
- Inventory routes → Find medicine to edit: routes to (evidence: `components/navigation/AddStackNavigator.js`)
- Inventory routes → Edit medicine form: routes to (evidence: `components/navigation/AddStackNavigator.js`)
- Inventory routes → New medicine form: routes to (evidence: `components/navigation/AddStackNavigator.js`)
- Inventory routes → Find existing stock: routes to (evidence: `components/navigation/AddStackNavigator.js`)
- Inventory routes → Add existing stock: routes to (evidence: `components/navigation/AddStackNavigator.js`)
- Inventory routes → Select stock to delete: routes to (evidence: `components/navigation/AddStackNavigator.js`)
- Stock browser → Medicine state: reads stock (evidence: `components/screens/HomeScreen.js`)
- Stock browser → Stock and quantity card: renders (evidence: `components/screens/HomeScreen.js`)
- Stock browser → Order confirmation: opens order (evidence: `components/screens/HomeScreen.js`)
- Order confirmation → Medicine state: updates quantities (evidence: `components/OrderModal.jsx`)
- Order confirmation → Transaction state: records sale (evidence: `components/OrderModal.jsx`)
- Transaction history → Transaction state: reads history (evidence: `components/screens/TransactionScreen.js`)
- Transaction history → Transaction display: renders (evidence: `components/screens/TransactionScreen.js`)
- Find medicine to edit → Medicine state: reads stock (evidence: `components/EditSearch.js`)
- Find medicine to edit → Medicine selection card: renders (evidence: `components/EditSearch.js`)
- Find existing stock → Medicine state: reads stock (evidence: `components/AddExistSearch.js`)
- Find existing stock → Medicine selection card: renders (evidence: `components/AddExistSearch.js`)
- Select stock to delete → Medicine state: reads stock (evidence: `components/screens/DeleteMedicineScreen.js`)
- Select stock to delete → Deletion selection card: renders (evidence: `components/screens/DeleteMedicineScreen.js`)
- Select stock to delete → Delete confirmation: opens confirmation (evidence: `components/screens/DeleteMedicineScreen.js`)
- Medicine state → Inventory SQLite: reads and writes (evidence: `components/contexts/MedicineContext.js`)
- Transaction state → Transaction storage: loads and saves (evidence: `components/contexts/TransactionContext.js`)
