# kudus-jall/kono-trade-sales-inventory architecture

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

- Interactive diagram: https://gitdiagram.com/kudus-jall/kono-trade-sales-inventory
- Repository: https://github.com/kudus-jall/kono-trade-sales-inventory

## Overview

Kono Trade is a Flask business-management app for trading workspaces. Users register or sign in, then manage business-scoped inventory, purchases, sales, payments, returns and expenses; owners also administer the workspace and review reports. These workflows persist to SQLite or PostgreSQL and feed receipts, notifications, exports and insights. The graph preserves the README’s major capabilities while keeping route modules distinct. Some links are documented at product level; unsampled route internals are not inferred beyond that evidence.

Main entry points: [`kono_trade/factory.py`](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/factory.py) (App factory), [`kono_trade/services/common.py`](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/services/common.py) (Shared business services), [`kono_trade/repositories/database.py`](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/repositories/database.py) (Database access and schema), [`kono_trade/routes/auth.py`](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/auth.py) (Accounts and access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App and Access"]
  node_app["Flask entry point<br/>[app.py]"]
  node_factory["App factory<br/>[factory.py]"]
  node_auth["Accounts and access<br/>[auth.py]"]
  node_business["Business settings<br/>[business.py]"]
end

subgraph group_operations["Business Operations"]
  node_inventory["Inventory<br/>[inventory.py]"]
  node_sales["Sales<br/>[sales.py]"]
  node_finance["Payments and expenses<br/>[finance.py]"]
  node_returns["Returns<br/>[returns.py]"]
end

subgraph group_oversight["Oversight and Tools"]
  node_dashboard["Dashboard<br/>[dashboard.py]"]
  node_reports["Reports and exports<br/>[reports.py]"]
  node_admin["Administration<br/>[admin.py]"]
  node_backup["Encrypted backups<br/>[backup_db.py]"]
end

subgraph group_platform["Shared Platform"]
  node_common["Shared business services<br/>[common.py]"]
  node_web["Request and session hooks<br/>[web.py]"]
  node_database[("Database access and schema<br/>[database.py]")]
  node_compat["PostgreSQL compatibility<br/>[db_compat.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

node_user(("Business user"))
node_smtp["Email service"]
node_ai["OpenAI-compatible provider"]

node_user -->|"uses"| node_app
node_app -->|"creates app"| node_factory
node_factory -->|"loads defaults"| node_config
node_factory -->|"registers hooks"| node_web
node_factory -->|"registers routes"| node_auth
node_factory -->|"registers routes"| node_business
node_factory -->|"registers routes"| node_dashboard
node_factory -->|"registers routes"| node_finance
node_factory -->|"registers routes"| node_inventory
node_factory -->|"registers routes"| node_reports
node_factory -->|"registers routes"| node_returns
node_factory -->|"registers routes"| node_sales
node_factory -->|"registers routes"| node_admin
node_factory -->|"initializes schema"| node_database
node_web -->|"opens connection"| node_database
node_database -->|"adapts PostgreSQL"| node_compat
node_user -->|"registers or signs in"| node_auth
node_user -->|"configures workspace"| node_business
node_user -->|"manages stock"| node_inventory
node_user -->|"records sales"| node_sales
node_user -->|"records payments"| node_finance
node_user -->|"records returns"| node_returns
node_user -->|"reviews and exports"| node_reports
node_user -->|"views overview"| node_dashboard
node_user -->|"administers workspace"| node_admin
node_user -.->|"runs backup"| node_backup
node_auth -.->|"sends recovery email"| node_smtp
node_business -.->|"configures optional insights"| node_ai
node_reports -->|"uses shared helpers"| node_common
node_sales -->|"uses shared helpers"| node_common
node_returns -->|"uses shared helpers"| node_common
node_common -->|"queries business data"| node_database

click node_app "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/app.py"
click node_factory "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/factory.py"
click node_auth "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/auth.py"
click node_business "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/business.py"
click node_dashboard "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/dashboard.py"
click node_inventory "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/inventory.py"
click node_sales "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/sales.py"
click node_finance "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/finance.py"
click node_returns "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/returns.py"
click node_reports "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/reports.py"
click node_admin "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/admin.py"
click node_common "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/services/common.py"
click node_web "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/web.py"
click node_database "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/repositories/database.py"
click node_compat "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/repositories/db_compat.py"
click node_config "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/config.py"
click node_backup "https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/backup_db.py"

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,node_factory,node_auth,node_business,node_user toneBlue
class node_inventory,node_sales,node_finance,node_returns toneAmber
class node_dashboard,node_reports,node_admin,node_backup toneMint
class node_common,node_web,node_database,node_compat,node_config toneRose
class node_smtp,node_ai toneIndigo
```

## Components

### App and Access

- [Flask entry point](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/app.py): `app.py`
- [App factory](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/factory.py): `kono_trade/factory.py`
- [Accounts and access](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/auth.py): `kono_trade/routes/auth.py`
- [Business settings](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/business.py): `kono_trade/routes/business.py`

### Business Operations

- [Inventory](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/inventory.py): `kono_trade/routes/inventory.py`
- [Sales](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/sales.py): `kono_trade/routes/sales.py`
- [Payments and expenses](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/finance.py): `kono_trade/routes/finance.py`
- [Returns](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/returns.py): `kono_trade/routes/returns.py`

### Oversight and Tools

- [Dashboard](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/dashboard.py): `kono_trade/routes/dashboard.py`
- [Reports and exports](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/reports.py): `kono_trade/routes/reports.py`
- [Administration](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/routes/admin.py): `kono_trade/routes/admin.py`
- [Encrypted backups](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/backup_db.py): `backup_db.py`

### Shared Platform

- [Shared business services](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/services/common.py): `kono_trade/services/common.py`
- [Request and session hooks](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/web.py): `kono_trade/web.py`
- [Database access and schema](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/repositories/database.py): `kono_trade/repositories/database.py`
- [PostgreSQL compatibility](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/repositories/db_compat.py): `kono_trade/repositories/db_compat.py`
- [Runtime configuration](https://github.com/kudus-jall/kono-trade-sales-inventory/blob/main/kono_trade/config.py): `kono_trade/config.py`

### Other components

- **Business user**
- **Email service**
- **OpenAI-compatible provider**

## Connections

- Business user → Flask entry point: uses (evidence: `README.md`)
- Flask entry point → App factory: creates app (evidence: `app.py`)
- App factory → Runtime configuration: loads defaults (evidence: `kono_trade/factory.py`)
- App factory → Request and session hooks: registers hooks (evidence: `kono_trade/factory.py`)
- App factory → Accounts and access: registers routes (evidence: `kono_trade/factory.py`)
- App factory → Business settings: registers routes (evidence: `kono_trade/factory.py`)
- App factory → Dashboard: registers routes (evidence: `kono_trade/factory.py`)
- App factory → Payments and expenses: registers routes (evidence: `kono_trade/factory.py`)
- App factory → Inventory: registers routes (evidence: `kono_trade/factory.py`)
- App factory → Reports and exports: registers routes (evidence: `kono_trade/factory.py`)
- App factory → Returns: registers routes (evidence: `kono_trade/factory.py`)
- App factory → Sales: registers routes (evidence: `kono_trade/factory.py`)
- App factory → Administration: registers routes (evidence: `kono_trade/factory.py`)
- App factory → Database access and schema: initializes schema (evidence: `kono_trade/factory.py`)
- Request and session hooks → Database access and schema: opens connection (evidence: `kono_trade/web.py`)
- Database access and schema → PostgreSQL compatibility: adapts PostgreSQL (evidence: `kono_trade/repositories/database.py`)
- Business user → Accounts and access: registers or signs in (evidence: `README.md`)
- Business user → Business settings: configures workspace (evidence: `README.md`)
- Business user → Inventory: manages stock (evidence: `README.md`)
- Business user → Sales: records sales (evidence: `README.md`)
- Business user → Payments and expenses: records payments (evidence: `README.md`)
- Business user → Returns: records returns (evidence: `README.md`)
- Business user → Reports and exports: reviews and exports (evidence: `README.md`)
- Business user → Dashboard: views overview (evidence: `README.md`)
- Business user → Administration: administers workspace (evidence: `README.md`)
- Business user → Encrypted backups: runs backup (evidence: `README.md`)
- Accounts and access → Email service: sends recovery email
- Business settings → OpenAI-compatible provider: configures optional insights (evidence: `README.md`)
- Reports and exports → Shared business services: uses shared helpers
- Sales → Shared business services: uses shared helpers
- Returns → Shared business services: uses shared helpers
- Shared business services → Database access and schema: queries business data (evidence: `kono_trade/services/common.py`)
