# darxx03eh/inventorymanagementsystem architecture

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

- Interactive diagram: https://gitdiagram.com/darxx03eh/inventorymanagementsystem
- Repository: https://github.com/darxx03eh/inventorymanagementsystem

## Overview

1. **Overall shape**
   - This is a small layered console application with a clear separation between presentation, business rules, and storage.
   - The solution is split into four project boundaries: `Models`, `Infrastructure`, `Service`, and `UI`, with `Program.cs` acting as the composition root.

2. **Entry point and composition**
   - `Program.cs` is the top-level executable entry point.
   - It likely wires together the repository, service, and UI objects, then starts the menu loop.
   - The README notes global error handling lives here, so fatal exceptions are caught before the process exits.

3. **Domain model**
   - `InventoryManagementSystem.Models/Entities/Product.cs` is the core data contract.
   - Product is the shared entity passed through the layers, carrying the inventory state such as name, price, and quantity.

4. **Storage boundary: Infrastructure**
   - `InventoryManagementSystem.Infrastructure` owns product persistence concerns.
   - `IProductRepository` defines the storage abstraction, while `ProductRepository` is the concrete implementation.
   - Current storage is in-memory, so this layer is not a database adapter yet; it is the isolated place where persistent storage could be swapped in later.

5. **Business logic boundary: Service**
   - `InventoryManagementSystem.Service` contains the inventory use-case rules in `InventoryService`.
   - `IInventoryService` abstracts the operations the UI consumes: adding, editing, deleting, searching, and listing products.
   - Validation rules described in the README belong here conceptually, not in the UI or repository.

6. **Presentation boundary: UI**
   - `InventoryManagementSystem.UI` owns the console experience and user interaction flow.
   - `Menu` implements the main navigation loop and user actions through `IMenu`.
   - `ConsoleHelper` centralizes console formatting and prompts, keeping presentation details out of the service layer.

7. **User interaction flow**
   - The user interacts only with the UI layer.
   - UI collects input, calls the service layer, and renders results or validation messages.
   - Service calls the repository to read or mutate the in-memory product collection.

8. **Key data flow**
   - The main path is: console input → UI menu → service validation/business rules → repository storage → service result → UI rendering.
   - Reads follow the same path in reverse: UI asks service for product data, service fetches from repository, then UI displays tables, summaries, or confirmations.

9. **Error handling**
   - Expected validation failures are handled as part of the normal UI experience and shown in styled error panels.
   - Unexpected failures bubble to `Program.cs`, where they are converted into a fatal error screen and a non-zero exit code.
   - That means the architecture separates recoverable business errors from unrecoverable application errors.

10. **External library and runtime**
   - The main non-BCL dependency called out in the README is `Spectre.Console`, which shapes the UI layer with banners, panels, tables, charts, prompts, and loading animations.
   - The target runtime is .NET 10, and the project is built as a console application rather than a web or desktop app.

11. **What to draw in an architecture diagram**
   - Show `Program.cs` at the top as the composition root.
   - Under it, show three horizontal layers: UI on top, Service in the middle, Infrastructure at the bottom, with `Models` shared across them.
   - Draw one-way dependencies downward: UI depends on Service, Service depends on repository abstractions and models, Infrastructure implements repository storage, and Models remain dependency-free.

12. **Current architectural constraint**
   - The system is intentionally ephemeral: inventory data disappears when the process exits.
   - That makes the repository layer the main seam for future persistence work, such as file storage or a database, without changing the UI flow.

