# eimarramos/doppio architecture

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

- Interactive diagram: https://gitdiagram.com/eimarramos/doppio
- Repository: https://github.com/eimarramos/doppio

## Overview

##### Main Components
- UI Layer:
– Contains all the XAML pages, view models, and platform-specific implementations (Android, iOS, Windows, etc.).
– Handles presentation logic, user interaction, and navigation.
- Application Layer:
– Houses various service classes (CartService, CategoryService, CoffeeService, ShopService) and the dependency injection configuration.
– Responsible for orchestrating business logic and acting as a mediator between the UI and Domain layers.
- Domain Layer:
– Contains all the domain models (Cart, CartDetail, Category, Coffee, Notify, Shop) along with repository interface definitions (for Cart, Category, Coffee, Shop).
– Represents the core business logic and rules.
- Infrastructure Layer:
– Implements the repository classes for various domain entities through API-based data access.
– Contains persistence components (e.g., DatabaseContext, Initialiser, interceptors) and common utilities (such as base entities and mapping profiles).
– Handles external concerns like data storage, caching, and integration with external APIs.

##### Relationships and Data Flow
- The UI layer (views and view models) communicates with the Application layer’s services to perform business operations.
- The Application layer uses its dependency injection configuration to work with the Domain layer’s repository interfaces.
- The Infrastructure layer provides the actual implementations for these repositories and manages database actions through the DatabaseContext and persistence classes.
- Data flows from the UI to the Application layer, then to the Domain—which encapsulates business rules—and finally the Infrastructure layer handles data persistence.
- Additionally, mapping profiles and interceptors in the Infrastructure assist in transforming domain entities to infrastructure-specific representations and enforcing rules (e.g., CartTotalInterceptor).

##### Architectural Patterns and Design Principles
- Emphasis on separation of concerns: Each layer (UI, Application, Domain, Infrastructure) has a distinct responsibility.
- Use of the Repository Pattern: Domain interfaces are defined in the Domain layer, while their implementations reside in the Infrastructure layer.
- Dependency Injection: Centralized in the ApplicationLayer and Infrastructure projects, ensuring inversion of control.
- Cross-platform UI via .NET MAUI: Indicates a strong focus on modular design and platform abstraction for the UI components.

– UI → Application Services (for invoking business operations)
– Application Services → Domain (for business rules)
– Domain → Infrastructure (for repository calls and persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD
    Doppio["Doppio.sln"]

    subgraph "UI Layer"
        UI["UI (MAUI - XAML & ViewModels)"]:::ui
    end

    subgraph "Application Layer"
        App["Application Services (DI, Business Logic)"]:::app
        DI["DI Container (Dependency Injection)"]:::app
    end

    subgraph "Domain Layer"
        Domain["Domain Models & Repositories"]:::domain
    end

    subgraph "Infrastructure Layer"
        Infra["Infrastructure (API, Persistence, Mapping Profiles)"]:::infra
        DB["Database (Entity Framework Core)"]:::database
    end

    Doppio -->|"contains"| UI
    UI -->|"callsService"| App
    App -->|"configuresDI"| DI
    DI -->|"injectsRepositoryInterface"| Domain
    DI -->|"injectsRepositoryImplementation"| Infra
    Domain -->|"repositoryCalls"| Infra
    Infra -->|"persistsData"| DB

    click UI "https://github.com/eimarramos/doppio/tree/master/src/UI"
    click App "https://github.com/eimarramos/doppio/tree/master/src/ApplicationLayer"
    click Domain "https://github.com/eimarramos/doppio/tree/master/src/Domain"
    click Infra "https://github.com/eimarramos/doppio/tree/master/src/Infrastructure"

    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef app fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef domain fill:#FFFF99,stroke:#333,stroke-width:2px;
    classDef infra fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef database fill:#F0F8FF,stroke:#333,stroke-width:2px;
```
