# alankhanal/asp.net-clean-architecture-basic-crud architecture

> Architecture diagram of the GitHub repository alankhanal/asp.net-clean-architecture-basic-crud, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alankhanal/asp.net-clean-architecture-basic-crud
- Repository: https://github.com/alankhanal/asp.net-clean-architecture-basic-crud

## Overview

This is a product-catalog API with a static browser client. The main workflow is an HTTP request to the products controller, through the application service and repository, to product persistence; reads return product DTOs and writes accept create/update DTOs. The application mapping profile translates between DTOs and domain products. Program.cs shows dependency registration, SQL Server configuration, and static-file hosting. The tree includes migrations, but their runtime role is not evidenced here; the browser client’s internal behavior is also not shown.

Main entry points: [`Application/Services/ProductService.cs`](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/Services/ProductService.cs) (Product service), [`CleanArchitecture/Program.cs`](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/CleanArchitecture/Program.cs) (Application host), [`Application/Mappings/MappingProfile.cs`](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/Mappings/MappingProfile.cs) (DTO mapping), [`Infrastructure/Repositories/ProductRepository.cs`](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Infrastructure/Repositories/ProductRepository.cs) (Product repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_browser["Static client<br/>[Index.js]"]
end

subgraph group_api["HTTP API"]
  node_controller["Products controller"]
  node_host["Application host<br/>[Program.cs]"]
end

subgraph group_application["Application and domain"]
  node_service["Product service<br/>[ProductService.cs]"]
  node_service_contract["Service contract<br/>[IProductService.cs]"]
  node_mapping["DTO mapping<br/>[MappingProfile.cs]"]
  node_create_dto["Create DTO"]
  node_product_dto["Product DTO<br/>[ProductDto.cs]"]
  node_update_dto["Update DTO"]
  node_product["Product entity<br/>[Product.cs]"]
  node_repository_contract["Repository contract"]
end

subgraph group_persistence["Persistence"]
  node_repository["Product repository"]
  node_db_context["EF database context"]
end

node_user(("User"))
node_sqlserver[("SQL Server")]

node_user -.->|"uses"| node_browser
node_host -->|"hosts static files"| node_browser
node_user -->|"sends product requests"| node_controller
node_controller -->|"calls"| node_service
node_host -->|"registers"| node_service
node_host -->|"registers"| node_repository
node_host -->|"registers"| node_mapping
node_host -->|"configures"| node_db_context
node_host -->|"configures provider"| node_sqlserver
node_controller -->|"depends on"| node_service_contract
node_service -->|"calls"| node_repository_contract
node_service -->|"maps products"| node_mapping
node_service -->|"accepts"| node_create_dto
node_service -->|"accepts"| node_update_dto
node_service -->|"returns"| node_product_dto
node_mapping -->|"maps"| node_product
node_mapping -->|"maps"| node_create_dto
node_mapping -->|"maps"| node_update_dto
node_mapping -->|"maps"| node_product_dto
node_repository -->|"reads and writes"| node_db_context
node_repository -->|"operates on"| node_product
node_db_context -->|"stores set of"| node_product
node_repository -->|"implements"| node_repository_contract

click node_browser "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/CleanArchitecture/wwwRoot/Index.js"
click node_controller "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/CleanArchitecture/Controllers/ProductsController.cs"
click node_service "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/Services/ProductService.cs"
click node_service_contract "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/Interfaces/IProductService.cs"
click node_mapping "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/Mappings/MappingProfile.cs"
click node_create_dto "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/DTOs/CreateProductDto.cs"
click node_product_dto "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/DTOs/ProductDto.cs"
click node_update_dto "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/DTOs/UpdateProductDto.cs"
click node_product "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Domain/Entities/Product.cs"
click node_repository_contract "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Domain/Interfaces/IProductRepository.cs"
click node_repository "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Infrastructure/Repositories/ProductRepository.cs"
click node_db_context "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Infrastructure/Data/ApplicationDbContext.cs"
click node_host "https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/CleanArchitecture/Program.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_browser,node_user toneBlue
class node_controller,node_host,node_sqlserver toneAmber
class node_service,node_service_contract,node_mapping,node_create_dto,node_product_dto,node_update_dto,node_product,node_repository_contract toneMint
class node_repository,node_db_context toneRose
```

## Components

### Browser client

- [Static client](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/CleanArchitecture/wwwRoot/Index.js): `CleanArchitecture/wwwRoot/Index.js`

### HTTP API

- [Products controller](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/CleanArchitecture/Controllers/ProductsController.cs): `CleanArchitecture/Controllers/ProductsController.cs`
- [Application host](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/CleanArchitecture/Program.cs): `CleanArchitecture/Program.cs`

### Application and domain

- [Product service](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/Services/ProductService.cs): `Application/Services/ProductService.cs`
- [Service contract](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/Interfaces/IProductService.cs): `Application/Interfaces/IProductService.cs`
- [DTO mapping](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/Mappings/MappingProfile.cs): `Application/Mappings/MappingProfile.cs`
- [Create DTO](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/DTOs/CreateProductDto.cs): `Application/DTOs/CreateProductDto.cs`
- [Product DTO](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/DTOs/ProductDto.cs): `Application/DTOs/ProductDto.cs`
- [Update DTO](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Application/DTOs/UpdateProductDto.cs): `Application/DTOs/UpdateProductDto.cs`
- [Product entity](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Domain/Entities/Product.cs): `Domain/Entities/Product.cs`
- [Repository contract](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Domain/Interfaces/IProductRepository.cs): `Domain/Interfaces/IProductRepository.cs`

### Persistence

- [Product repository](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Infrastructure/Repositories/ProductRepository.cs): `Infrastructure/Repositories/ProductRepository.cs`
- [EF database context](https://github.com/alankhanal/asp.net-clean-architecture-basic-crud/blob/master/Infrastructure/Data/ApplicationDbContext.cs): `Infrastructure/Data/ApplicationDbContext.cs`

### Other components

- **User**
- **SQL Server**

## Connections

- User → Static client: uses
- Application host → Static client: hosts static files (evidence: `CleanArchitecture/Program.cs`)
- User → Products controller: sends product requests (evidence: `CleanArchitecture/Controllers/ProductsController.cs`)
- Products controller → Product service: calls (evidence: `CleanArchitecture/Controllers/ProductsController.cs`)
- Application host → Product service: registers (evidence: `CleanArchitecture/Program.cs`)
- Application host → Product repository: registers (evidence: `CleanArchitecture/Program.cs`)
- Application host → DTO mapping: registers (evidence: `CleanArchitecture/Program.cs`)
- Application host → EF database context: configures (evidence: `CleanArchitecture/Program.cs`)
- Application host → SQL Server: configures provider (evidence: `CleanArchitecture/Program.cs`)
- Products controller → Service contract: depends on (evidence: `CleanArchitecture/Controllers/ProductsController.cs`)
- Product service → Repository contract: calls (evidence: `Application/Services/ProductService.cs`)
- Product service → DTO mapping: maps products (evidence: `Application/Services/ProductService.cs`)
- Product service → Create DTO: accepts (evidence: `Application/Services/ProductService.cs`)
- Product service → Update DTO: accepts (evidence: `Application/Services/ProductService.cs`)
- Product service → Product DTO: returns (evidence: `Application/Services/ProductService.cs`)
- DTO mapping → Product entity: maps (evidence: `Application/Mappings/MappingProfile.cs`)
- DTO mapping → Create DTO: maps (evidence: `Application/Mappings/MappingProfile.cs`)
- DTO mapping → Update DTO: maps (evidence: `Application/Mappings/MappingProfile.cs`)
- DTO mapping → Product DTO: maps (evidence: `Application/Mappings/MappingProfile.cs`)
- Product repository → EF database context: reads and writes (evidence: `Infrastructure/Repositories/ProductRepository.cs`)
- Product repository → Product entity: operates on (evidence: `Infrastructure/Repositories/ProductRepository.cs`)
- EF database context → Product entity: stores set of (evidence: `Infrastructure/Data/ApplicationDbContext.cs`)
- Product repository → Repository contract: implements (evidence: `Infrastructure/Repositories/ProductRepository.cs`)
