# mengheak/mart-management-window-form architecture

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

- Interactive diagram: https://gitdiagram.com/mengheak/mart-management-window-form
- Repository: https://github.com/mengheak/mart-management-window-form

## Overview

MiniMart is a Windows Forms point-of-sale and stock-management desktop application backed by SQL Server. A cashier signs in, searches products, builds a cart, applies a discount, accepts tender, and completes checkout; the sale service validates stock and payment before the repository persists the sale transactionally, then the UI displays a receipt. Other documented product areas include inventory and category maintenance, user administration, low-stock monitoring, and sales reporting/history. README and sampled files establish the layered design; several form and service connections are shown only by the README or remain unverified.

Main entry points: [`src/MiniMart.Presentation/AppServices.cs`](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/AppServices.cs) (Service wiring), [`src/MiniMart.BusinessLogic/Services/SaleService.cs`](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/SaleService.cs) (Checkout service), [`src/MiniMart.BusinessLogic/Services/InventoryService.cs`](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/InventoryService.cs) (Inventory service), [`src/MiniMart.Presentation/Forms/PosForm.cs`](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/PosForm.cs) (Point of sale)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Desktop UI"]
  node_program["Application startup<br/>[Program.cs]"]
  node_appservices["Service wiring<br/>[AppServices.cs]"]
  node_login["Sign-in and setup<br/>[LoginForm.cs]"]
  node_pos["Point of sale<br/>[PosForm.cs]"]
  node_receipt["Receipt display<br/>[ReceiptForm.cs]"]
  node_admin["Admin dashboard"]
  node_catalogui["Catalog maintenance<br/>[ProductListForm.cs]"]
  node_categoryui["Category maintenance"]
  node_stockui["Stock monitoring<br/>[LowStockForm.cs]"]
  node_salesui["Sales history"]
  node_usersui["User administration<br/>[UserListForm.cs]"]
end

subgraph group_business["Business services"]
  node_auth["Authentication<br/>[AuthService.cs]"]
  node_sales["Checkout service<br/>[SaleService.cs]"]
  node_cart["Cart and sale domain<br/>[Cart.cs]"]
  node_discounts["Discount strategies"]
  node_inventory["Inventory service"]
  node_categories["Category service<br/>[CategoryService.cs]"]
  node_users["User service<br/>[UserService.cs]"]
  node_reporting["Sales reporting"]
  node_productmodel["Product rules<br/>[Product.cs]"]
  node_exceptions["Business exceptions"]
  node_repos["Repository contracts"]
end

subgraph group_data["SQL persistence"]
  node_sqlfactory["SQL connection factory"]
  node_sqlbase["SQL query helpers"]
  node_productrepo["Product repository"]
  node_categoryrepo["Category repository"]
  node_salerepo["Sale repository<br/>[SaleRepository.cs]"]
  node_userrepo["User repository<br/>[UserRepository.cs]"]
end

node_cashier(("Cashier"))
node_sqlserver[("SQL Server")]

