# krawmire/profitocracy-maui architecture

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

- Interactive diagram: https://gitdiagram.com/krawmire/profitocracy-maui
- Repository: https://github.com/krawmire/profitocracy-maui

## Overview

##### Main Components
- Mobile UI Layer (Profitocracy.Mobile): This is the presentation layer handling all user interactions. It includes platform-specific configurations and pages (for Android, iOS, Windows, etc.), view models, and services (e.g., for currency, theme, and localization). The UI layer uses XAML pages, code-behind, and supports multi-platform builds.
- Domain Core (Profitocracy.Core): This layer contains the business logic, modeled with DDD. It includes domain models for Profiles, Categories, Transactions, Settings, and Summaries. It also defines abstractions (interfaces for calculation, profile, and category services), factories to build domain objects, and shared kernel objects (like AggregateRoot, Entity, and ValueObject). All the core business rules and calculations are encapsulated here.
- Infrastructure (Profitocracy.Infrastructure): This layer provides persistence and data handling implementations. It includes repositories (like ProfileRepository, CategoryRepository, etc.), mappers for translating between domain models and persistence models, and configuration files specifically for SQLlite persistence. This layer implements interfaces defined in the core and ties the business logic to actual storage mechanisms.
- Project Setup & Documentation: The solution file (Profitocracy.sln), documentation assets, and configuration files provide additional context for deployment and integration.

##### Out Relationships and Interactions
- The Mobile UI layer interacts with the Domain Core via service calls. For example, view models communicate with the CalculationService, ProfileService, and CategoryService to process user actions.
- The Domain Core layer relies on abstractions and interfaces which are implemented in the Infrastructure layer. The repositories (IProfileRepository, ICategoryRepository, etc.) abstract the persistence details, allowing business logic to work agnostic of the data store.
- Dependency inversion is employed so that the Domain defines interfaces and the Infrastructure provides concrete implementations (e.g., for SQLlite data persistence).
- The application leverages dependency injection (configured likely in MauiProgram.cs and related initialization classes) to wire up these relationships dynamically at runtime.
- The persistence layer (Infrastructure/Sqlite) contains mappers that convert domain objects to and from SQLlite models.

##### Architectural Patterns and Design Principles
- Domain-Driven Design (DDD): Separate domain logic from persistence and presentation. Domain models, factories, and value objects are located within Profitocracy.Core.
- Repository Pattern: Abstracts data access through defined interfaces in the core and implemented in the infrastructure layer.
- Dependency Injection: Using configuration files and registries (e.g., CoreRegistry.cs, InfrastructureRegistry.cs) to manage dependencies.
- Multi-layered Architecture: Clear separation between Mobile (Presentation), Core (Business Logic), and Infrastructure (Data Access).
- Factories and Value Objects: Use of factories (e.g., CategoryFactory, ProfileBuilder) ensures that object construction is centralized and encapsulated.

##### Technologies and Frameworks
- .NET / C# as the primary programming language.
- .NET MAUI for the mobile application.
- SQLlite for local data storage.
- Design patterns like Repository, Dependency Injection, and Domain-Driven Design are vital to the architectural foundation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile UI Layer
    subgraph "Mobile UI Layer (Profitocracy.Mobile)"
        MUI["Mobile UI Layer"]:::mobile
        Views["Views"]:::mobile
        VMs["ViewModels"]:::mobile
        Services["Services"]:::mobile
        Maui["MauiProgram.cs"]:::mobile
    end

    %% Domain Core Layer
    subgraph "Domain Core (Profitocracy.Core)"
        DC["Domain Core"]:::core
        Models["Domain Models & Factories"]:::core
        DServices["Domain Services"]:::core
        CoreRegistry["CoreRegistry.cs"]:::core
        RepoInterfaces["Repository Interfaces"]:::core
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer (Profitocracy.Infrastructure)"
        INF["Infrastructure Layer"]:::infra
        SqliteConfig["SQLlite Persistence Configuration"]:::infra
        InfraRegistry["InfrastructureRegistry.cs"]:::infra
        SqliteRepos["SQLlite Repositories"]:::infra
        SqliteMappers["SQLlite Mappers"]:::infra
    end

    %% Inter-layer Interactions
    MUI -->|"serviceCalls"| DC
    Services -->|"calls"| DServices
    DServices -->|"uses"| RepoInterfaces
    RepoInterfaces -->|"implementedBy"| SqliteRepos
    SqliteRepos -->|"maps"| SqliteMappers
    DC -->|"repositoryCalls"| INF

    %% Dependency Injection Wiring
    Maui -->|"wiresTo"| CoreRegistry
    Maui -->|"wiresTo"| InfraRegistry

    %% Class Definitions (Colors)
    classDef mobile fill:#f9d5e5,stroke:#333,stroke-width:2px;
    classDef core fill:#d5f9e5,stroke:#333,stroke-width:2px;
    classDef infra fill:#d5e5f9,stroke:#333,stroke-width:2px;

    %% Click Events
    click MUI "https://github.com/krawmire/profitocracy-maui/blob/dev/src/Profitocracy.Mobile"
    click Maui "https://github.com/krawmire/profitocracy-maui/blob/dev/src/Profitocracy.Mobile/MauiProgram.cs"
    click DC "https://github.com/krawmire/profitocracy-maui/blob/dev/src/Profitocracy.Core"
    click Models "https://github.com/krawmire/profitocracy-maui/tree/dev/src/Profitocracy.Core/Domain/Model"
    click DServices "https://github.com/krawmire/profitocracy-maui/tree/dev/src/Profitocracy.Core/Domain/Services"
    click CoreRegistry "https://github.com/krawmire/profitocracy-maui/blob/dev/src/Profitocracy.Core/CoreRegistry.cs"
    click RepoInterfaces "https://github.com/krawmire/profitocracy-maui/tree/dev/src/Profitocracy.Core/Persistence"
    click INF "https://github.com/krawmire/profitocracy-maui/blob/dev/src/Profitocracy.Infrastructure"
    click SqliteConfig "https://github.com/krawmire/profitocracy-maui/tree/dev/src/Profitocracy.Infrastructure/Persistence/Sqlite"
    click InfraRegistry "https://github.com/krawmire/profitocracy-maui/blob/dev/src/Profitocracy.Infrastructure/InfrastructureRegistry.cs"
    click SqliteRepos "https://github.com/krawmire/profitocracy-maui/tree/dev/src/Profitocracy.Infrastructure/Persistence/Sqlite/Repositories"
    click SqliteMappers "https://github.com/krawmire/profitocracy-maui/tree/dev/src/Profitocracy.Infrastructure/Persistence/Sqlite/Mappers"
```
