# amruthaamara1/inventorymanagementsystem architecture

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

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

## Overview

##### Project type and purpose
- This is a WPF desktop application written in C#/.NET using the MVVM pattern.
- It’s an Inventory Management System: manages products, sales/purchase transactions, and generates/export reports (CSV).

##### File structure
- Top-level App.xaml/App.xaml.cs and MainWindow.xaml/MainWindow.xaml.cs: bootstrap and host the UI.
- Commands: reusable ICommand implementations (RelayCommand).
- Converters: WPF IValueConverters (BoolToVisibilityConverter).
- Views & ViewModels: one-to-one mapping of XAML View files under Views/ to ViewModel classes under ViewModels/.
- Models: domain entities (Product, Transaction, Report).
- Services: business-logic layer (ProductService, TransactionService, ReportService, IReportGenerator implementations like SalesReportGenerator).
- Data: EF Core’s DbContext and Migrations for SQLite schema.
- Helpers: FileExporter for CSV export (uses CsvHelper & SaveFileDialog).

##### README for additional insights
- Confirms MVVM, EF Core with SQLite, CsvHelper for exports, async/await and ObservableCollection for live UI updates.

a. Main components
- UI Layer (WPF Views & Converters)
- Presentation Layer (ViewModels & Commands)
- Service / Business Logic Layer (Services + IReportGenerator implementations)
- Data Access Layer (EF Core’s DatabaseContext + Migrations)
- External/Infrastructure (SQLite database file; CsvHelper + SaveFileDialog for export)

b. Relationships & interactions
- Views bind to Properties/Commands in ViewModels (INotifyPropertyChanged, ObservableCollection).
- ViewModels invoke Services (e.g. ProductService.AddProductAsync, TransactionService.RecordSaleAsync, ReportService.GenerateReportAsync).
- Services use DatabaseContext (CRUD via EF Core’s DbSet<T>) and Linq queries.
- ReportService composes with one or more IReportGenerator implementations to produce Report models.
- Helpers/FileExporter uses CsvHelper library and WPF’s SaveFileDialog to persist CSV to disk.

c. Architectural patterns & design principles
- MVVM enforces separation of concerns: Views ↔ ViewModels ↔ Models.
- Dependency Inversion: ViewModels depend on service interfaces.
- Asynchronous programming (async/await) for all I/O.
- Observable pattern for UI refreshes.

