# bassamalsaqqa/account architecture

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

- Interactive diagram: https://gitdiagram.com/bassamalsaqqa/account
- Repository: https://github.com/bassamalsaqqa/account

## Overview

Small Trader Accounting is a multi-tenant accounting and trading system for merchants. The principal workflow is company-scoped sales: an authenticated user works within an active company, creates or updates an invoice through the API command boundary, and reads reporting outputs or shares financial information. The product also covers purchasing, inventory, money, payroll, expenses, and double-entry accounting. Groups distinguish user-facing flows, operational domains, posting, and reporting. Edges are limited to relationships shown in indexed source references or excerpts; several product areas are represented from the tree and README, so their internal call paths are not asserted.

Main entry points: [`app/Livewire/FinancialShareManager.php`](https://github.com/bassamalsaqqa/account/blob/main/app/Livewire/FinancialShareManager.php) (Financial Share Manager), [`app/Http/Controllers/Api/V1/SalesInvoiceApiController.php`](https://github.com/bassamalsaqqa/account/blob/main/app/Http/Controllers/Api/V1/SalesInvoiceApiController.php) (Sales Invoice API), [`app/Http/Controllers/ReportCsvController.php`](https://github.com/bassamalsaqqa/account/blob/main/app/Http/Controllers/ReportCsvController.php) (CSV Export), [`app/Support/Tenancy/CompanyContext.php`](https://github.com/bassamalsaqqa/account/blob/main/app/Support/Tenancy/CompanyContext.php) (Company Context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Tenant and Access"]
  node_context["Company Context<br/>[CompanyContext.php]"]
  node_tenant[("Company and Membership<br/>[Company.php]")]
end

subgraph group_commerce["Trading Operations"]
  node_api["Sales Invoice API"]
  node_salescommands["Sales Invoice Commands"]
  node_salesrecords[("Sales Documents<br/>[SalesInvoice.php]")]
  node_customers[("Customer Records<br/>[Customer.php]")]
  node_products[("Product Catalog<br/>[Product.php]")]
  node_inventory["Inventory Movement"]
  node_stockquery["Stock Availability"]
  node_purchasing["Purchasing"]
end

subgraph group_finance["Financial Operations"]
  node_money["Money Operations"]
  node_payroll["Payroll"]
  node_expenses["Expenses"]
end

subgraph group_reporting["Reporting and Sharing"]
  node_reports["Report Queries"]
  node_filters["Report Filters<br/>[ReportFilters.php]"]
  node_csv["CSV Export"]
  node_sharemanager["Financial Share Manager"]
  node_sharequery["Customer Statement"]
  node_share[("Public Financial Shares<br/>[PublicShare.php]")]
end

subgraph group_platform["Core Data and Posting"]
  node_posting["Accounting Posting"]
  node_ledger[("Ledger Accounts<br/>[LedgerAccount.php]")]
end

node_user(("Merchant User"))

node_user -->|"requests invoice"| node_api
node_user -->|"manages share"| node_sharemanager
node_api -->|"invokes commands"| node_salescommands
node_api -->|"resolves company"| node_context
node_api -->|"reads invoice"| node_salesrecords
node_context -->|"selects company"| node_tenant
node_stockquery -->|"allocates stock"| node_inventory
node_inventory -->|"updates stock"| node_products
node_posting -.->|"posts entries"| node_ledger
node_csv -->|"builds filters"| node_filters
node_csv -->|"delivers report"| node_reports
node_csv -.->|"formats output"| node_sharemanager
node_sharemanager -->|"checks company"| node_context
node_sharemanager -->|"loads shares"| node_share
node_sharemanager -->|"previews statement"| node_sharequery
node_sharemanager -->|"creates share"| node_tenant
node_sharemanager -->|"creates share"| node_share

click node_context "https://github.com/bassamalsaqqa/account/blob/main/app/Support/Tenancy/CompanyContext.php"
click node_tenant "https://github.com/bassamalsaqqa/account/blob/main/app/Models/Company.php"
click node_api "https://github.com/bassamalsaqqa/account/blob/main/app/Http/Controllers/Api/V1/SalesInvoiceApiController.php"
click node_salescommands "https://github.com/bassamalsaqqa/account/blob/main/app/Application/Commands/SalesInvoiceCommands.php"
click node_salesrecords "https://github.com/bassamalsaqqa/account/blob/main/app/Models/SalesInvoice.php"
click node_customers "https://github.com/bassamalsaqqa/account/blob/main/app/Models/Customer.php"
click node_products "https://github.com/bassamalsaqqa/account/blob/main/app/Models/Product.php"
click node_inventory "https://github.com/bassamalsaqqa/account/blob/main/app/Services/Inventory/InventoryMovementService.php"
click node_stockquery "https://github.com/bassamalsaqqa/account/blob/main/app/Application/Commands/StockAvailabilityQuery.php"
click node_purchasing "https://github.com/bassamalsaqqa/account/tree/main/app/Actions/Purchasing"
click node_money "https://github.com/bassamalsaqqa/account/tree/main/app/Actions/Money"
click node_payroll "https://github.com/bassamalsaqqa/account/tree/main/app/Actions/Payroll"
click node_expenses "https://github.com/bassamalsaqqa/account/tree/main/app/Actions/Expenses"
click node_posting "https://github.com/bassamalsaqqa/account/blob/main/app/Services/Posting/AccountingPostingService.php"
click node_ledger "https://github.com/bassamalsaqqa/account/blob/main/app/Models/LedgerAccount.php"
click node_reports "https://github.com/bassamalsaqqa/account/tree/main/app/Application/Reporting/Queries"
click node_filters "https://github.com/bassamalsaqqa/account/blob/main/app/Application/Reporting/DTO/ReportFilters.php"
click node_csv "https://github.com/bassamalsaqqa/account/blob/main/app/Http/Controllers/ReportCsvController.php"
click node_sharemanager "https://github.com/bassamalsaqqa/account/blob/main/app/Livewire/FinancialShareManager.php"
click node_sharequery "https://github.com/bassamalsaqqa/account/blob/main/app/Domain/Sales/Queries/CustomerStatementQuery.php"
click node_share "https://github.com/bassamalsaqqa/account/blob/main/app/Models/PublicShare.php"

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_context,node_tenant,node_user toneBlue
class node_api,node_salescommands,node_salesrecords,node_customers,node_products,node_inventory,node_stockquery,node_purchasing toneAmber
class node_money,node_payroll,node_expenses toneMint
class node_reports,node_filters,node_csv,node_sharemanager,node_sharequery,node_share toneRose
class node_posting,node_ledger toneIndigo
```

## Components

### Tenant and Access

- [Company Context](https://github.com/bassamalsaqqa/account/blob/main/app/Support/Tenancy/CompanyContext.php): `app/Support/Tenancy/CompanyContext.php`
- [Company and Membership](https://github.com/bassamalsaqqa/account/blob/main/app/Models/Company.php): `app/Models/Company.php`

### Trading Operations

- [Sales Invoice API](https://github.com/bassamalsaqqa/account/blob/main/app/Http/Controllers/Api/V1/SalesInvoiceApiController.php): `app/Http/Controllers/Api/V1/SalesInvoiceApiController.php`
- [Sales Invoice Commands](https://github.com/bassamalsaqqa/account/blob/main/app/Application/Commands/SalesInvoiceCommands.php): `app/Application/Commands/SalesInvoiceCommands.php`
- [Sales Documents](https://github.com/bassamalsaqqa/account/blob/main/app/Models/SalesInvoice.php): `app/Models/SalesInvoice.php`
- [Customer Records](https://github.com/bassamalsaqqa/account/blob/main/app/Models/Customer.php): `app/Models/Customer.php`
- [Product Catalog](https://github.com/bassamalsaqqa/account/blob/main/app/Models/Product.php): `app/Models/Product.php`
- [Inventory Movement](https://github.com/bassamalsaqqa/account/blob/main/app/Services/Inventory/InventoryMovementService.php): `app/Services/Inventory/InventoryMovementService.php`
- [Stock Availability](https://github.com/bassamalsaqqa/account/blob/main/app/Application/Commands/StockAvailabilityQuery.php): `app/Application/Commands/StockAvailabilityQuery.php`
- [Purchasing](https://github.com/bassamalsaqqa/account/tree/main/app/Actions/Purchasing): `app/Actions/Purchasing`

### Financial Operations

- [Money Operations](https://github.com/bassamalsaqqa/account/tree/main/app/Actions/Money): `app/Actions/Money`
- [Payroll](https://github.com/bassamalsaqqa/account/tree/main/app/Actions/Payroll): `app/Actions/Payroll`
- [Expenses](https://github.com/bassamalsaqqa/account/tree/main/app/Actions/Expenses): `app/Actions/Expenses`

### Reporting and Sharing

- [Report Queries](https://github.com/bassamalsaqqa/account/tree/main/app/Application/Reporting/Queries): `app/Application/Reporting/Queries`
- [Report Filters](https://github.com/bassamalsaqqa/account/blob/main/app/Application/Reporting/DTO/ReportFilters.php): `app/Application/Reporting/DTO/ReportFilters.php`
- [CSV Export](https://github.com/bassamalsaqqa/account/blob/main/app/Http/Controllers/ReportCsvController.php): `app/Http/Controllers/ReportCsvController.php`
- [Financial Share Manager](https://github.com/bassamalsaqqa/account/blob/main/app/Livewire/FinancialShareManager.php): `app/Livewire/FinancialShareManager.php`
- [Customer Statement](https://github.com/bassamalsaqqa/account/blob/main/app/Domain/Sales/Queries/CustomerStatementQuery.php): `app/Domain/Sales/Queries/CustomerStatementQuery.php`
- [Public Financial Shares](https://github.com/bassamalsaqqa/account/blob/main/app/Models/PublicShare.php): `app/Models/PublicShare.php`

### Core Data and Posting

- [Accounting Posting](https://github.com/bassamalsaqqa/account/blob/main/app/Services/Posting/AccountingPostingService.php): `app/Services/Posting/AccountingPostingService.php`
- [Ledger Accounts](https://github.com/bassamalsaqqa/account/blob/main/app/Models/LedgerAccount.php): `app/Models/LedgerAccount.php`

### Other components

- **Merchant User**

## Connections

- Merchant User → Sales Invoice API: requests invoice
- Merchant User → Financial Share Manager: manages share (evidence: `app/Livewire/FinancialShareManager.php`)
- Sales Invoice API → Sales Invoice Commands: invokes commands (evidence: `app/Http/Controllers/Api/V1/SalesInvoiceApiController.php`)
- Sales Invoice API → Company Context: resolves company (evidence: `app/Http/Controllers/Api/V1/SalesInvoiceApiController.php`)
- Sales Invoice API → Sales Documents: reads invoice (evidence: `app/Http/Controllers/Api/V1/SalesInvoiceApiController.php`)
- Company Context → Company and Membership: selects company (evidence: `app/Support/Tenancy/CompanyContext.php`)
- Stock Availability → Inventory Movement: allocates stock (evidence: `app/Application/Commands/StockAvailabilityQuery.php`)
- Inventory Movement → Product Catalog: updates stock (evidence: `app/Services/Inventory/InventoryMovementService.php`)
- Accounting Posting → Ledger Accounts: posts entries (evidence: `app/Services/Posting/AccountingPostingService.php`)
- CSV Export → Report Filters: builds filters (evidence: `app/Http/Controllers/ReportCsvController.php`)
- CSV Export → Report Queries: delivers report (evidence: `app/Http/Controllers/ReportCsvController.php`)
- CSV Export → Financial Share Manager: formats output
- Financial Share Manager → Company Context: checks company (evidence: `app/Livewire/FinancialShareManager.php`)
- Financial Share Manager → Public Financial Shares: loads shares (evidence: `app/Livewire/FinancialShareManager.php`)
- Financial Share Manager → Customer Statement: previews statement (evidence: `app/Livewire/FinancialShareManager.php`)
- Financial Share Manager → Company and Membership: creates share (evidence: `app/Livewire/FinancialShareManager.php`)
- Financial Share Manager → Public Financial Shares: creates share (evidence: `app/Livewire/FinancialShareManager.php`)