node_cashier -->|"starts"| node_program
node_program -->|"configures"| node_appservices
node_program -->|"opens"| node_login
node_login -.->|"authenticates"| node_auth
node_auth -->|"looks up user"| node_userrepo
node_appservices -->|"constructs"| node_userrepo
node_appservices -->|"constructs"| node_productrepo
node_appservices -->|"constructs"| node_categoryrepo
node_appservices -->|"constructs"| node_salerepo
node_appservices -->|"constructs"| node_inventory
node_appservices -->|"constructs"| node_categories
node_appservices -->|"constructs"| node_auth
node_appservices -->|"constructs"| node_users
node_appservices -->|"constructs"| node_reporting
node_appservices -->|"creates"| node_sales
node_pos -->|"uses"| node_appservices
node_pos -->|"checks out"| node_sales
node_pos -->|"updates cart"| node_cart
node_pos -->|"searches products"| node_inventory
node_pos -->|"shows receipt"| node_receipt
node_sales -->|"quotes cart"| node_cart
node_sales -->|"applies discount"| node_discounts
node_sales -->|"checks stock"| node_productrepo
node_sales -->|"saves sale"| node_salerepo
node_sales -->|"rejects invalid sale"| node_exceptions
node_inventory -->|"reads and updates"| node_productrepo
node_inventory -->|"uses categories"| node_categoryrepo
node_categories -->|"manages categories"| node_categoryrepo
node_users -->|"manages users"| node_userrepo
node_reporting -.->|"requests reports"| node_salerepo
node_catalogui -.->|"manages catalog"| node_inventory
node_categoryui -.->|"manages categories"| node_categories
node_stockui -.->|"views low stock"| node_inventory
node_salesui -->|"views sales"| node_reporting
node_usersui -.->|"manages users"| node_users
node_admin -.->|"opens"| node_catalogui
node_productrepo -->|"uses query helpers"| node_sqlbase
node_categoryrepo -->|"uses query helpers"| node_sqlbase
node_salerepo -->|"uses query helpers"| node_sqlbase
node_userrepo -->|"uses query helpers"| node_sqlbase
node_sqlbase -->|"opens connections"| node_sqlfactory
node_sqlfactory -.->|"connects"| node_sqlserver
node_productrepo -.->|"reads and writes"| node_sqlserver
node_categoryrepo -.->|"reads and writes"| node_sqlserver
node_salerepo -->|"persists transaction"| node_sqlserver
node_userrepo -.->|"reads and writes"| node_sqlserver

