# allaith95/commessionalhal2 architecture

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

- Interactive diagram: https://gitdiagram.com/allaith95/commessionalhal2
- Repository: https://github.com/allaith95/commessionalhal2

## Overview

CommessionalHal is an Arabic commission-accounting application with account, item, invoice, voucher, reporting, printing, and database-management workflows, plus offline RSA license activation. Users enter through the React app, activate the installation, configure a PostgreSQL connection/database, then work with accounting records and reports; shared app state synchronizes data through the server API. Licensing also has a separate developer-side key/license generation workflow. Several feature modules were not sampled, so their placement follows the README and source index; uncertain links are omitted.

Main entry points: [`src/App.tsx`](https://github.com/allaith95/commessionalhal2/blob/main/src/App.tsx) (App Shell), [`lib/license-verifier.ts`](https://github.com/allaith95/commessionalhal2/blob/main/lib/license-verifier.ts) (License Verifier), [`src/utils/pgClient.ts`](https://github.com/allaith95/commessionalhal2/blob/main/src/utils/pgClient.ts) (PostgreSQL Client), [`src/context/AppContext.tsx`](https://github.com/allaith95/commessionalhal2/blob/main/src/context/AppContext.tsx) (App State)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_app_shell["App Shell<br/>[App.tsx]"]
  node_app_state["App State<br/>[AppContext.tsx]"]
  node_settings["Settings<br/>[SettingsView.tsx]"]
  node_print["Print Output<br/>[PrintContainer.tsx]"]
end

subgraph group_accounting["Accounting Workflows"]
  node_accounts["Accounts"]
  node_account_editor["Account Editor"]
  node_items["Items and Categories<br/>[ItemsListView.tsx]"]
  node_item_editor["Item Editor<br/>[ItemCardModal.tsx]"]
  node_invoices["Commission Invoices"]
  node_vouchers["Vouchers<br/>[VouchersView.tsx]"]
  node_reports["Reports"]
  node_dashboard["Dashboard<br/>[HomeDashboard.tsx]"]
end

subgraph group_data["Data and Storage"]
  node_database_setup["Database Setup"]
  node_database_selector["Database Selector"]
  node_initial_data["Initial Data<br/>[initialData.ts]"]
  node_pg_client["PostgreSQL Client<br/>[pgClient.ts]"]
  node_database_api["Database API<br/>[server.ts]"]
end

subgraph group_licensing["License System"]
  node_activation_ui["Activation Screen"]
  node_activation_util["Activation Client<br/>[activation.ts]"]
  node_activation_api["Activation Routes"]
  node_license_verify["License Verifier"]
  node_fingerprint["Machine Fingerprint"]
  node_public_key["Public Key<br/>[public-key.ts]"]
  node_license_types["License Types<br/>[license-types.ts]"]
  node_license_generator["License Generator"]
end

node_user(("User"))
node_developer(("Developer"))
node_postgres[("PostgreSQL")]

node_user -->|"uses"| node_app_shell
node_app_shell -->|"gates access"| node_activation_ui
node_activation_ui -->|"requests activation"| node_activation_util
node_activation_util -->|"calls endpoints"| node_activation_api
node_activation_api -->|"gets fingerprint"| node_fingerprint
node_activation_api -->|"verifies license"| node_license_verify
node_license_verify -->|"checks device"| node_fingerprint
node_license_verify -->|"verifies signature"| node_public_key
node_license_verify -->|"uses types"| node_license_types
node_developer -->|"generates license"| node_license_generator
node_license_generator -->|"uses types"| node_license_types
node_license_generator -->|"produces signed license"| node_license_verify
node_app_shell -->|"provides state"| node_app_state
node_app_shell -->|"renders views"| node_accounts
node_app_shell -->|"renders views"| node_account_editor
node_app_shell -->|"renders views"| node_items
node_app_shell -->|"renders views"| node_item_editor
node_app_shell -->|"renders views"| node_invoices
node_app_shell -->|"renders views"| node_vouchers
node_app_shell -->|"renders views"| node_reports
node_app_shell -->|"renders views"| node_dashboard
node_app_shell -->|"renders views"| node_settings
node_app_shell -->|"renders output"| node_print
node_app_shell -->|"opens setup"| node_database_setup
node_app_shell -->|"manages databases"| node_database_selector
node_app_shell -->|"manages connection"| node_pg_client
node_app_state -->|"loads defaults"| node_initial_data
node_app_state -->|"syncs data"| node_pg_client
node_database_setup -->|"manages databases"| node_pg_client
node_database_selector -->|"manages databases"| node_pg_client
node_pg_client -->|"sends API requests"| node_database_api
node_database_api -.->|"reads and writes"| node_postgres

click node_app_shell "https://github.com/allaith95/commessionalhal2/blob/main/src/App.tsx"
click node_app_state "https://github.com/allaith95/commessionalhal2/blob/main/src/context/AppContext.tsx"
click node_activation_ui "https://github.com/allaith95/commessionalhal2/blob/main/src/components/activation/ActivationLockScreen.tsx"
click node_activation_util "https://github.com/allaith95/commessionalhal2/blob/main/src/utils/activation.ts"
click node_activation_api "https://github.com/allaith95/commessionalhal2/blob/main/server/activation-routes.ts"
click node_license_verify "https://github.com/allaith95/commessionalhal2/blob/main/lib/license-verifier.ts"
click node_fingerprint "https://github.com/allaith95/commessionalhal2/blob/main/lib/machine-fingerprint.ts"
click node_public_key "https://github.com/allaith95/commessionalhal2/blob/main/lib/public-key.ts"
click node_license_types "https://github.com/allaith95/commessionalhal2/blob/main/lib/license-types.ts"
click node_license_generator "https://github.com/allaith95/commessionalhal2/blob/main/tools/generate-license.ts"
click node_accounts "https://github.com/allaith95/commessionalhal2/blob/main/src/components/accounts/AccountsListView.tsx"
click node_account_editor "https://github.com/allaith95/commessionalhal2/blob/main/src/components/accounts/AccountCardModal.tsx"
click node_items "https://github.com/allaith95/commessionalhal2/blob/main/src/components/items/ItemsListView.tsx"
click node_item_editor "https://github.com/allaith95/commessionalhal2/blob/main/src/components/items/ItemCardModal.tsx"
click node_invoices "https://github.com/allaith95/commessionalhal2/blob/main/src/components/invoices/CommissionInvoiceView.tsx"
click node_vouchers "https://github.com/allaith95/commessionalhal2/blob/main/src/components/vouchers/VouchersView.tsx"
click node_reports "https://github.com/allaith95/commessionalhal2/blob/main/src/components/reports/AccountStatementView.tsx"
click node_dashboard "https://github.com/allaith95/commessionalhal2/blob/main/src/components/home/HomeDashboard.tsx"
click node_settings "https://github.com/allaith95/commessionalhal2/blob/main/src/components/settings/SettingsView.tsx"
click node_print "https://github.com/allaith95/commessionalhal2/blob/main/src/components/print/PrintContainer.tsx"
click node_database_setup "https://github.com/allaith95/commessionalhal2/blob/main/src/components/database/DatabaseFilesSetupScreen.tsx"
click node_database_selector "https://github.com/allaith95/commessionalhal2/blob/main/src/components/database/DatabaseSelectorModal.tsx"
click node_initial_data "https://github.com/allaith95/commessionalhal2/blob/main/src/context/initialData.ts"
click node_pg_client "https://github.com/allaith95/commessionalhal2/blob/main/src/utils/pgClient.ts"
click node_database_api "https://github.com/allaith95/commessionalhal2/blob/main/server.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_app_shell,node_app_state,node_settings,node_print,node_user toneBlue
class node_accounts,node_account_editor,node_items,node_item_editor,node_invoices,node_vouchers,node_reports,node_dashboard,node_postgres toneAmber
class node_database_setup,node_database_selector,node_initial_data,node_pg_client,node_database_api toneMint
class node_activation_ui,node_activation_util,node_activation_api,node_license_verify,node_fingerprint,node_public_key,node_license_types,node_license_generator toneRose
class node_developer toneIndigo
```

## Components

### Application

- [App Shell](https://github.com/allaith95/commessionalhal2/blob/main/src/App.tsx): `src/App.tsx`
- [App State](https://github.com/allaith95/commessionalhal2/blob/main/src/context/AppContext.tsx): `src/context/AppContext.tsx`
- [Settings](https://github.com/allaith95/commessionalhal2/blob/main/src/components/settings/SettingsView.tsx): `src/components/settings/SettingsView.tsx`
- [Print Output](https://github.com/allaith95/commessionalhal2/blob/main/src/components/print/PrintContainer.tsx): `src/components/print/PrintContainer.tsx`

### Accounting Workflows

- [Accounts](https://github.com/allaith95/commessionalhal2/blob/main/src/components/accounts/AccountsListView.tsx): `src/components/accounts/AccountsListView.tsx`
- [Account Editor](https://github.com/allaith95/commessionalhal2/blob/main/src/components/accounts/AccountCardModal.tsx): `src/components/accounts/AccountCardModal.tsx`
- [Items and Categories](https://github.com/allaith95/commessionalhal2/blob/main/src/components/items/ItemsListView.tsx): `src/components/items/ItemsListView.tsx`
- [Item Editor](https://github.com/allaith95/commessionalhal2/blob/main/src/components/items/ItemCardModal.tsx): `src/components/items/ItemCardModal.tsx`
- [Commission Invoices](https://github.com/allaith95/commessionalhal2/blob/main/src/components/invoices/CommissionInvoiceView.tsx): `src/components/invoices/CommissionInvoiceView.tsx`
- [Vouchers](https://github.com/allaith95/commessionalhal2/blob/main/src/components/vouchers/VouchersView.tsx): `src/components/vouchers/VouchersView.tsx`
- [Reports](https://github.com/allaith95/commessionalhal2/blob/main/src/components/reports/AccountStatementView.tsx): `src/components/reports/AccountStatementView.tsx`
- [Dashboard](https://github.com/allaith95/commessionalhal2/blob/main/src/components/home/HomeDashboard.tsx): `src/components/home/HomeDashboard.tsx`

### Data and Storage

- [Database Setup](https://github.com/allaith95/commessionalhal2/blob/main/src/components/database/DatabaseFilesSetupScreen.tsx): `src/components/database/DatabaseFilesSetupScreen.tsx`
- [Database Selector](https://github.com/allaith95/commessionalhal2/blob/main/src/components/database/DatabaseSelectorModal.tsx): `src/components/database/DatabaseSelectorModal.tsx`
- [Initial Data](https://github.com/allaith95/commessionalhal2/blob/main/src/context/initialData.ts): `src/context/initialData.ts`
- [PostgreSQL Client](https://github.com/allaith95/commessionalhal2/blob/main/src/utils/pgClient.ts): `src/utils/pgClient.ts`
- [Database API](https://github.com/allaith95/commessionalhal2/blob/main/server.ts): `server.ts`

### License System

- [Activation Screen](https://github.com/allaith95/commessionalhal2/blob/main/src/components/activation/ActivationLockScreen.tsx): `src/components/activation/ActivationLockScreen.tsx`
- [Activation Client](https://github.com/allaith95/commessionalhal2/blob/main/src/utils/activation.ts): `src/utils/activation.ts`
- [Activation Routes](https://github.com/allaith95/commessionalhal2/blob/main/server/activation-routes.ts): `server/activation-routes.ts`
- [License Verifier](https://github.com/allaith95/commessionalhal2/blob/main/lib/license-verifier.ts): `lib/license-verifier.ts`
- [Machine Fingerprint](https://github.com/allaith95/commessionalhal2/blob/main/lib/machine-fingerprint.ts): `lib/machine-fingerprint.ts`
- [Public Key](https://github.com/allaith95/commessionalhal2/blob/main/lib/public-key.ts): `lib/public-key.ts`
- [License Types](https://github.com/allaith95/commessionalhal2/blob/main/lib/license-types.ts): `lib/license-types.ts`
- [License Generator](https://github.com/allaith95/commessionalhal2/blob/main/tools/generate-license.ts): `tools/generate-license.ts`

### Other components

- **User**
- **Developer**
- **PostgreSQL**

## Connections

- User → App Shell: uses
- App Shell → Activation Screen: gates access (evidence: `src/App.tsx`)
- Activation Screen → Activation Client: requests activation (evidence: `src/components/activation/ActivationLockScreen.tsx`)
- Activation Client → Activation Routes: calls endpoints
- Activation Routes → Machine Fingerprint: gets fingerprint (evidence: `server/activation-routes.ts`)
- Activation Routes → License Verifier: verifies license (evidence: `server/activation-routes.ts`)
- License Verifier → Machine Fingerprint: checks device (evidence: `lib/license-verifier.ts`)
- License Verifier → Public Key: verifies signature (evidence: `lib/license-verifier.ts`)
- License Verifier → License Types: uses types (evidence: `lib/license-verifier.ts`)
- Developer → License Generator: generates license
- License Generator → License Types: uses types (evidence: `tools/generate-license.ts`)
- License Generator → License Verifier: produces signed license
- App Shell → App State: provides state (evidence: `src/App.tsx`)
- App Shell → Accounts: renders views (evidence: `src/App.tsx`)
- App Shell → Account Editor: renders views (evidence: `src/App.tsx`)
- App Shell → Items and Categories: renders views (evidence: `src/App.tsx`)
- App Shell → Item Editor: renders views (evidence: `src/App.tsx`)
- App Shell → Commission Invoices: renders views (evidence: `src/App.tsx`)
- App Shell → Vouchers: renders views (evidence: `src/App.tsx`)
- App Shell → Reports: renders views (evidence: `src/App.tsx`)
- App Shell → Dashboard: renders views (evidence: `src/App.tsx`)
- App Shell → Settings: renders views (evidence: `src/App.tsx`)
- App Shell → Print Output: renders output (evidence: `src/App.tsx`)
- App Shell → Database Setup: opens setup (evidence: `src/App.tsx`)
- App Shell → Database Selector: manages databases (evidence: `src/App.tsx`)
- App Shell → PostgreSQL Client: manages connection (evidence: `src/App.tsx`)
- App State → Initial Data: loads defaults (evidence: `src/context/AppContext.tsx`)
- App State → PostgreSQL Client: syncs data (evidence: `src/context/AppContext.tsx`)
- Database Setup → PostgreSQL Client: manages databases (evidence: `src/components/database/DatabaseFilesSetupScreen.tsx`)
- Database Selector → PostgreSQL Client: manages databases (evidence: `src/components/database/DatabaseSelectorModal.tsx`)
- PostgreSQL Client → Database API: sends API requests (evidence: `src/utils/pgClient.ts`)
- Database API → PostgreSQL: reads and writes