Main entry points: [`InventoryManagementSystem.Service/Interfaces/IInventoryService.cs`](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Service/Interfaces/IInventoryService.cs) (IInventoryService), [`InventoryManagementSystem.Infrastructure/IRepositories/IProductRepository.cs`](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Infrastructure/IRepositories/IProductRepository.cs) (IProductRepository), [`InventoryManagementSystem.Models/Entities/Product.cs`](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Models/Entities/Product.cs) (Product), [`Program.cs`](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/Program.cs) (Program.cs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_composition["Composition"]
  node_program["Program.cs<br/>composition root<br/>[Program.cs]"]
end

subgraph group_ui["UI"]
  node_menu["Menu<br/>console UI<br/>[Menu.cs]"]
  node_menu_if["IMenu<br/>UI contract<br/>[IMenu.cs]"]
  node_console_helper["ConsoleHelper<br/>presentation helper<br/>[ConsoleHelper.cs]"]
end

subgraph group_service["Service"]
  node_inventory_service["InventoryService<br/>use-case service"]
  node_service_if["IInventoryService<br/>service contract"]
end

subgraph group_infrastructure["Infrastructure"]
  node_product_repo["ProductRepository<br/>in-memory store"]
  node_repo_if["IProductRepository<br/>storage contract"]
end

subgraph group_models["Models"]
  node_product["Product<br/>domain entity<br/>[Product.cs]"]
end

node_program -->|"creates"| node_menu_if
node_program -->|"creates"| node_service_if
node_program -->|"creates"| node_repo_if
node_menu -->|"uses"| node_service_if
node_menu -->|"renders with"| node_console_helper
node_menu -->|"implements"| node_menu_if
node_inventory_service -->|"depends on"| node_repo_if
node_inventory_service -->|"manages"| node_product
node_inventory_service -->|"implements"| node_service_if
node_product_repo -->|"implements"| node_repo_if
node_product_repo -->|"stores"| node_product
node_repo_if -->|"returns"| node_product
node_service_if -->|"accepts"| node_product

click node_program "https://github.com/darxx03eh/inventorymanagementsystem/blob/main/Program.cs"
click node_menu "https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.UI/Implementations/Menu.cs"
click node_menu_if "https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.UI/Interfaces/IMenu.cs"
click node_console_helper "https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.UI/Helpers/ConsoleHelper.cs"
click node_inventory_service "https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Service/Implementations/InventoryService.cs"
click node_service_if "https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Service/Interfaces/IInventoryService.cs"
click node_product_repo "https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Infrastructure/Repositories/ProductRepository.cs"
click node_repo_if "https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Infrastructure/IRepositories/IProductRepository.cs"
click node_product "https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Models/Entities/Product.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 toneBlue
class node_menu,node_menu_if,node_console_helper toneAmber
class node_inventory_service,node_service_if toneMint
class node_product_repo,node_repo_if toneRose
class node_product toneIndigo
```

## Components

### Composition

Application entry and wiring

- [Program.cs](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/Program.cs): composition root · Wires layers, starts app, handles fatal errors · `Program.cs`

### UI

Console interaction layer

- [Menu](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.UI/Implementations/Menu.cs): console UI · Main navigation loop and user actions · `InventoryManagementSystem.UI/Implementations/Menu.cs`
- [IMenu](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.UI/Interfaces/IMenu.cs): UI contract · Menu abstraction used by the composition root · `InventoryManagementSystem.UI/Interfaces/IMenu.cs`
- [ConsoleHelper](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.UI/Helpers/ConsoleHelper.cs): presentation helper · Centralized console formatting and prompts · `InventoryManagementSystem.UI/Helpers/ConsoleHelper.cs`

### Service

Business rules and use cases

- [InventoryService](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Service/Implementations/InventoryService.cs): use-case service · Implements inventory operations and validation · `InventoryManagementSystem.Service/Implementations/InventoryService.cs`
- [IInventoryService](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Service/Interfaces/IInventoryService.cs): service contract · Operations exposed to the UI · `InventoryManagementSystem.Service/Interfaces/IInventoryService.cs`

### Infrastructure

Storage boundary

- [ProductRepository](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Infrastructure/Repositories/ProductRepository.cs): in-memory store · Concrete product persistence implementation · `InventoryManagementSystem.Infrastructure/Repositories/ProductRepository.cs`
- [IProductRepository](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Infrastructure/IRepositories/IProductRepository.cs): storage contract · Repository abstraction for product storage · `InventoryManagementSystem.Infrastructure/IRepositories/IProductRepository.cs`

### Models

Shared domain entities

- [Product](https://github.com/darxx03eh/inventorymanagementsystem/blob/main/InventoryManagementSystem.Models/Entities/Product.cs): domain entity · Shared inventory record: name, price, quantity · `InventoryManagementSystem.Models/Entities/Product.cs`

## Connections

- Program.cs → IMenu: creates · Composition root builds the menu entrypoint
- Program.cs → IInventoryService: creates · Composition root wires the service dependency
- Program.cs → IProductRepository: creates · Composition root wires the repository dependency
- Menu → IInventoryService: uses · Console flow calls into application operations
- Menu → ConsoleHelper: renders with · Presentation formatting and prompts are centralized here
- Menu → IMenu: implements · Concrete console menu satisfies the UI contract
- InventoryService → IProductRepository: depends on · Business logic reads and mutates storage through the abstraction
- InventoryService → Product: manages · Service operates on the shared product entity
- InventoryService → IInventoryService: implements · Concrete inventory use-case service
- ProductRepository → IProductRepository: implements · In-memory repository satisfies the storage contract
- ProductRepository → Product: stores · Repository persists product records in process memory
- IProductRepository → Product: returns · Repository contract is typed around products
- IInventoryService → Product: accepts · Service contract exposes product-centric operations