d. Relevant technologies
- WPF (Views, App.xaml)
- MVVM (ViewModels, Commands, Converters)
- Entity Framework Core (DatabaseContext, Migrations, Data Annotations)
- SQLite (local file database)
- CsvHelper & SaveFileDialog (export)
- LINQ, async/await

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        App["App.xaml / App.xaml.cs"]:::ui
        MainWin["MainWindow.xaml / .cs"]:::ui
        subgraph "Views"
            direction TB
            MainView["MainView.xaml / .cs"]:::ui
            ProductView["ProductView.xaml / .cs"]:::ui
            TransactionView["TransactionView.xaml / .cs"]:::ui
            ReportView["ReportView.xaml / .cs"]:::ui
        end
        Converter["BoolToVisibilityConverter"]:::ui
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        MainVM["MainViewModel"]:::pres
        ProductVM["ProductViewModel"]:::pres
        TransactionVM["TransactionViewModel"]:::pres
        ReportVM["ReportViewModel"]:::pres
        RelayCmd["RelayCommand"]:::pres
    end

    %% Business Layer
    subgraph "Business Layer"
        direction TB
        IReportGen["IReportGenerator"]:::biz
        ProductSvc["ProductService"]:::biz
        TransSvc["TransactionService"]:::biz
        ReportSvc["ReportService"]:::biz
        SalesGen["SalesReportGenerator"]:::biz
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        DbContext["DatabaseContext"]:::data
        subgraph "Migrations"
            direction TB
            Mig1["20250325033828_InitialCreate"]:::data
            Mig2["20250412032002_AddTransactionPricingFields"]:::data
            Snapshot["DatabaseContextModelSnapshot"]:::data
        end
    end

    %% Domain Models
    subgraph "Domain Models"
        direction TB
        Product["Product"]:::data
        Transaction["Transaction"]:::data
        ReportModel["Report"]:::data
    end

    %% External/Infrastructure
    subgraph "External/Infrastructure"
        direction TB
        SQLiteDB["SQLite Database File"]:::external
        FileExporter["FileExporter (CsvHelper + SaveFileDialog)"]:::external
        CSVFile["Exported CSV File"]:::external
    end

    %% Relationships
    App -->|bootstraps| MainWin
    MainWin -->|hosts| MainView
    MainView -->|binds to| MainVM
    ProductView -->|binds to| ProductVM
    TransactionView -->|binds to| TransactionVM
    ReportView -->|binds to| ReportVM
    MainView -->|uses| Converter
    ProductView -->|uses| Converter
    TransactionView -->|uses| Converter
    ReportView -->|uses| Converter

    MainVM -->|async invokes| ProductSvc
    ProductVM -->|async invokes| ProductSvc
    TransactionVM -->|async invokes| TransSvc
    ReportVM -->|async invokes| ReportSvc
    MainVM -->|uses| RelayCmd
    ProductVM -->|uses| RelayCmd
    TransactionVM -->|uses| RelayCmd
    ReportVM -->|uses| RelayCmd

    ProductSvc -->|CRUD via| DbContext
    TransSvc -->|CRUD via| DbContext
    ReportSvc -->|uses| IReportGen
    ReportSvc -->|calls| SalesGen
    DbContext -->|applies| Mig1
    DbContext -->|applies| Mig2
    DbContext -->|snapshot| Snapshot
    DbContext -->|stores data in| SQLiteDB

    ReportSvc -->|exports via| FileExporter
    FileExporter -->|writes| CSVFile

    %% Click Events
    click App "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/App.xaml"
    click App "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/App.xaml.cs"
    click MainWin "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/MainWindow.xaml"
    click MainWin "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/MainWindow.xaml.cs"
    click MainView "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Views/MainView.xaml"
    click MainView "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Views/MainView.xaml.cs"
    click ProductView "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Views/ProductView.xaml"
    click ProductView "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Views/ProductView.xaml.cs"
    click TransactionView "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Views/TransactionView.xaml"
    click TransactionView "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Views/TransactionView.xaml.cs"
    click ReportView "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Views/ReportView.xaml"
    click ReportView "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Views/ReportView.xaml.cs"
    click Converter "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Converters/BoolToVisibilityConverter.cs"
    click MainVM "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/ViewModels/MainViewModel.cs"
    click ProductVM "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/ViewModels/ProductViewModel.cs"
    click TransactionVM "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/ViewModels/TransactionViewModel.cs"
    click ReportVM "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/ViewModels/ReportViewModel.cs"
    click RelayCmd "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Commands/RelayCommand.cs"
    click IReportGen "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Services/IReportGenerator.cs"
    click ProductSvc "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Services/ProductService.cs"
    click TransSvc "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Services/TransactionService.cs"
    click ReportSvc "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Services/ReportService.cs"
    click SalesGen "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Services/SalesReportGenerator.cs"
    click DbContext "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Data/DatabaseContext.cs"
    click Mig1 "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Migrations/20250325033828_InitialCreate.cs"
    click Mig1 "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Migrations/20250325033828_InitialCreate.Designer.cs"
    click Mig2 "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Migrations/20250412032002_AddTransactionPricingFields.cs"
    click Mig2 "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Migrations/20250412032002_AddTransactionPricingFields.Designer.cs"
    click Snapshot "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Migrations/DatabaseContextModelSnapshot.cs"
    click Product "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Models/Product.cs"
    click Transaction "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Models/Transaction.cs"
    click ReportModel "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Models/Report.cs"
    click FileExporter "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/Helpers/FileExporter.cs"
    click CSVFile "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/InventoryManagementSystem.csproj"
    click CSVFile "https://github.com/amruthaamara1/inventorymanagementsystem/blob/main/README.md"

    %% Styles
    classDef ui fill:#D6EAF8,stroke:#3498DB,color:#1B4F72
    classDef pres fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef biz fill:#FDEBD0,stroke:#E67E22,color:#935116
    classDef data fill:#EBDEF0,stroke:#8E44AD,color:#512E5F
    classDef external fill:#F2F3F4,stroke:#7F8C8D,color:#2C3E50
```
