# bola-j/contact-lenses-erp architecture

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

- Interactive diagram: https://gitdiagram.com/bola-j/contact-lenses-erp
- Repository: https://github.com/bola-j/contact-lenses-erp

## Overview

Lensee Production is an Arabic-first optical-retail management system. A user works through the browser client to the ASP.NET host, which exposes identity and business workflows for catalog, inventory, CRM, operations, payments, and finance; reporting and notifications support the operational result. The graph preserves the README’s major capabilities and sampled internal services. Many endpoint implementations and frontend request paths were not sampled, so uncertain interactions are omitted rather than inferred.

Main entry points: [`backend/Lensee.Host/Program.cs`](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Program.cs) (ASP.NET host), [`backend/Lensee.Host/Services/OperationCorrectionService.cs`](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Services/OperationCorrectionService.cs) (Operation corrections), [`frontend/app.js`](https://github.com/bola-j/contact-lenses-erp/blob/main/frontend/app.js) (Web application), [`backend/Lensee.Host/Infrastructure/RefreshTokenSessionService.cs`](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Infrastructure/RefreshTokenSessionService.cs) (Refresh-token sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_browser["Web application<br/>[app.js]"]
end

subgraph group_host["API and workflows"]
  node_api["ASP.NET host<br/>[Program.cs]"]
  node_corrections["Operation corrections"]
  node_refresh["Refresh-token sessions"]
end

subgraph group_business["Business domains"]
  node_identity["Identity and auth<br/>[AuthEndpoints.cs]"]
  node_catalog["Catalog management"]
  node_inventory["Inventory ledger"]
  node_crm["Merchant CRM<br/>[CrmEndpoints.cs]"]
  node_operations["Retail operations"]
  node_payments["Payments"]
  node_finance["Finance"]
  node_reporting["Reports and exports"]
  node_notifications["Notifications"]
  node_shopify["Shopify sync"]
  node_catalogdb[("Catalog data")]
  node_identitydb[("Identity data")]
  node_inventorydb[("Inventory data")]
  node_operationsdb[("Operations data")]
  node_paymentsdb[("Payments data")]
  node_categorytree["Category hierarchy"]
end

subgraph group_shared["Shared services"]
  node_shareddata[("Shared data and outbox<br/>[SharedDbContext.cs]")]
  node_documents["Document renderers"]
end

node_user(("Retail staff"))

node_user -->|"uses"| node_browser
node_browser -.->|"submits requests"| node_api
node_api -->|"routes"| node_identity
node_api -->|"routes"| node_catalog
node_api -->|"routes"| node_inventory
node_api -->|"routes"| node_crm
node_api -->|"routes"| node_operations
node_api -->|"routes"| node_payments
node_api -->|"routes"| node_finance
node_api -->|"routes"| node_reporting
node_api -->|"routes"| node_notifications
node_api -.->|"supports optional sync"| node_shopify
node_api -->|"configures"| node_catalogdb
node_api -->|"configures"| node_identitydb
node_api -->|"configures"| node_inventorydb
node_api -->|"configures"| node_operationsdb
node_api -->|"configures"| node_paymentsdb
node_api -->|"configures"| node_shareddata
node_catalog -->|"builds hierarchy"| node_categorytree
node_categorytree -->|"reads categories"| node_catalogdb
node_identity -->|"manages sessions"| node_refresh
node_refresh -->|"reads and writes tokens"| node_identitydb
node_corrections -->|"updates operations"| node_operationsdb
node_corrections -->|"adjusts stock"| node_inventorydb
node_corrections -->|"settles payments"| node_paymentsdb
node_reporting -->|"renders documents"| node_documents

click node_browser "https://github.com/bola-j/contact-lenses-erp/blob/main/frontend/app.js"
click node_api "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Program.cs"
click node_identity "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/AuthEndpoints.cs"
click node_catalog "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/CatalogEndpoints.cs"
click node_inventory "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Inventory/Services/StockLedgerService.cs"
click node_crm "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/CrmEndpoints.cs"
click node_operations "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/OperationsEndpoints.cs"
click node_payments "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/PaymentsEndpoints.cs"
click node_finance "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/FinanceEndpoints.cs"
click node_reporting "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/ReportsEndpoints.cs"
click node_notifications "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/NotificationsEndpoints.cs"
click node_shopify "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Infrastructure/ShopifyIntegrationService.cs"
click node_catalogdb "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Catalog/Data/CatalogDbContext.cs"
click node_identitydb "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Identity/Data/IdentityDbContext.cs"
click node_inventorydb "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Inventory/Data/InventoryDbContext.cs"
click node_operationsdb "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Operations/Data/OperationsDbContext.cs"
click node_paymentsdb "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Payments/Data/PaymentsDbContext.cs"
click node_shareddata "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.SharedKernel/Data/SharedDbContext.cs"
click node_corrections "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Services/OperationCorrectionService.cs"
click node_refresh "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Infrastructure/RefreshTokenSessionService.cs"
click node_categorytree "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Catalog/Services/CategoryTreeService.cs"
click node_documents "https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Reporting/Infrastructure/DocumentServices.cs"

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_browser toneBlue
class node_api,node_corrections,node_refresh toneAmber
class node_identity,node_catalog,node_inventory,node_crm,node_operations,node_payments,node_finance,node_reporting,node_notifications,node_shopify,node_catalogdb,node_identitydb,node_inventorydb,node_operationsdb,node_paymentsdb,node_categorytree toneMint
class node_shareddata,node_documents toneRose
class node_user toneIndigo
```

## Components

### Browser client

- [Web application](https://github.com/bola-j/contact-lenses-erp/blob/main/frontend/app.js): `frontend/app.js`

### API and workflows

- [ASP.NET host](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Program.cs): `backend/Lensee.Host/Program.cs`
- [Operation corrections](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Services/OperationCorrectionService.cs): `backend/Lensee.Host/Services/OperationCorrectionService.cs`
- [Refresh-token sessions](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Infrastructure/RefreshTokenSessionService.cs): `backend/Lensee.Host/Infrastructure/RefreshTokenSessionService.cs`

### Business domains

- [Identity and auth](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/AuthEndpoints.cs): `backend/Lensee.Host/Endpoints/AuthEndpoints.cs`
- [Catalog management](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/CatalogEndpoints.cs): `backend/Lensee.Host/Endpoints/CatalogEndpoints.cs`
- [Inventory ledger](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Inventory/Services/StockLedgerService.cs): `backend/Lensee.Modules.Inventory/Services/StockLedgerService.cs`
- [Merchant CRM](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/CrmEndpoints.cs): `backend/Lensee.Host/Endpoints/CrmEndpoints.cs`
- [Retail operations](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/OperationsEndpoints.cs): `backend/Lensee.Host/Endpoints/OperationsEndpoints.cs`
- [Payments](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/PaymentsEndpoints.cs): `backend/Lensee.Host/Endpoints/PaymentsEndpoints.cs`
- [Finance](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/FinanceEndpoints.cs): `backend/Lensee.Host/Endpoints/FinanceEndpoints.cs`
- [Reports and exports](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/ReportsEndpoints.cs): `backend/Lensee.Host/Endpoints/ReportsEndpoints.cs`
- [Notifications](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Endpoints/NotificationsEndpoints.cs): `backend/Lensee.Host/Endpoints/NotificationsEndpoints.cs`
- [Shopify sync](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Host/Infrastructure/ShopifyIntegrationService.cs): `backend/Lensee.Host/Infrastructure/ShopifyIntegrationService.cs`
- [Catalog data](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Catalog/Data/CatalogDbContext.cs): `backend/Lensee.Modules.Catalog/Data/CatalogDbContext.cs`
- [Identity data](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Identity/Data/IdentityDbContext.cs): `backend/Lensee.Modules.Identity/Data/IdentityDbContext.cs`
- [Inventory data](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Inventory/Data/InventoryDbContext.cs): `backend/Lensee.Modules.Inventory/Data/InventoryDbContext.cs`
- [Operations data](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Operations/Data/OperationsDbContext.cs): `backend/Lensee.Modules.Operations/Data/OperationsDbContext.cs`
- [Payments data](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Payments/Data/PaymentsDbContext.cs): `backend/Lensee.Modules.Payments/Data/PaymentsDbContext.cs`
- [Category hierarchy](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Catalog/Services/CategoryTreeService.cs): `backend/Lensee.Modules.Catalog/Services/CategoryTreeService.cs`

### Shared services

- [Shared data and outbox](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.SharedKernel/Data/SharedDbContext.cs): `backend/Lensee.SharedKernel/Data/SharedDbContext.cs`
- [Document renderers](https://github.com/bola-j/contact-lenses-erp/blob/main/backend/Lensee.Modules.Reporting/Infrastructure/DocumentServices.cs): `backend/Lensee.Modules.Reporting/Infrastructure/DocumentServices.cs`

### Other components

- **Retail staff**

## Connections

- Retail staff → Web application: uses (evidence: `README.md`)
- Web application → ASP.NET host: submits requests
- ASP.NET host → Identity and auth: routes (evidence: `backend/Lensee.Host/Program.cs`)
- ASP.NET host → Catalog management: routes (evidence: `backend/Lensee.Host/Program.cs`)
- ASP.NET host → Inventory ledger: routes (evidence: `README.md`)
- ASP.NET host → Merchant CRM: routes (evidence: `README.md`)
- ASP.NET host → Retail operations: routes (evidence: `README.md`)
- ASP.NET host → Payments: routes (evidence: `README.md`)
- ASP.NET host → Finance: routes (evidence: `README.md`)
- ASP.NET host → Reports and exports: routes (evidence: `README.md`)
- ASP.NET host → Notifications: routes (evidence: `README.md`)
- ASP.NET host → Shopify sync: supports optional sync (evidence: `README.md`)
- ASP.NET host → Catalog data: configures (evidence: `backend/Lensee.Host/Program.cs`)
- ASP.NET host → Identity data: configures (evidence: `backend/Lensee.Host/Program.cs`)
- ASP.NET host → Inventory data: configures (evidence: `backend/Lensee.Host/Program.cs`)
- ASP.NET host → Operations data: configures (evidence: `backend/Lensee.Host/Program.cs`)
- ASP.NET host → Payments data: configures (evidence: `backend/Lensee.Host/Program.cs`)
- ASP.NET host → Shared data and outbox: configures (evidence: `backend/Lensee.Host/Program.cs`)
- Catalog management → Category hierarchy: builds hierarchy (evidence: `backend/Lensee.Modules.Catalog/Services/CategoryTreeService.cs`)
- Category hierarchy → Catalog data: reads categories (evidence: `backend/Lensee.Modules.Catalog/Services/CategoryTreeService.cs`)
- Identity and auth → Refresh-token sessions: manages sessions (evidence: `backend/Lensee.Host/Infrastructure/RefreshTokenSessionService.cs`)
- Refresh-token sessions → Identity data: reads and writes tokens (evidence: `backend/Lensee.Host/Infrastructure/RefreshTokenSessionService.cs`)
- Operation corrections → Operations data: updates operations (evidence: `backend/Lensee.Host/Services/OperationCorrectionService.cs`)
- Operation corrections → Inventory data: adjusts stock (evidence: `backend/Lensee.Host/Services/OperationCorrectionService.cs`)
- Operation corrections → Payments data: settles payments (evidence: `backend/Lensee.Host/Services/OperationCorrectionService.cs`)
- Reports and exports → Document renderers: renders documents (evidence: `backend/Lensee.Modules.Reporting/Infrastructure/DocumentServices.cs`)
