# matthewrenze/clean-architecture-demo architecture

> Architecture diagram of the GitHub repository matthewrenze/clean-architecture-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/matthewrenze/clean-architecture-demo
- Repository: https://github.com/matthewrenze/clean-architecture-demo

## Overview

##### Main Components

a) Core Layers (Inside-Out):
- Domain Layer (Center)
- Contains entities (Customer, Employee, Product, Sale)
- Pure business logic and domain models

- Application Layer
- Contains business use cases
- Implements CQRS pattern (Commands and Queries)
- Interface definitions

b) Infrastructure Layers (Outside):
- Presentation Layer (MVC)
- Service Layer (Web API)
- Infrastructure Layer
- Persistence Layer

##### Detailed Component Breakdown

a) Domain Layer (Center):
- Core entities: Customer, Employee, Product, Sale
- IEntity interface connection

b) Application Layer:
- Split into Commands and Queries sections
- Main use cases:
- Customer Queries
- Employee Queries
- Product Queries
- Sale Commands/Queries

c) Infrastructure Components:
- Persistence: DatabaseService, Configurations
- Infrastructure: InventoryService, Network
- Presentation: MVC Controllers
- Service: Web API Controllers

##### Cross-Cutting Concerns
- Common utilities and services
- Dependency Injection (StructureMap)
- Date services
- Testing infrastructure

##### Important Elements to Highlight

a) CQRS Pattern Implementation:
- Separation of Commands and Queries
- Query models vs. command models

b) Interface Boundaries:
- IDatabaseService
- IInventoryService
- Query/Command interfaces

c) Factory Patterns:
- SaleFactory
- ViewModelFactory

##### Technical Details

- Framework: .NET Framework 4.8
- Key Technologies:
- ASP.NET MVC 5.2
- Entity Framework 6.4
- StructureMap 4.7

##### Testing Components
- Test projects relationship
- SpecFlow specifications
- Unit test coverage

##### Notes
- Clean Architecture principles
- Dependency flow
- Key design decisions

Remember to maintain a balance between detail and clarity, focusing on the architectural boundaries and dependencies while avoiding overwhelming detail at the implementation level.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Component]
        L2[(Database)]
        L3([Service])
        L4{{"Interface"}}
        style L1 fill:#f5f5f5
        style L2 fill:#e1e1e1
        style L3 fill:#d4d4d4
        style L4 fill:#c3c3c3
    end

    subgraph Domain["Domain Layer"]
        IEntity{{"IEntity Interface"}}
        Customer["Customer Entity"]
        Employee["Employee Entity"]
        Product["Product Entity"]
        Sale["Sale Entity"]

        IEntity --> Customer
        IEntity --> Employee
        IEntity --> Product
        IEntity --> Sale
    end

    subgraph Application["Application Layer"]
        direction TB
        subgraph Commands
            SaleCommands["Sale Commands"]
        end
        
        subgraph Queries
            CustomerQueries["Customer Queries"]
            EmployeeQueries["Employee Queries"]
            ProductQueries["Product Queries"]
            SaleQueries["Sale Queries"]
        end

        CoreInterfaces{{"Core Interfaces"}}
    end

    subgraph Infrastructure["Infrastructure Layer"]
        InventoryService([Inventory Service])
        NetworkServices([Network Services])
    end

    subgraph Persistence["Persistence Layer"]
        DatabaseService[(Database Service)]
        
        CustomerConfig["Customer Configuration"]
        EmployeeConfig["Employee Configuration"]
        ProductConfig["Product Configuration"]
        SaleConfig["Sale Configuration"]
        
        DatabaseService --> CustomerConfig
        DatabaseService --> EmployeeConfig
        DatabaseService --> ProductConfig
        DatabaseService --> SaleConfig
    end

    subgraph Presentation["Presentation Layer (MVC)"]
        MVCCustomers["Customers Controller"]
        MVCProducts["Products Controller"]
        MVCSales["Sales Controller"]
        SharedViews["Shared Views"]
    end

    subgraph Service["Service Layer (API)"]
        APICustomers["Customers API"]
        APIProducts["Products API"]
        APISales["Sales API"]
    end

    subgraph CrossCutting["Cross-Cutting Concerns"]
        DateServices["Date Services"]
        TestingInfra["Testing Infrastructure"]
        DI["Dependency Injection"]
    end

    %% Dependencies and Relationships
    Presentation --> Application
    Service --> Application
    Application --> Domain
    Infrastructure --> Application
    Persistence --> Application

    %% Click Events
    click IEntity "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Domain/Common/IEntity.cs"
    click Customer "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Domain/Customers/Customer.cs"
    click Employee "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Domain/Employees/Employee.cs"
    click Product "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Domain/Products/Product.cs"
    click Sale "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Domain/Sales/Sale.cs"
    
    click CustomerQueries "https://github.com/matthewrenze/clean-architecture-demo/tree/master/Application/Customers/Queries"
    click EmployeeQueries "https://github.com/matthewrenze/clean-architecture-demo/tree/master/Application/Employees/Queries"
    click ProductQueries "https://github.com/matthewrenze/clean-architecture-demo/tree/master/Application/Products/Queries"
    click SaleCommands "https://github.com/matthewrenze/clean-architecture-demo/tree/master/Application/Sales/Commands"
    click SaleQueries "https://github.com/matthewrenze/clean-architecture-demo/tree/master/Application/Sales/Queries"
    click CoreInterfaces "https://github.com/matthewrenze/clean-architecture-demo/tree/master/Application/Interfaces"
    
    click InventoryService "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Infrastructure/Inventory/InventoryService.cs"
    click NetworkServices "https://github.com/matthewrenze/clean-architecture-demo/tree/master/Infrastructure/Network"
    
    click DatabaseService "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Persistence/DatabaseService.cs"
    click CustomerConfig "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Persistence/Customers/CustomerConfiguration.cs"
    click EmployeeConfig "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Persistence/Employees/EmployeeConfiguration.cs"
    click ProductConfig "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Persistence/Products/ProductConfiguration.cs"
    click SaleConfig "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Persistence/Sales/SaleConfiguration.cs"
    
    click MVCCustomers "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Presentation/Customers/CustomersController.cs"
    click MVCProducts "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Presentation/Products/ProductsController.cs"
    click MVCSales "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Presentation/Sales/SalesController.cs"
    click SharedViews "https://github.com/matthewrenze/clean-architecture-demo/tree/master/Presentation/Shared/Views"
    
    click APICustomers "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Service/Customers/CustomersController.cs"
    click APIProducts "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Service/Products/ProductsController.cs"
    click APISales "https://github.com/matthewrenze/clean-architecture-demo/blob/master/Service/Sales/SalesController.cs"
    
    click DateServices "https://github.com/matthewrenze/clean-architecture-demo/tree/master/Common/Dates"
    click TestingInfra "https://github.com/matthewrenze/clean-architecture-demo/tree/master/Common/Mocks"
    click DI "https://github.com/matthewrenze/clean-architecture-demo/tree/master/Presentation/DependencyResolution"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef interface fill:#e1e1e1,stroke:#333,stroke-width:1px
    classDef service fill:#d4d4d4,stroke:#333,stroke-width:1px
    classDef database fill:#c3c3c3,stroke:#333,stroke-width:1px
```