click node_program "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Program.cs"
click node_appservices "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/AppServices.cs"
click node_login "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/LoginForm.cs"
click node_pos "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/PosForm.cs"
click node_receipt "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/ReceiptForm.cs"
click node_admin "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/AdminDashboardForm.cs"
click node_catalogui "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/ProductListForm.cs"
click node_categoryui "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/CategoryListForm.cs"
click node_stockui "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/LowStockForm.cs"
click node_salesui "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/SalesHistoryForm.cs"
click node_usersui "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/UserListForm.cs"
click node_auth "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/AuthService.cs"
click node_sales "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/SaleService.cs"
click node_cart "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Models/Cart.cs"
click node_discounts "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Discounts/DiscountStrategy.cs"
click node_inventory "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/InventoryService.cs"
click node_categories "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/CategoryService.cs"
click node_users "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/UserService.cs"
click node_reporting "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/ReportingService.cs"
click node_productmodel "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Models/Product.cs"
click node_exceptions "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Exceptions/BusinessRuleException.cs"
click node_repos "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Repositories/IProductRepository.cs"
click node_sqlfactory "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Infrastructure/ISqlConnectionFactory.cs"
click node_sqlbase "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Infrastructure/SqlRepositoryBase.cs"
click node_productrepo "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Repositories/ProductRepository.cs"
click node_categoryrepo "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Repositories/CategoryRepository.cs"
click node_salerepo "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Repositories/SaleRepository.cs"
click node_userrepo "https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Repositories/UserRepository.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_program,node_appservices,node_login,node_pos,node_receipt,node_admin,node_catalogui,node_categoryui,node_stockui,node_salesui,node_usersui toneBlue
class node_auth,node_sales,node_cart,node_discounts,node_inventory,node_categories,node_users,node_reporting,node_productmodel,node_exceptions,node_repos,node_sqlserver toneAmber
class node_sqlfactory,node_sqlbase,node_productrepo,node_categoryrepo,node_salerepo,node_userrepo toneMint
class node_cashier toneIndigo
```

## Components

### Desktop UI

- [Application startup](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Program.cs): `src/MiniMart.Presentation/Program.cs`
- [Service wiring](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/AppServices.cs): `src/MiniMart.Presentation/AppServices.cs`
- [Sign-in and setup](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/LoginForm.cs): `src/MiniMart.Presentation/Forms/LoginForm.cs`
- [Point of sale](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/PosForm.cs): `src/MiniMart.Presentation/Forms/PosForm.cs`
- [Receipt display](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/ReceiptForm.cs): `src/MiniMart.Presentation/Forms/ReceiptForm.cs`
- [Admin dashboard](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/AdminDashboardForm.cs): `src/MiniMart.Presentation/Forms/AdminDashboardForm.cs`
- [Catalog maintenance](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/ProductListForm.cs): `src/MiniMart.Presentation/Forms/ProductListForm.cs`
- [Category maintenance](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/CategoryListForm.cs): `src/MiniMart.Presentation/Forms/CategoryListForm.cs`
- [Stock monitoring](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/LowStockForm.cs): `src/MiniMart.Presentation/Forms/LowStockForm.cs`
- [Sales history](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/SalesHistoryForm.cs): `src/MiniMart.Presentation/Forms/SalesHistoryForm.cs`
- [User administration](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.Presentation/Forms/UserListForm.cs): `src/MiniMart.Presentation/Forms/UserListForm.cs`

### Business services

- [Authentication](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/AuthService.cs): `src/MiniMart.BusinessLogic/Services/AuthService.cs`
- [Checkout service](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/SaleService.cs): `src/MiniMart.BusinessLogic/Services/SaleService.cs`
- [Cart and sale domain](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Models/Cart.cs): `src/MiniMart.BusinessLogic/Models/Cart.cs`
- [Discount strategies](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Discounts/DiscountStrategy.cs): `src/MiniMart.BusinessLogic/Discounts/DiscountStrategy.cs`
- [Inventory service](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/InventoryService.cs): `src/MiniMart.BusinessLogic/Services/InventoryService.cs`
- [Category service](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/CategoryService.cs): `src/MiniMart.BusinessLogic/Services/CategoryService.cs`
- [User service](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/UserService.cs): `src/MiniMart.BusinessLogic/Services/UserService.cs`
- [Sales reporting](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Services/ReportingService.cs): `src/MiniMart.BusinessLogic/Services/ReportingService.cs`
- [Product rules](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Models/Product.cs): `src/MiniMart.BusinessLogic/Models/Product.cs`
- [Business exceptions](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Exceptions/BusinessRuleException.cs): `src/MiniMart.BusinessLogic/Exceptions/BusinessRuleException.cs`
- [Repository contracts](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.BusinessLogic/Repositories/IProductRepository.cs): `src/MiniMart.BusinessLogic/Repositories/IProductRepository.cs`

### SQL persistence

- [SQL connection factory](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Infrastructure/ISqlConnectionFactory.cs): `src/MiniMart.DataAccess/Infrastructure/ISqlConnectionFactory.cs`
- [SQL query helpers](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Infrastructure/SqlRepositoryBase.cs): `src/MiniMart.DataAccess/Infrastructure/SqlRepositoryBase.cs`
- [Product repository](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Repositories/ProductRepository.cs): `src/MiniMart.DataAccess/Repositories/ProductRepository.cs`
- [Category repository](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Repositories/CategoryRepository.cs): `src/MiniMart.DataAccess/Repositories/CategoryRepository.cs`
- [Sale repository](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Repositories/SaleRepository.cs): `src/MiniMart.DataAccess/Repositories/SaleRepository.cs`
- [User repository](https://github.com/mengheak/mart-management-window-form/blob/main/src/MiniMart.DataAccess/Repositories/UserRepository.cs): `src/MiniMart.DataAccess/Repositories/UserRepository.cs`

### Other components

- **Cashier**
- **SQL Server**

## Connections

- Cashier → Application startup: starts (evidence: `src/MiniMart.Presentation/Program.cs`)
- Application startup → Service wiring: configures (evidence: `src/MiniMart.Presentation/Program.cs`)
- Application startup → Sign-in and setup: opens (evidence: `src/MiniMart.Presentation/Program.cs`)
- Sign-in and setup → Authentication: authenticates
- Authentication → User repository: looks up user (evidence: `src/MiniMart.BusinessLogic/Services/AuthService.cs`)
- Service wiring → User repository: constructs (evidence: `src/MiniMart.Presentation/AppServices.cs`)
- Service wiring → Product repository: constructs (evidence: `src/MiniMart.Presentation/AppServices.cs`)
- Service wiring → Category repository: constructs (evidence: `src/MiniMart.Presentation/AppServices.cs`)
- Service wiring → Sale repository: constructs (evidence: `src/MiniMart.Presentation/AppServices.cs`)
- Service wiring → Inventory service: constructs (evidence: `src/MiniMart.Presentation/AppServices.cs`)
- Service wiring → Category service: constructs (evidence: `src/MiniMart.Presentation/AppServices.cs`)
- Service wiring → Authentication: constructs (evidence: `src/MiniMart.Presentation/AppServices.cs`)
- Service wiring → User service: constructs (evidence: `src/MiniMart.Presentation/AppServices.cs`)
- Service wiring → Sales reporting: constructs (evidence: `src/MiniMart.Presentation/AppServices.cs`)
- Service wiring → Checkout service: creates (evidence: `src/MiniMart.Presentation/AppServices.cs`)
- Point of sale → Service wiring: uses (evidence: `src/MiniMart.Presentation/Forms/PosForm.cs`)
- Point of sale → Checkout service: checks out (evidence: `src/MiniMart.Presentation/Forms/PosForm.cs`)
- Point of sale → Cart and sale domain: updates cart (evidence: `src/MiniMart.Presentation/Forms/PosForm.cs`)
- Point of sale → Inventory service: searches products (evidence: `src/MiniMart.Presentation/Forms/PosForm.cs`)
- Point of sale → Receipt display: shows receipt (evidence: `src/MiniMart.Presentation/Forms/PosForm.cs`)
- Checkout service → Cart and sale domain: quotes cart (evidence: `src/MiniMart.BusinessLogic/Services/SaleService.cs`)
- Checkout service → Discount strategies: applies discount (evidence: `src/MiniMart.BusinessLogic/Services/SaleService.cs`)
- Checkout service → Product repository: checks stock (evidence: `src/MiniMart.BusinessLogic/Services/SaleService.cs`)
- Checkout service → Sale repository: saves sale (evidence: `src/MiniMart.BusinessLogic/Services/SaleService.cs`)
- Checkout service → Business exceptions: rejects invalid sale (evidence: `src/MiniMart.BusinessLogic/Services/SaleService.cs`)
- Inventory service → Product repository: reads and updates (evidence: `src/MiniMart.BusinessLogic/Services/InventoryService.cs`)
- Inventory service → Category repository: uses categories (evidence: `src/MiniMart.BusinessLogic/Services/InventoryService.cs`)
- Category service → Category repository: manages categories (evidence: `src/MiniMart.BusinessLogic/Services/CategoryService.cs`)
- User service → User repository: manages users (evidence: `src/MiniMart.BusinessLogic/Services/UserService.cs`)
- Sales reporting → Sale repository: requests reports
- Catalog maintenance → Inventory service: manages catalog
- Category maintenance → Category service: manages categories
- Stock monitoring → Inventory service: views low stock
- Sales history → Sales reporting: views sales (evidence: `src/MiniMart.Presentation/Forms/SalesHistoryForm.cs`)
- User administration → User service: manages users
- Admin dashboard → Catalog maintenance: opens
- Product repository → SQL query helpers: uses query helpers (evidence: `src/MiniMart.DataAccess/Repositories/ProductRepository.cs`)
- Category repository → SQL query helpers: uses query helpers (evidence: `src/MiniMart.DataAccess/Repositories/CategoryRepository.cs`)
- Sale repository → SQL query helpers: uses query helpers (evidence: `src/MiniMart.DataAccess/Repositories/SaleRepository.cs`)
- User repository → SQL query helpers: uses query helpers (evidence: `src/MiniMart.DataAccess/Repositories/UserRepository.cs`)
- SQL query helpers → SQL connection factory: opens connections (evidence: `src/MiniMart.DataAccess/Infrastructure/SqlRepositoryBase.cs`)
- SQL connection factory → SQL Server: connects
- Product repository → SQL Server: reads and writes
- Category repository → SQL Server: reads and writes
- Sale repository → SQL Server: persists transaction (evidence: `src/MiniMart.DataAccess/Repositories/SaleRepository.cs`)
- User repository → SQL Server: reads and writes
