# kathulhur/store-management-system architecture

> Architecture diagram of the GitHub repository kathulhur/store-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kathulhur/store-management-system
- Repository: https://github.com/kathulhur/store-management-system

## Overview

##### Main Components
- Presentation Layer: Represented by the StoreManagementSystemX project. This layer houses the WPF Views (XAML files), code-behind (e.g., MainWindow.xaml.cs), and ViewModels (e.g., DashboardViewModel, LoginViewModel, and the view model folders for Products, StockPurchases, Transactions, and Users). Also include the Services defined in the UI project (authentication, barcode generation, dialog services, etc.) and note the MVVM (Model-View-ViewModel) pattern used.
- Domain Layer: Found in the StoreManagementX.Domain project. This layer contains domain aggregates (Products, StockPurchases, Transactions, Users), factories, repositories, and domain services (including barcode service interfaces) that encapsulate the core business logic.
- Infrastructure Layer: The StoreManagementSystemX.Infrastructure project acts as the bridge between the domain and the database. It includes DTOs, persistence implementations (repository implementations like ProductRepositoryImpl, StockPurchaseRepositoryImpl, etc.), migrations, and connection context classes. This layer uses Entity Framework Core for ORM tasks.
- Database Layer: The StoreManagementSystemX.Database project contains the EF Core DbContext, repository interfaces and implementations for database access, migrations, and the actual SQLite database file (sqlite.db). It is responsible for setting up the database and performing CRUD operations.

##### Relationships & Interactions
- UI/Presentation layer communicates with the Domain and Infrastructure layers via service calls. For example, user interactions in a WPF window (login, product management, transaction processing) will trigger calls to the authentication, product creation, and transaction services.
- Services in the Presentation layer might directly invoke Domain layer functions or use the Infrastructure layer to persist data.
- The Domain layer exposes domain logic through repositories, factories, and aggregate operations. Its repositories may be implemented by the Infrastructure or Database projects.
- The Infrastructure layer (with its DTOs and EF Core configurations) forms the intermediary, ensuring that the high-level domain models are properly persisted in the SQLite database.

##### Architectural Patterns & Design Principles
- MVVM Pattern: Clearly used in the WPF project, so ensure that Views, ViewModels, and Models are visually distinct.
- Separation of Concerns: Different projects for Domain, Infrastructure, and Database show clear boundaries between business logic, data persistence, and presentation.
- Repository and Unit of Work Pattern: These are evident from the repository interfaces and implementations in both the Domain and Database projects.
- Clean Architecture: Maintain a separation between high-level business rules (Domain) and low-level data access (Infrastructure/Database).

##### Relevant Technologies and Frameworks
- C# and .NET Core as primary language and runtime.
- WPF for creating the user interface.
- Entity Framework Core for ORM.
- SQLite is the choice for data storage.
- Testing frameworks are used in projects like StoreManagementSystemX.Domain.Tests and StoreManagementSystemX.Tests.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        UI["WPF - Views & ViewModels"]:::presentation
    end

    subgraph "Domain Layer"
        DOMAIN["Domain Aggregates & Business Logic"]:::domain
    end

    subgraph "Infrastructure Layer"
        INF["Persistence & DTOs (EF Core Configurations)"]:::infrastructure
    end

    subgraph "Database Layer"
        DB["EF Core DbContext & SQLite DB"]:::database
    end

    UI -->|"calls"| DOMAIN
    DOMAIN -->|"utilizes"| INF
    INF -->|"performsCRUDon"| DB
    DB -->|"returnsData"| INF
    INF -->|"propagatesData"| DOMAIN
    DOMAIN -->|"updatesUI"| UI

    click UI "https://github.com/kathulhur/store-management-system/tree/main/StoreManagementSystemX"
    click DOMAIN "https://github.com/kathulhur/store-management-system/blob/main/StoreManagementX.Domain"
    click INF "https://github.com/kathulhur/store-management-system/blob/main/StoreManagementSystemX.Infrastructure"
    click DB "https://github.com/kathulhur/store-management-system/blob/main/StoreManagementSystemX.Database"

    classDef presentation fill:#cce5ff,stroke:#4169E1,stroke-width:2px;
    classDef domain fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef infrastructure fill:#fff3cd,stroke:#ffc107,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
```
