# kbieszczad/car-dealership-system architecture

> Architecture diagram of the GitHub repository kbieszczad/car-dealership-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kbieszczad/car-dealership-system
- Repository: https://github.com/kbieszczad/car-dealership-system

## Overview

#### Purpose and runtime
SalonSamochodowy is a Windows desktop dealership-management application. It targets WPF/.NET Desktop Runtime and persists operational data through Entity Framework Core to SQL Server. The solution/project entry artifacts are `SalonSamochodowy/SalonSamochodowy.sln` and `SalonSamochodowy/SalonSamochodowy.csproj`; application startup is defined by `SalonSamochodowy/App.xaml` and `SalonSamochodowy/App.xaml.cs`.

#### UI composition and navigation
The application follows MVVM: XAML Views render screens while ViewModels own presentation state, commands, and screen orchestration. The main authenticated shell is `SalonSamochodowy/Views/MainWindow.xaml`, backed by `SalonSamochodowy/ViewModels/MainWindowViewModel.cs`. Login and initial deployment are separate flows in `SalonSamochodowy/Views/LoginWindow.xaml` and `SalonSamochodowy/Views/FirstConfigWindow.xaml`.

#### Identity, roles, and session boundary
Authentication and user/role logic are centralized in `SalonSamochodowy/Services/AuthService.cs`, using user and role entities in `SalonSamochodowy/Entities/AppUser.cs` and `SalonSamochodowy/Entities/AppRole.cs`. `SalonSamochodowy/SessionContext.cs` represents application-level active-user state. Role-aware navigation and permissions gate administrative, sales, service, client, and management workflows.

#### Persistence and transaction layer
`SalonSamochodowy/Entities/AppDbContext.cs` is the EF Core database boundary. Domain persistence is abstracted behind generic repository and unit-of-work contracts/implementations: `SalonSamochodowy/Repositories/IRepository.cs`, `SalonSamochodowy/Repositories/Repository.cs`, and `SalonSamochodowy/Repositories/UnitOfWork.cs`. This places query and coordinated save behavior below business services rather than ViewModels. Initial or demo database population is handled by `SalonSamochodowy/Entities/DbSeeder.cs`.

#### Core dealership domain and services
The data model covers dealership inventory, customers, orders, staffing, and service work: `SalonSamochodowy/Entities/Vehicle.cs`, `SalonSamochodowy/Entities/SalesOrder.cs`, and `SalonSamochodowy/Entities/Job.cs`, with related model/engine/trim/features entities. Service-layer use cases separate these domains: `SalonSamochodowy/Services/VehicleService.cs`, `SalonSamochodowy/Services/ClientService.cs`, `SalonSamochodowy/Services/OrderService.cs`, and `SalonSamochodowy/Services/JobService.cs`. Typical flow is View → ViewModel → domain service → Unit of Work/EF Core → SQL Server.

#### Operational screens and updates
Inventory/catalog flows are presented through `SalonSamochodowy/ViewModels/VehiclesPageViewModel.cs` and `SalonSamochodowy/ViewModels/AddVehicleViewModel.cs`; order creation through `SalonSamochodowy/ViewModels/CreateOrderViewModel.cs`; service operations through `SalonSamochodowy/ViewModels/ServicesPageViewModel.cs`. Cross-screen refreshes use application messages, notably `SalonSamochodowy/Messages/DataChangedMessage.cs`, avoiding direct coupling between independently displayed screens.

#### Reporting and localization
Management reporting is driven by `SalonSamochodowy/ViewModels/ReportsPageViewModel.cs` and `SalonSamochodowy/Services/ReportGeneratorService.cs`, with PDF/chart output delegated to `SalonSamochodowy/Services/PdfChartGenerator.cs`. Bilingual UI resources reside in `SalonSamochodowy/Resources/Languages/Strings.en.xaml` and `SalonSamochodowy/Resources/Languages/Strings.pl.xaml`; language changes propagate through `SalonSamochodowy/Messages/LanguageChangedMessage.cs`.

