# dweenmd/pharmadaily architecture

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

- Interactive diagram: https://gitdiagram.com/dweenmd/pharmadaily
- Repository: https://github.com/dweenmd/pharmadaily

## Overview

PharmaDaily is a multi-branch pharmacy management PWA. Staff sign in, work within a branch, and complete operational tasks such as selling medicines, receiving purchases, managing stock, and transferring inventory; those records feed cash, customer/supplier balances, dashboards, and reports. The README documents database-enforced branch isolation and transactional sale, purchase, adjustment, and transfer behavior. The source index shows key page-to-feature and client-to-action/query links; unsampled subsystems are represented at their existing feature paths, without assuming internal call wiring.

Main entry points: [`src/app/(protected)/dashboard/page.tsx`](https://github.com/dweenmd/pharmadaily/blob/main/src/app/(protected)/dashboard/page.tsx) (Dashboard), [`src/features/sales/components/pos-terminal.tsx`](https://github.com/dweenmd/pharmadaily/blob/main/src/features/sales/components/pos-terminal.tsx) (Point of sale), [`src/features/suppliers/queries.ts`](https://github.com/dweenmd/pharmadaily/blob/main/src/features/suppliers/queries.ts) (Supplier accounts), [`src/features/expenses/components/expenses-client.tsx`](https://github.com/dweenmd/pharmadaily/blob/main/src/features/expenses/components/expenses-client.tsx) (Expenses)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and shell"]
  node_login["Sign in<br/>[page.tsx]"]
  node_workspace["Protected workspace<br/>[layout.tsx]"]
  node_authlogic["Authentication<br/>[actions.ts]"]
  node_staffadmin["Staff and permissions"]
  node_settings["Branch settings"]
  node_ui["Shared UI primitives<br/>[button.tsx]"]
  node_branches["Branch management<br/>[queries.ts]"]
end

subgraph group_operations["Pharmacy operations"]
  node_catalog["Medicine catalog"]
  node_pos["Point of sale<br/>[pos-terminal.tsx]"]
  node_saleslogic["Sales processing<br/>[actions.ts]"]
  node_purchases["Purchasing"]
  node_stock["Stock management<br/>[queries.ts]"]
  node_transfers["Branch transfers"]
  node_customers["Customer accounts"]
  node_suppliers["Supplier accounts<br/>[queries.ts]"]
end

subgraph group_insight["Finance and insight"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_cash["Till and cash"]
  node_expenses["Expenses"]
  node_reports["Reports"]
end

subgraph group_platform["Data and resilience"]
  node_audit["Audit trail"]
  node_notifications["Notifications"]
  node_offline[("Offline queue and sync<br/>[db.ts]")]
  node_supabase[("Supabase database")]
  node_serverclient["Cookie-bound server client<br/>[server.ts]"]
  node_types["Database types<br/>[database.types.ts]"]
end

node_staff(("Pharmacy staff"))

node_staff -->|"signs in"| node_login
node_login -->|"uses form"| node_authlogic
node_staff -.->|"uses"| node_workspace
node_workspace -.->|"opens"| node_dashboard
node_dashboard -->|"reads"| node_stock
node_dashboard -->|"reads"| node_reports
node_dashboard -->|"reads"| node_branches
node_pos -.->|"submits sale"| node_saleslogic
node_saleslogic -->|"records transaction"| node_supabase
node_purchases -->|"records purchase"| node_supabase
node_stock -->|"adjusts stock"| node_supabase
node_transfers -->|"moves stock"| node_supabase
node_customers -.->|"stores accounts"| node_supabase
node_suppliers -.->|"stores balances"| node_supabase
node_cash -.->|"reads till data"| node_supabase
node_expenses -.->|"records expenses"| node_supabase
node_reports -.->|"queries metrics"| node_supabase
node_staffadmin -.->|"manages staff"| node_supabase
node_settings -.->|"stores settings"| node_supabase
node_audit -.->|"reads audit log"| node_supabase
node_notifications -.->|"reads notifications"| node_supabase
node_serverclient -->|"queries as user"| node_supabase
node_serverclient -->|"types client"| node_types
node_offline -.->|"syncs queued work"| node_supabase
node_pos -.->|"selects medicines"| node_catalog
node_expenses -->|"creates expense"| node_supabase
node_suppliers -->|"reuses payment dialog"| node_customers

click node_login "https://github.com/dweenmd/pharmadaily/blob/main/src/app/(auth)/login/page.tsx"
click node_workspace "https://github.com/dweenmd/pharmadaily/blob/main/src/app/(protected)/layout.tsx"
click node_authlogic "https://github.com/dweenmd/pharmadaily/blob/main/src/features/auth/actions.ts"
click node_dashboard "https://github.com/dweenmd/pharmadaily/blob/main/src/app/(protected)/dashboard/page.tsx"
click node_catalog "https://github.com/dweenmd/pharmadaily/tree/main/src/features/medicines"
click node_pos "https://github.com/dweenmd/pharmadaily/blob/main/src/features/sales/components/pos-terminal.tsx"
click node_saleslogic "https://github.com/dweenmd/pharmadaily/blob/main/src/features/sales/actions.ts"
click node_purchases "https://github.com/dweenmd/pharmadaily/tree/main/src/features/purchases"
click node_stock "https://github.com/dweenmd/pharmadaily/blob/main/src/features/stock/queries.ts"
click node_transfers "https://github.com/dweenmd/pharmadaily/tree/main/src/features/transfers"
click node_customers "https://github.com/dweenmd/pharmadaily/tree/main/src/features/customers"
click node_suppliers "https://github.com/dweenmd/pharmadaily/blob/main/src/features/suppliers/queries.ts"
click node_cash "https://github.com/dweenmd/pharmadaily/tree/main/src/features/cash"
click node_expenses "https://github.com/dweenmd/pharmadaily/blob/main/src/features/expenses/components/expenses-client.tsx"
click node_reports "https://github.com/dweenmd/pharmadaily/tree/main/src/features/reports"
click node_staffadmin "https://github.com/dweenmd/pharmadaily/tree/main/src/features/staff"
click node_settings "https://github.com/dweenmd/pharmadaily/tree/main/src/features/settings"
click node_audit "https://github.com/dweenmd/pharmadaily/tree/main/src/features/audit"
click node_notifications "https://github.com/dweenmd/pharmadaily/tree/main/src/features/notifications"
click node_offline "https://github.com/dweenmd/pharmadaily/blob/main/src/lib/offline/db.ts"
click node_serverclient "https://github.com/dweenmd/pharmadaily/blob/main/src/lib/supabase/server.ts"
click node_types "https://github.com/dweenmd/pharmadaily/blob/main/src/types/database.types.ts"
click node_ui "https://github.com/dweenmd/pharmadaily/blob/main/src/components/ui/button.tsx"
click node_branches "https://github.com/dweenmd/pharmadaily/blob/main/src/features/branches/queries.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_login,node_workspace,node_authlogic,node_staffadmin,node_settings,node_ui,node_branches toneBlue
class node_catalog,node_pos,node_saleslogic,node_purchases,node_stock,node_transfers,node_customers,node_suppliers toneAmber
class node_dashboard,node_cash,node_expenses,node_reports toneMint
class node_audit,node_notifications,node_offline,node_supabase,node_serverclient,node_types toneRose
class node_staff toneIndigo
```

## Components

### Access and shell

- [Sign in](https://github.com/dweenmd/pharmadaily/blob/main/src/app/(auth)/login/page.tsx): `src/app/(auth)/login/page.tsx`
- [Protected workspace](https://github.com/dweenmd/pharmadaily/blob/main/src/app/(protected)/layout.tsx): `src/app/(protected)/layout.tsx`
- [Authentication](https://github.com/dweenmd/pharmadaily/blob/main/src/features/auth/actions.ts): `src/features/auth/actions.ts`
- [Staff and permissions](https://github.com/dweenmd/pharmadaily/tree/main/src/features/staff): `src/features/staff`
- [Branch settings](https://github.com/dweenmd/pharmadaily/tree/main/src/features/settings): `src/features/settings`
- [Shared UI primitives](https://github.com/dweenmd/pharmadaily/blob/main/src/components/ui/button.tsx): `src/components/ui/button.tsx`
- [Branch management](https://github.com/dweenmd/pharmadaily/blob/main/src/features/branches/queries.ts): `src/features/branches/queries.ts`

### Pharmacy operations

- [Medicine catalog](https://github.com/dweenmd/pharmadaily/tree/main/src/features/medicines): `src/features/medicines`
- [Point of sale](https://github.com/dweenmd/pharmadaily/blob/main/src/features/sales/components/pos-terminal.tsx): `src/features/sales/components/pos-terminal.tsx`
- [Sales processing](https://github.com/dweenmd/pharmadaily/blob/main/src/features/sales/actions.ts): `src/features/sales/actions.ts`
- [Purchasing](https://github.com/dweenmd/pharmadaily/tree/main/src/features/purchases): `src/features/purchases`
- [Stock management](https://github.com/dweenmd/pharmadaily/blob/main/src/features/stock/queries.ts): `src/features/stock/queries.ts`
- [Branch transfers](https://github.com/dweenmd/pharmadaily/tree/main/src/features/transfers): `src/features/transfers`
- [Customer accounts](https://github.com/dweenmd/pharmadaily/tree/main/src/features/customers): `src/features/customers`
- [Supplier accounts](https://github.com/dweenmd/pharmadaily/blob/main/src/features/suppliers/queries.ts): `src/features/suppliers/queries.ts`

### Finance and insight

- [Dashboard](https://github.com/dweenmd/pharmadaily/blob/main/src/app/(protected)/dashboard/page.tsx): `src/app/(protected)/dashboard/page.tsx`
- [Till and cash](https://github.com/dweenmd/pharmadaily/tree/main/src/features/cash): `src/features/cash`
- [Expenses](https://github.com/dweenmd/pharmadaily/blob/main/src/features/expenses/components/expenses-client.tsx): `src/features/expenses/components/expenses-client.tsx`
- [Reports](https://github.com/dweenmd/pharmadaily/tree/main/src/features/reports): `src/features/reports`

### Data and resilience

- [Audit trail](https://github.com/dweenmd/pharmadaily/tree/main/src/features/audit): `src/features/audit`
- [Notifications](https://github.com/dweenmd/pharmadaily/tree/main/src/features/notifications): `src/features/notifications`
- [Offline queue and sync](https://github.com/dweenmd/pharmadaily/blob/main/src/lib/offline/db.ts): `src/lib/offline/db.ts`
- **Supabase database**
- [Cookie-bound server client](https://github.com/dweenmd/pharmadaily/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`
- [Database types](https://github.com/dweenmd/pharmadaily/blob/main/src/types/database.types.ts): `src/types/database.types.ts`

### Other components

- **Pharmacy staff**

## Connections

- Pharmacy staff → Sign in: signs in (evidence: `src/app/(auth)/login/page.tsx`)
- Sign in → Authentication: uses form (evidence: `src/app/(auth)/login/page.tsx`)
- Pharmacy staff → Protected workspace: uses
- Protected workspace → Dashboard: opens
- Dashboard → Stock management: reads (evidence: `src/app/(protected)/dashboard/page.tsx`)
- Dashboard → Reports: reads (evidence: `src/app/(protected)/dashboard/page.tsx`)
- Dashboard → Branch management: reads (evidence: `src/app/(protected)/dashboard/page.tsx`)
- Point of sale → Sales processing: submits sale
- Sales processing → Supabase database: records transaction (evidence: `README.md`)
- Purchasing → Supabase database: records purchase (evidence: `README.md`)
- Stock management → Supabase database: adjusts stock (evidence: `README.md`)
- Branch transfers → Supabase database: moves stock (evidence: `README.md`)
- Customer accounts → Supabase database: stores accounts
- Supplier accounts → Supabase database: stores balances
- Till and cash → Supabase database: reads till data
- Expenses → Supabase database: records expenses
- Reports → Supabase database: queries metrics
- Staff and permissions → Supabase database: manages staff
- Branch settings → Supabase database: stores settings
- Audit trail → Supabase database: reads audit log
- Notifications → Supabase database: reads notifications
- Cookie-bound server client → Supabase database: queries as user (evidence: `src/lib/supabase/server.ts`)
- Cookie-bound server client → Database types: types client (evidence: `src/lib/supabase/server.ts`)
- Offline queue and sync → Supabase database: syncs queued work (evidence: `README.md`)
- Point of sale → Medicine catalog: selects medicines
- Expenses → Supabase database: creates expense (evidence: `src/features/expenses/components/expenses-client.tsx`)
- Supplier accounts → Customer accounts: reuses payment dialog (evidence: `src/features/suppliers/components/suppliers-client.tsx`)
