# msmrfq/pharmnos-lite architecture

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

- Interactive diagram: https://gitdiagram.com/msmrfq/pharmnos-lite
- Repository: https://github.com/msmrfq/pharmnos-lite

## Overview

Pharmnos Lite is a pharmacy-management and financial-records application: users manage inventory, customers, suppliers, purchases, sales and billing, then review reports and exports. The sampled inventory page demonstrates a server-rendered tenant-scoped workflow: establish tenant context, query products, batches and stock movements through repositories, and present results in the dashboard. The tree also shows GST, payments, audit and settings capabilities. Several of those modules were not sampled, so their internal call paths are not asserted; dashed, uncited edges indicate unverified architectural relationships.

Main entry points: [`src/repositories/index.ts`](https://github.com/msmrfq/pharmnos-lite/blob/main/src/repositories/index.ts) (Repository factory), [`src/lib/db/tenant-context.ts`](https://github.com/msmrfq/pharmnos-lite/blob/main/src/lib/db/tenant-context.ts) (Tenant context), [`src/lib/db/prisma.ts`](https://github.com/msmrfq/pharmnos-lite/blob/main/src/lib/db/prisma.ts) (Prisma database client), [`src/app/inventory/page.tsx`](https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/inventory/page.tsx) (Inventory workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application experience"]
  node_dashboard["Dashboard shell"]
  node_inventory["Inventory workspace<br/>[page.tsx]"]
  node_sales["Sales and billing<br/>[page.tsx]"]
  node_purchases["Purchasing<br/>[page.tsx]"]
  node_masters["Business records<br/>[page.tsx]"]
  node_reports["Reports and exports<br/>[page.tsx]"]
  node_settings["Business settings<br/>[page.tsx]"]
end

subgraph group_domain["Business workflows"]
  node_gst["GST calculations"]
  node_aging["Aging reports"]
  node_reconciliation["Financial reconciliation"]
  node_decimal["Exact decimal arithmetic<br/>[decimal.ts]"]
end

subgraph group_data["Tenant data layer"]
  node_ledger["Ledger storage"]
  node_salesrepo["Sales invoice storage"]
  node_paymentrepo["Payment storage"]
  node_repos["Repository factory<br/>[index.ts]"]
  node_base["Repository base<br/>[base-repository.ts]"]
  node_prisma[("Prisma database client<br/>[prisma.ts]")]
end

subgraph group_identity["Identity and access"]
  node_auth["Authentication actions<br/>[auth.actions.ts]"]
  node_tenant["Tenant context<br/>[tenant-context.ts]"]
end

subgraph group_integrations["External services"]
  node_authadapter["Auth adapter"]
  node_postgres[("PostgreSQL")]
end

node_operator(("Pharmacy user"))

node_operator -.->|"uses"| node_dashboard
node_dashboard -->|"signs out via"| node_auth
node_inventory -->|"requires context"| node_tenant
node_inventory -->|"queries inventory"| node_repos
node_repos -->|"creates repositories"| node_prisma
node_repos -->|"creates"| node_salesrepo
node_repos -->|"creates"| node_paymentrepo
node_repos -->|"creates"| node_ledger
node_base -->|"validates tenant"| node_tenant
node_tenant -->|"gets session"| node_authadapter
node_tenant -->|"loads membership"| node_prisma
node_prisma -.->|"connects"| node_postgres
node_sales -.->|"records invoices"| node_salesrepo
node_purchases -.->|"uses tax calculations"| node_gst
node_sales -.->|"uses tax calculations"| node_gst
node_reports -.->|"includes aging"| node_aging
node_reports -.->|"supports reconciliation"| node_reconciliation
node_reconciliation -.->|"uses precise arithmetic"| node_decimal
node_aging -.->|"uses precise arithmetic"| node_decimal
node_masters -.->|"uses records"| node_repos
node_settings -->|"uses records"| node_repos

click node_dashboard "https://github.com/msmrfq/pharmnos-lite/blob/main/src/components/layout/dashboard-layout.tsx"
click node_inventory "https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/inventory/page.tsx"
click node_sales "https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/billing/page.tsx"
click node_purchases "https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/purchases/page.tsx"
click node_masters "https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/customers/page.tsx"
click node_reports "https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/reports/page.tsx"
click node_settings "https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/settings/page.tsx"
click node_auth "https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/auth/_actions/auth.actions.ts"
click node_tenant "https://github.com/msmrfq/pharmnos-lite/blob/main/src/lib/db/tenant-context.ts"
click node_authadapter "https://github.com/msmrfq/pharmnos-lite/blob/main/src/adapters/auth/supabase-auth.adapter.ts"
click node_gst "https://github.com/msmrfq/pharmnos-lite/blob/main/src/domain/services/gst-calculator.service.ts"
click node_aging "https://github.com/msmrfq/pharmnos-lite/blob/main/src/domain/services/aging-report.service.ts"
click node_reconciliation "https://github.com/msmrfq/pharmnos-lite/blob/main/src/domain/services/financial-reconciliation.service.ts"
click node_ledger "https://github.com/msmrfq/pharmnos-lite/blob/main/src/repositories/ledger.repository.ts"
click node_salesrepo "https://github.com/msmrfq/pharmnos-lite/blob/main/src/repositories/sales-invoice.repository.ts"
click node_paymentrepo "https://github.com/msmrfq/pharmnos-lite/blob/main/src/repositories/payment.repository.ts"
click node_repos "https://github.com/msmrfq/pharmnos-lite/blob/main/src/repositories/index.ts"
click node_base "https://github.com/msmrfq/pharmnos-lite/blob/main/src/lib/db/base-repository.ts"
click node_prisma "https://github.com/msmrfq/pharmnos-lite/blob/main/src/lib/db/prisma.ts"
click node_decimal "https://github.com/msmrfq/pharmnos-lite/blob/main/src/lib/decimal.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_inventory,node_sales,node_purchases,node_masters,node_reports,node_settings,node_operator toneBlue
class node_gst,node_aging,node_reconciliation,node_decimal toneAmber
class node_ledger,node_salesrepo,node_paymentrepo,node_repos,node_base,node_prisma toneMint
class node_auth,node_tenant toneRose
class node_authadapter,node_postgres toneIndigo
```

## Components

### Application experience

- [Dashboard shell](https://github.com/msmrfq/pharmnos-lite/blob/main/src/components/layout/dashboard-layout.tsx): `src/components/layout/dashboard-layout.tsx`
- [Inventory workspace](https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/inventory/page.tsx): `src/app/inventory/page.tsx`
- [Sales and billing](https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/billing/page.tsx): `src/app/billing/page.tsx`
- [Purchasing](https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/purchases/page.tsx): `src/app/purchases/page.tsx`
- [Business records](https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/customers/page.tsx): `src/app/customers/page.tsx`
- [Reports and exports](https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/reports/page.tsx): `src/app/reports/page.tsx`
- [Business settings](https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/settings/page.tsx): `src/app/settings/page.tsx`

### Business workflows

- [GST calculations](https://github.com/msmrfq/pharmnos-lite/blob/main/src/domain/services/gst-calculator.service.ts): `src/domain/services/gst-calculator.service.ts`
- [Aging reports](https://github.com/msmrfq/pharmnos-lite/blob/main/src/domain/services/aging-report.service.ts): `src/domain/services/aging-report.service.ts`
- [Financial reconciliation](https://github.com/msmrfq/pharmnos-lite/blob/main/src/domain/services/financial-reconciliation.service.ts): `src/domain/services/financial-reconciliation.service.ts`
- [Exact decimal arithmetic](https://github.com/msmrfq/pharmnos-lite/blob/main/src/lib/decimal.ts): `src/lib/decimal.ts`

### Tenant data layer

- [Ledger storage](https://github.com/msmrfq/pharmnos-lite/blob/main/src/repositories/ledger.repository.ts): `src/repositories/ledger.repository.ts`
- [Sales invoice storage](https://github.com/msmrfq/pharmnos-lite/blob/main/src/repositories/sales-invoice.repository.ts): `src/repositories/sales-invoice.repository.ts`
- [Payment storage](https://github.com/msmrfq/pharmnos-lite/blob/main/src/repositories/payment.repository.ts): `src/repositories/payment.repository.ts`
- [Repository factory](https://github.com/msmrfq/pharmnos-lite/blob/main/src/repositories/index.ts): `src/repositories/index.ts`
- [Repository base](https://github.com/msmrfq/pharmnos-lite/blob/main/src/lib/db/base-repository.ts): `src/lib/db/base-repository.ts`
- [Prisma database client](https://github.com/msmrfq/pharmnos-lite/blob/main/src/lib/db/prisma.ts): `src/lib/db/prisma.ts`

### Identity and access

- [Authentication actions](https://github.com/msmrfq/pharmnos-lite/blob/main/src/app/auth/_actions/auth.actions.ts): `src/app/auth/_actions/auth.actions.ts`
- [Tenant context](https://github.com/msmrfq/pharmnos-lite/blob/main/src/lib/db/tenant-context.ts): `src/lib/db/tenant-context.ts`

### External services

- [Auth adapter](https://github.com/msmrfq/pharmnos-lite/blob/main/src/adapters/auth/supabase-auth.adapter.ts): `src/adapters/auth/supabase-auth.adapter.ts`
- **PostgreSQL**

### Other components

- **Pharmacy user**

## Connections

- Pharmacy user → Dashboard shell: uses
- Dashboard shell → Authentication actions: signs out via (evidence: `src/components/layout/dashboard-layout.tsx`)
- Inventory workspace → Tenant context: requires context (evidence: `src/app/inventory/page.tsx`)
- Inventory workspace → Repository factory: queries inventory (evidence: `src/app/inventory/page.tsx`)
- Repository factory → Prisma database client: creates repositories (evidence: `src/repositories/index.ts`)
- Repository factory → Sales invoice storage: creates (evidence: `src/repositories/index.ts`)
- Repository factory → Payment storage: creates (evidence: `src/repositories/index.ts`)
- Repository factory → Ledger storage: creates (evidence: `src/repositories/index.ts`)
- Repository base → Tenant context: validates tenant (evidence: `src/lib/db/base-repository.ts`)
- Tenant context → Auth adapter: gets session (evidence: `src/lib/db/tenant-context.ts`)
- Tenant context → Prisma database client: loads membership (evidence: `src/lib/db/tenant-context.ts`)
- Prisma database client → PostgreSQL: connects
- Sales and billing → Sales invoice storage: records invoices
- Purchasing → GST calculations: uses tax calculations
- Sales and billing → GST calculations: uses tax calculations
- Reports and exports → Aging reports: includes aging (evidence: `src/app/reports/page.tsx`)
- Reports and exports → Financial reconciliation: supports reconciliation
- Financial reconciliation → Exact decimal arithmetic: uses precise arithmetic (evidence: `src/domain/services/financial-reconciliation.service.ts`)
- Aging reports → Exact decimal arithmetic: uses precise arithmetic (evidence: `src/domain/services/aging-report.service.ts`)
- Business records → Repository factory: uses records
- Business settings → Repository factory: uses records (evidence: `src/app/settings/page.tsx`)
