WPF Inventory Management SystemΒΆ

  • πŸ“‚ Project Path: csharp/desktop-apps/wpf/WpfInventoryApp/

Technologies: C# β€’ WPF β€’ SQLite

WPF Inventory Management SystemΒΆ

A comprehensive WPF desktop application built with enterprise-grade MVVM architecture for inventory management.

ArchitectureΒΆ

Design PatternsΒΆ

  • MVVM (Model-View-ViewModel): Strict separation of concerns

  • Repository Pattern: Decoupled data access layer from business logic

  • Dependency Injection: Microsoft.Extensions.DependencyInjection

  • Command Pattern: RelayCommand and AsyncRelayCommand implementations

Technology StackΒΆ

  • .NET 8: Modern C# with latest features

  • WPF: Rich desktop user interface

  • Entity Framework Core: ORM with SQLite database

  • xUnit + FluentAssertions: Comprehensive unit testing

  • Microsoft Extensions: Configuration, Logging, DI

Database SchemaΒΆ

Products TableΒΆ

CREATE TABLE Products (
    Id INTEGER PRIMARY KEY AUTOINCREMENT,
    Name TEXT(100) NOT NULL,
    SKU TEXT(50) NOT NULL UNIQUE,
    Quantity INTEGER NOT NULL DEFAULT 0,
    Price DECIMAL(18,2) NOT NULL,
    CreatedAt DATETIME DEFAULT (datetime('now')),
    UpdatedAt DATETIME DEFAULT (datetime('now'))
);

FeaturesΒΆ

CRUD OperationsΒΆ

  • βœ… Create: Add new products with validation

  • βœ… Read: View all products in sortable DataGrid

  • βœ… Update: Edit existing products with form validation

  • βœ… Delete: Remove products with confirmation dialog

Data ManagementΒΆ

  • SQLite Database: Lightweight, file-based storage

  • Entity Framework Core: Code-first migrations

  • Unique SKU Validation: Prevents duplicate product codes

  • Automatic Timestamps: CreatedAt and UpdatedAt tracking

User ExperienceΒΆ

  • Responsive UI: Modern WPF styling with visual feedback

  • Real-time Validation: Input validation with error messages

  • Status Updates: Progress indicators and status messages

  • Keyboard Navigation: Full keyboard accessibility

ConfigurationΒΆ

Environment VariablesΒΆ

# Database connection string (optional)
INVENTORY_DB_CONNECTION="Data Source=custom_inventory.db;Cache=Shared"

appsettings.jsonΒΆ

{
  "ConnectionStrings": {
    "DefaultConnection": "Data Source=inventory.db;Cache=Shared"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.EntityFrameworkCore": "Warning"
    }
  }
}

Quality AssuranceΒΆ

Unit Testing CoverageΒΆ

  • βœ… Repository CRUD Operations: All database operations tested

  • βœ… Data Validation: Input validation and business rules

  • βœ… Error Handling: Exception scenarios and edge cases

  • βœ… Memory Management: Disposal and leak prevention

  • βœ… Connection Handling: Database connection lifecycle

Test CategoriesΒΆ

  1. Functional Tests: CRUD operations validation

  2. Integration Tests: Database interaction testing

  3. Performance Tests: Memory leak detection

  4. Boundary Tests: Edge case handling

Development SetupΒΆ

PrerequisitesΒΆ

  • .NET 8 SDK

  • Visual Studio 2022 or VS Code

  • SQLite (embedded)

InstallationΒΆ

# Clone repository
git clone https://github.com/AmalieShi/amalie_projects.git
cd amalie_projects/csharp/desktop-apps/wpf/WpfInventoryApp

# Restore dependencies
dotnet restore

# Build solution
dotnet build

# Run application
dotnet run

Running TestsΒΆ

# Run all tests
dotnet test

# Run with coverage
dotnet test --collect:"XPlat Code Coverage"

# Run specific test category
dotnet test --filter "Category=Repository"

πŸ“ Project StructureΒΆ

WpfInventoryApp/
β”œβ”€β”€ Commands/              # MVVM Command implementations
β”‚   β”œβ”€β”€ RelayCommand.cs
β”‚   └── AsyncRelayCommand.cs
β”œβ”€β”€ Data/                  # Entity Framework DbContext
β”‚   └── InventoryDbContext.cs
β”œβ”€β”€ Models/                # Data models
β”‚   └── Product.cs
β”œβ”€β”€ Repositories/          # Repository pattern implementation
β”‚   β”œβ”€β”€ IProductRepository.cs
β”‚   └── ProductRepository.cs
β”œβ”€β”€ ViewModels/            # MVVM ViewModels
β”‚   β”œβ”€β”€ ViewModelBase.cs
β”‚   β”œβ”€β”€ ProductViewModel.cs
β”‚   └── MainViewModel.cs
β”œβ”€β”€ Views/                 # WPF Views
β”‚   β”œβ”€β”€ MainWindow.xaml
β”‚   └── MainWindow.xaml.cs
β”œβ”€β”€ App.xaml              # Application resources
β”œβ”€β”€ App.xaml.cs           # Application startup
└── appsettings.json      # Configuration

WpfInventoryApp.Tests/
└── Repositories/         # Unit tests
    └── ProductRepositoryTests.cs

Security & Best PracticesΒΆ

Database SecurityΒΆ

  • Parameterized Queries: SQL injection prevention

  • Connection String Protection: Environment variable support

  • Data Validation: Input sanitization and validation

Memory ManagementΒΆ

  • IDisposable Implementation: Proper resource cleanup

  • DbContext Scoping: Dependency injection lifecycle management

  • Memory Leak Prevention: Verified through unit tests

Code QualityΒΆ

  • SOLID Principles: Clean architecture implementation

  • Separation of Concerns: MVVM pattern enforcement

  • Error Handling: Comprehensive exception management

  • Logging: Structured logging with Microsoft.Extensions.Logging

πŸ“ˆ Performance CharacteristicsΒΆ

  • Database: SQLite with Entity Framework Core optimization

  • UI Responsiveness: Async operations with progress indicators

  • Memory Footprint: Lightweight with proper disposal patterns

  • Startup Time: Fast initialization with dependency injection

ContributingΒΆ

This project follows enterprise development standards:

  1. Fork the repository

  2. Create feature branch (git checkout -b feature/AmazingFeature)

  3. Write tests for new functionality

  4. Ensure all tests pass (dotnet test)

  5. Commit changes (git commit -m 'Add AmazingFeature')

  6. Push to branch (git push origin feature/AmazingFeature)

  7. Open Pull Request

LicenseΒΆ

This project is part of the Amalie Projects portfolio and is available under the Apache License.


← Back to Csharp Desktop-Apps Wpf Projects