# ashurumaru/educational_practice_wpf_mvvm architecture

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

- Interactive diagram: https://gitdiagram.com/ashurumaru/educational_practice_wpf_mvvm
- Repository: https://github.com/ashurumaru/educational_practice_wpf_mvvm

## Overview

##### Project Type and Purpose
- This is a Windows desktop application built using WPF (Windows Presentation Foundation) in C#, following the MVVM (Model-View-ViewModel) pattern.
- Purpose: A user management system supporting login/registration, role-based user CRUD, theme selection, and background image loading.

##### High-Level Architectural Components
a. Presentation Layer (UI)
- Views: XAML windows and user controls under /Views and /CustomControls.
- Styles & Resources: XAML files under /Styles and /Images for theming and backgrounds.
b. Presentation Logic
- ViewModels: Classes under /ViewModels implementing INotifyPropertyChanged and RelayCommand. They receive user events, coordinate commands, expose data for binding.
c. Business & Data Access
- Models:
- UserModel – representation of a user entity
- DataBaseLogicModel – encapsulates EF database operations (login, CRUD).
- ThemeManager – handles loading and switching of themes/background images.
- Configuration: DataBaseConfig.cs holds connection settings; DatabaseQuery.sql for schema.
d. Persistence
- SQL Server database accessed via Entity Framework.

##### Relationships and Data Flows
- UI Events → ViewModels via Commands (RelayCommand)
- ViewModel Methods → Models for business logic and data access
- DataBaseLogicModel ↔ SQL Server (queries, updates)
- ThemeManager ↔ Local file system (Images folder) to load themes
- ViewModels update bound Views through INotifyPropertyChanged

##### Architectural Patterns and Principles
- MVVM: clear separation of concerns among Views, ViewModels, and Models.
- Dependency Inversion: ViewModels depend on interfaces of Models (DataBaseLogicModel), not direct database calls.
- Single Responsibility: each folder and class has a distinct role (UI, logic, data access, theming).

##### Technologies & Frameworks to Annotate
- WPF (XAML) for UI
- C# .NET (educational_practice.sln)
- Entity Framework (DbContext, LINQ) for ORM
- MVVM pattern implemented via BaseViewModel, RelayCommand
- SQL Server as the relational database

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        subgraph "Views"
            AddUserView["AddUserView.xaml / .cs"]:::ui
            LoginView["LoginView.xaml / .cs"]:::ui
            MessageBoxView["MessageBoxView.xaml / .cs"]:::ui
            PersonalAccountView["PersonalAccountView.xaml / .cs"]:::ui
            UpdateUserView["UpdateUserView.xaml / .cs"]:::ui
        end
        subgraph "Custom Controls"
            ChevronLeft["ChevronLeft.xaml / .cs"]:::ui
        end
        subgraph "Styles & Resources"
            DarkTheme["Dark.xaml"]:::ui
            OriginalTheme["Original.xaml"]:::ui
            WhiteTheme["White.xaml"]:::ui
            AppXAML["App.xaml / .cs"]:::ui
            AppConfig["App.config"]:::ui
            ImagesFolder["Images (assets)"]:::external
        end
    end

    %% Presentation Logic
    subgraph "Presentation Logic"
        BaseViewModel["BaseViewModel.cs"]:::logic
        LoginViewModel["LoginViewModel.cs"]:::logic
        PersonalAccountViewModel["PersonalAccountViewModel.cs"]:::logic
        MessageBoxViewModel["MessageBoxViewModel.cs"]:::logic
        RelayCommand["RelayCommand.cs"]:::logic
    end

    %% Business & Data Access
    subgraph "Business & Data Access"
        UserModel["UserModel.cs"]:::data
        DataBaseLogicModel["DataBaseLogicModel.cs\n(Entity Framework)"]:::data
        ThemeManager["ThemeManager.cs"]:::data
    end

    %% Persistence
    SQLServer["SQL Server Database"]:::persistence

    %% Relationships
    LoginView -->|"Execute LoginCommand"| LoginViewModel
    PersonalAccountView -->|"Bind Data / Commands"| PersonalAccountViewModel
    MessageBoxView -->|"Bind Data / Commands"| MessageBoxViewModel
    AddUserView -->|"Bind Data / Commands"| BaseViewModel
    UpdateUserView -->|"Bind Data / Commands"| BaseViewModel

    LoginViewModel -->|"Calls Business Logic"| DataBaseLogicModel
    PersonalAccountViewModel -->|"Calls Business Logic"| DataBaseLogicModel
    MessageBoxViewModel -->|"Calls Business Logic"| DataBaseLogicModel
    RelayCommand -->|"Implements ICommand for"| LoginViewModel
    RelayCommand -->|"Implements ICommand for"| PersonalAccountViewModel

    DataBaseLogicModel -->|"Executes SQL Queries"| SQLServer

    ThemeManager -->|"Loads from"| ImagesFolder
    ThemeManager -->|"Provides themes to"| DarkTheme
    ThemeManager -->|"Provides themes to"| OriginalTheme
    ThemeManager -->|"Provides themes to"| WhiteTheme

    %% Click Events
    click AddUserView "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/Views/AddUserView.xaml"
    click LoginView "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/Views/LoginView.xaml"
    click MessageBoxView "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/Views/MessageBoxView.xaml"
    click PersonalAccountView "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/Views/PersonalAccountView.xaml"
    click UpdateUserView "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/Views/UpdateUserView.xaml"
    click ChevronLeft "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/CustomControls/ChevronLeft.xaml"
    click DarkTheme "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/Styles/Dark.xaml"
    click OriginalTheme "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/Styles/Original.xaml"
    click WhiteTheme "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/Styles/White.xaml"
    click ImagesFolder "https://github.com/ashurumaru/educational_practice_wpf_mvvm/tree/master/educational_practice/Images"
    click AppXAML "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/App.xaml"
    click AppConfig "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/App.config"
    click BaseViewModel "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/ViewModels/BaseViewModel.cs"
    click LoginViewModel "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/ViewModels/LoginViewModel.cs"
    click PersonalAccountViewModel "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/ViewModels/PersonalAccountViewModel.cs"
    click MessageBoxViewModel "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/ViewModels/MessageBoxViewModel.cs"
    click RelayCommand "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/ViewModels/RelayCommand.cs"
    click UserModel "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/Models/UserModel.cs"
    click DataBaseLogicModel "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/Models/DataBaseLogicModel.cs"
    click ThemeManager "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/Models/ThemeMamager.cs"
    click SQLServer "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/DatabaseQuery.sql"
    click SQLServer "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/DataBaseConfig.cs"
    click SQLServer "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/educational_practice.sln"
    click SQLServer "https://github.com/ashurumaru/educational_practice_wpf_mvvm/blob/master/educational_practice/educational_practice.csproj"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#2980B9
    classDef logic fill:#A9DFBF,stroke:#27AE60
    classDef data fill:#F9E79F,stroke:#B7950B
    classDef persistence fill:#F5CBA7,stroke:#BA4A00
    classDef external fill:#D6DBDF,stroke:#7B7D7D
```