Main entry points: [`SalonSamochodowy/Entities/AppDbContext.cs`](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Entities/AppDbContext.cs) (EF Core Context), [`SalonSamochodowy/ViewModels/MainWindowViewModel.cs`](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/ViewModels/MainWindowViewModel.cs) (Shell Navigation), [`SalonSamochodowy/Repositories/UnitOfWork.cs`](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Repositories/UnitOfWork.cs) (Unit of Work), [`SalonSamochodowy/Views/LoginWindow.xaml`](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Views/LoginWindow.xaml) (Login & Setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["WPF Presentation"]
  node_startup["WPF Startup<br/>application bootstrap<br/>[App.xaml.cs]"]
  node_auth_screens["Login &amp; Setup<br/>WPF views<br/>[LoginWindow.xaml]"]
  node_main_shell["Authenticated Shell<br/>WPF view<br/>[MainWindow.xaml]"]
  node_main_vm["Shell Navigation<br/>view model"]
  node_operations_vms["Operational Workflows<br/>view models"]
  node_reports_vm["Reporting UI<br/>view model"]
end

subgraph group_application["Application Services"]
  node_auth_service["Authentication &amp; Roles<br/>[AuthService.cs]"]
  node_domain_services["Dealership Use Cases<br/>services<br/>[VehicleService.cs]"]
  node_report_service["Report Generation"]
  node_pdf_charts["PDF &amp; Chart Output<br/>report renderer"]
end

subgraph group_data["Persistence"]
  node_unit_of_work["Unit of Work<br/>transaction boundary<br/>[UnitOfWork.cs]"]
  node_repository["Generic Repository<br/>data access<br/>[Repository.cs]"]
  node_db_context[("EF Core Context<br/>database context<br/>[AppDbContext.cs]")]
  node_domain_entities["Dealership Domain<br/>EF entities<br/>[Vehicle.cs]"]
  node_seeder["Database Seeder<br/>initialization<br/>[DbSeeder.cs]"]
  node_sql_server[("SQL Server<br/>operational database")]
end

subgraph group_crosscutting["Cross-Cutting"]
  node_session["Active User Session<br/>session context<br/>[SessionContext.cs]"]
  node_data_messages["Data Change Messages<br/>application messages"]
  node_language_messages["Language Messages<br/>application messages"]
  node_localized_resources["Bilingual Resources<br/>XAML resources<br/>[Strings.en.xaml]"]
end

node_startup -->|"opens"| node_auth_screens
node_startup -->|"initializes"| node_db_context
node_db_context -->|"seeds"| node_seeder
node_auth_screens -->|"authenticates via"| node_auth_service
node_auth_service -->|"sets"| node_session
node_auth_screens -->|"on success"| node_main_shell
node_main_shell -->|"binds"| node_main_vm
node_main_vm -->|"checks roles"| node_session
node_main_vm -->|"navigates to"| node_operations_vms
node_main_vm -->|"navigates to"| node_reports_vm
node_operations_vms -->|"executes use cases"| node_domain_services
node_domain_services -.->|"publishes updates"| node_data_messages
node_data_messages -.->|"triggers refresh"| node_operations_vms
node_reports_vm -->|"requests"| node_report_service
node_report_service -->|"renders"| node_pdf_charts
node_domain_services -->|"persists through"| node_unit_of_work
node_report_service -->|"queries through"| node_unit_of_work
node_auth_service -->|"loads users and roles"| node_unit_of_work
node_unit_of_work -->|"coordinates"| node_repository
node_repository -->|"uses"| node_db_context
node_db_context -->|"maps"| node_domain_entities
node_db_context -->|"persists to"| node_sql_server
node_language_messages -.->|"switches"| node_localized_resources
node_language_messages -.->|"updates UI"| node_main_shell

click node_startup "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/App.xaml.cs"
click node_auth_screens "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Views/LoginWindow.xaml"
click node_main_shell "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Views/MainWindow.xaml"
click node_main_vm "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/ViewModels/MainWindowViewModel.cs"
click node_operations_vms "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/ViewModels/VehiclesPageViewModel.cs"
click node_reports_vm "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/ViewModels/ReportsPageViewModel.cs"
click node_auth_service "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Services/AuthService.cs"
click node_domain_services "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Services/VehicleService.cs"
click node_report_service "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Services/ReportGeneratorService.cs"
click node_pdf_charts "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Services/PdfChartGenerator.cs"
click node_session "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/SessionContext.cs"
click node_data_messages "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Messages/DataChangedMessage.cs"
click node_language_messages "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Messages/LanguageChangedMessage.cs"
click node_localized_resources "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Resources/Languages/Strings.en.xaml"
click node_unit_of_work "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Repositories/UnitOfWork.cs"
click node_repository "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Repositories/Repository.cs"
click node_db_context "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Entities/AppDbContext.cs"
click node_domain_entities "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Entities/Vehicle.cs"
click node_seeder "https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Entities/DbSeeder.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_startup,node_auth_screens,node_main_shell,node_main_vm,node_operations_vms,node_reports_vm toneBlue
class node_auth_service,node_domain_services,node_report_service,node_pdf_charts toneAmber
class node_unit_of_work,node_repository,node_db_context,node_domain_entities,node_seeder,node_sql_server toneMint
class node_session,node_data_messages,node_language_messages,node_localized_resources toneRose
```

## Components

### WPF Presentation

- [WPF Startup](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/App.xaml.cs): application bootstrap · Starts the desktop application and initial configuration flow. · `SalonSamochodowy/App.xaml.cs`
- [Login & Setup](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Views/LoginWindow.xaml): WPF views · `SalonSamochodowy/Views/LoginWindow.xaml`
- [Authenticated Shell](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Views/MainWindow.xaml): WPF view · `SalonSamochodowy/Views/MainWindow.xaml`
- [Shell Navigation](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/ViewModels/MainWindowViewModel.cs): view model · Owns role-aware navigation and screen orchestration. · `SalonSamochodowy/ViewModels/MainWindowViewModel.cs`
- [Operational Workflows](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/ViewModels/VehiclesPageViewModel.cs): view models · Inventory, order creation, and service screen state. · `SalonSamochodowy/ViewModels/VehiclesPageViewModel.cs`
- [Reporting UI](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/ViewModels/ReportsPageViewModel.cs): view model · `SalonSamochodowy/ViewModels/ReportsPageViewModel.cs`

### Application Services

- [Authentication & Roles](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Services/AuthService.cs): service · `SalonSamochodowy/Services/AuthService.cs`
- [Dealership Use Cases](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Services/VehicleService.cs): services · Vehicle, client, order, and job operations. · `SalonSamochodowy/Services/VehicleService.cs`
- [Report Generation](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Services/ReportGeneratorService.cs): service · `SalonSamochodowy/Services/ReportGeneratorService.cs`
- [PDF & Chart Output](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Services/PdfChartGenerator.cs): report renderer · `SalonSamochodowy/Services/PdfChartGenerator.cs`

### Persistence

- [Unit of Work](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Repositories/UnitOfWork.cs): transaction boundary · Coordinates repository persistence and saves. · `SalonSamochodowy/Repositories/UnitOfWork.cs`
- [Generic Repository](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Repositories/Repository.cs): data access · `SalonSamochodowy/Repositories/Repository.cs`
- [EF Core Context](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Entities/AppDbContext.cs): database context · `SalonSamochodowy/Entities/AppDbContext.cs`
- [Dealership Domain](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Entities/Vehicle.cs): EF entities · Vehicles, sales orders, jobs, users, roles, and related records. · `SalonSamochodowy/Entities/Vehicle.cs`
- [Database Seeder](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Entities/DbSeeder.cs): initialization · Populates initial or demo data. · `SalonSamochodowy/Entities/DbSeeder.cs`
- **SQL Server**: operational database

### Cross-Cutting

- [Active User Session](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/SessionContext.cs): session context · `SalonSamochodowy/SessionContext.cs`
- [Data Change Messages](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Messages/DataChangedMessage.cs): application messages · Refreshes independently displayed screens. · `SalonSamochodowy/Messages/DataChangedMessage.cs`
- [Language Messages](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Messages/LanguageChangedMessage.cs): application messages · `SalonSamochodowy/Messages/LanguageChangedMessage.cs`
- [Bilingual Resources](https://github.com/kbieszczad/car-dealership-system/blob/main/SalonSamochodowy/Resources/Languages/Strings.en.xaml): XAML resources · English and Polish UI strings. · `SalonSamochodowy/Resources/Languages/Strings.en.xaml`

## Connections

- WPF Startup → Login & Setup: opens
- WPF Startup → EF Core Context: initializes
- EF Core Context → Database Seeder: seeds
- Login & Setup → Authentication & Roles: authenticates via
- Authentication & Roles → Active User Session: sets
- Login & Setup → Authenticated Shell: on success
- Authenticated Shell → Shell Navigation: binds
- Shell Navigation → Active User Session: checks roles
- Shell Navigation → Operational Workflows: navigates to
- Shell Navigation → Reporting UI: navigates to
- Operational Workflows → Dealership Use Cases: executes use cases
- Dealership Use Cases → Data Change Messages: publishes updates
- Data Change Messages → Operational Workflows: triggers refresh
- Reporting UI → Report Generation: requests
- Report Generation → PDF & Chart Output: renders
- Dealership Use Cases → Unit of Work: persists through
- Report Generation → Unit of Work: queries through
- Authentication & Roles → Unit of Work: loads users and roles
- Unit of Work → Generic Repository: coordinates
- Generic Repository → EF Core Context: uses
- EF Core Context → Dealership Domain: maps
- EF Core Context → SQL Server: persists to
- Language Messages → Bilingual Resources: switches
- Language Messages → Authenticated Shell: updates UI
