# rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server architecture

> Architecture diagram of the GitHub repository rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server
- Repository: https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server

## Overview

##### Main Components
- Presentation Layer: This includes all WPF elements such as Views (LoginView.xaml, MainView.xaml) and the Custom Controls (BindablePasswordBox). Mark these as the “UI / View” components.
- ViewModels: Represented by the LoginViewModel, MainViewModel, and the associated ViewModelBase and ViewModelCommand elements. These orchestrate the logic and mediate between the UI and the business/data layers.
- Models: These include UserModel, UserAccountModel, and the IUserRepository interface. They represent the data and business rules.
- Data Access / Repository Layer: Consisting of RepositoryBase and UserRepository which handle interactions with the SQL Server database via the MVVMLoginDb.sql script.
- Application Configuration: Files like App.xaml/App.config declare application startup procedures and configurations.
- SQL Server Backend: Represented externally by the MVVMLoginDb.sql file, which sets up the database schema and any necessary stored procedures.

##### Relationships and Interactions
- Optionally, include configuration and startup elements (i.e., App.xaml) as the project’s entry point that loads the initial View and ViewModel.

##### Architectural Patterns and Design Principles
- That the project follows the MVVM pattern by segregating the UI, ViewModel, and Model layers.
- How dependency injection or service location might be used (if it is implicit) to link the repositories to the view models.
- Separation of concerns, where the UI is decoupled from business logic and data handling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer (WPF Views & Custom Controls)"
        pv1["LoginView.xaml"]:::ui
        pv2["MainView.xaml"]:::ui
        pv3["BindablePasswordBox.xaml"]:::ui
    end

    %% Business Logic / ViewModels
    subgraph "Business Logic / ViewModels"
        vm1["LoginViewModel"]:::vm
        vm2["MainViewModel"]:::vm
        vm3["ViewModelBase"]:::vm
        vm4["ViewModelCommand"]:::vm
    end

    %% Data Models and Repository Layer
    subgraph "Data Models and Repository Layer"
        m1["UserModel"]:::model
        m2["UserAccountModel"]:::model
        m3["IUserRepository"]:::model
        subgraph "Repository Layer"
            r1["RepositoryBase"]:::repository
            r2["UserRepository"]:::repository
        end
    end

    %% Application Configuration
    subgraph "Application Configuration"
        ac1["App.xaml"]:::config
        ac2["App.config"]:::config
    end

    %% SQL Server Backend
    db["MVVMLoginDb.sql"]:::db

    %% Interactions between Layers
    %% UI binds to corresponding ViewModels
    pv1 -->|"bindsTo"| vm1
    pv2 -->|"bindsTo"| vm2
    pv3 -->|"usedIn"| pv1

    %% ViewModel Inheritance and Utilization
    vm1 -->|"inherits"| vm3
    vm2 -->|"inherits"| vm3
    vm1 -->|"uses"| vm4
    vm2 -->|"uses"| vm4

    %% ViewModels interacting with Models
    vm1 -->|"updates"| m1
    vm1 -->|"updates"| m2
    vm2 -->|"updates"| m1
    vm2 -->|"updates"| m2
    vm1 -->|"calls"| m3
    vm2 -->|"calls"| m3

    %% Repository Implementation and Data Access
    m3 -->|"implementedBy"| r2
    r2 -->|"extends"| r1
    r2 -->|"executes"| db

    %% Application Startup Initialization
    ac1 -->|"initializes"| pv1
    ac1 -->|"initializes"| vm1

    %% Styles for different layers
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef vm fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef model fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef repository fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef config fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef db fill:#FFA07A,stroke:#000,stroke-width:1px;

    %% Click Events for Component Mapping
    click pv1 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/Views/LoginView.xaml"
    click pv2 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/Views/MainView.xaml"
    click pv3 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/CustomControls/BindablePasswordBox.xaml"
    click vm1 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/ViewModels/LoginViewModel.cs"
    click vm2 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/ViewModels/MainViewModel.cs"
    click vm3 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/ViewModels/ViewModelBase.cs"
    click vm4 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/ViewModels/ViewModelCommand.cs"
    click m1 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/Models/UserModel.cs"
    click m2 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/Models/UserAccountModel.cs"
    click m3 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/Models/IUserRepository.cs"
    click r1 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/Repositories/RepositoryBase.cs"
    click r2 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/Repositories/UserRepository.cs"
    click ac1 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/App.xaml"
    click ac2 "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/WPF-LoginForm/App.config"
    click db "https://github.com/rjcodeadvance/login-in-wpf-mvvm-c-sharp-and-sql-server/blob/main/MVVMLoginDb.sql"
```
