# iammukeshm/onionarchitecture architecture

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

- Interactive diagram: https://gitdiagram.com/iammukeshm/onionarchitecture
- Repository: https://github.com/iammukeshm/onionarchitecture

## Overview

This is an ASP.NET Core product CRUD API organized around Onion Architecture and MediatR. A client reaches the versioned Product API, which dispatches create, read, update, or delete requests to application handlers; handlers use the application database abstraction, implemented by the EF Core context, to access products. The domain defines the product model. Startup configures application and persistence services and documents API versioning and Swagger. The README also advertises inverted dependencies and EF Core. The WeatherForecast endpoint is a separate sample branch. Some wiring is inferred only from the README or source index.

Main entry points: [`WebApi/Controllers/v1/ProductController.cs`](https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/Controllers/v1/ProductController.cs) (Product controller), [`Application/Interfaces/IApplicationDbContext.cs`](https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Interfaces/IApplicationDbContext.cs) (Database abstraction), [`Persistence/Context/ApplicationDbContext.cs`](https://github.com/iammukeshm/onionarchitecture/blob/master/Persistence/Context/ApplicationDbContext.cs) (EF Core context), [`WebApi/Startup.cs`](https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/Startup.cs) (API startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_startup["API startup<br/>[Startup.cs]"]
  node_product_api["Product controller"]
  node_base_controller["API base controller"]
  node_weather["Weather endpoint"]
  node_weather_model["Forecast model<br/>[WeatherForecast.cs]"]
end

subgraph group_application["Application CQRS"]
  node_app_di["Application registration"]
  node_create["Create product"]
  node_read_all["List products"]
  node_read_one["Get product"]
  node_update["Update product"]
  node_delete["Delete product"]
  node_db_interface["Database abstraction"]
end

subgraph group_domain["Product Domain"]
  node_product["Product entity<br/>[Product.cs]"]
  node_base_entity["Base entity<br/>[BaseEntity.cs]"]
end

subgraph group_persistence["Persistence"]
  node_persistence_di["Persistence registration"]
  node_db_context["EF Core context"]
  node_database[("Product database")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_product_api
node_product_api -->|"dispatches create"| node_create
node_product_api -->|"dispatches list"| node_read_all
node_product_api -->|"dispatches lookup"| node_read_one
node_product_api -->|"dispatches update"| node_update
node_product_api -->|"dispatches delete"| node_delete
node_product_api -->|"inherits"| node_base_controller
node_weather -->|"creates"| node_weather_model
node_startup -->|"registers"| node_app_di
node_startup -->|"registers"| node_persistence_di
node_startup -->|"maps controllers"| node_product_api
node_create -->|"writes through"| node_db_interface
node_read_all -->|"reads through"| node_db_interface
node_read_one -->|"reads through"| node_db_interface
node_update -->|"updates through"| node_db_interface
node_delete -->|"uses"| node_db_interface
node_db_context -->|"implements"| node_db_interface
node_db_context -->|"models"| node_product
node_product -->|"inherits"| node_base_entity
node_persistence_di -->|"registers"| node_db_context
node_db_context -.->|"accesses"| node_database

click node_startup "https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/Startup.cs"
click node_product_api "https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/Controllers/v1/ProductController.cs"
click node_base_controller "https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/Controllers/BaseApiController.cs"
click node_weather "https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/Controllers/WeatherForecastController.cs"
click node_weather_model "https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/WeatherForecast.cs"
click node_app_di "https://github.com/iammukeshm/onionarchitecture/blob/master/Application/DependencyInjection.cs"
click node_create "https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Features/ProductFeatures/Commands/CreateProductCommand.cs"
click node_read_all "https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Features/ProductFeatures/Queries/GetAllProductsQuery.cs"
click node_read_one "https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Features/ProductFeatures/Queries/GetProductByIdQuery.cs"
click node_update "https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Features/ProductFeatures/Commands/UpdateProductCommand.cs"
click node_delete "https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Features/ProductFeatures/Commands/DeleteProductByIdCommand.cs"
click node_db_interface "https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Interfaces/IApplicationDbContext.cs"
click node_product "https://github.com/iammukeshm/onionarchitecture/blob/master/Domain/Entities/Product.cs"
click node_base_entity "https://github.com/iammukeshm/onionarchitecture/blob/master/Domain/Common/BaseEntity.cs"
click node_persistence_di "https://github.com/iammukeshm/onionarchitecture/blob/master/Persistence/DependencyInjection.cs"
click node_db_context "https://github.com/iammukeshm/onionarchitecture/blob/master/Persistence/Context/ApplicationDbContext.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_product_api,node_base_controller,node_weather,node_weather_model,node_client toneBlue
class node_app_di,node_create,node_read_all,node_read_one,node_update,node_delete,node_db_interface toneAmber
class node_product,node_base_entity toneMint
class node_persistence_di,node_db_context,node_database toneRose
```

## Components

### HTTP API

- [API startup](https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/Startup.cs): `WebApi/Startup.cs`
- [Product controller](https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/Controllers/v1/ProductController.cs): `WebApi/Controllers/v1/ProductController.cs`
- [API base controller](https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/Controllers/BaseApiController.cs): `WebApi/Controllers/BaseApiController.cs`
- [Weather endpoint](https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/Controllers/WeatherForecastController.cs): `WebApi/Controllers/WeatherForecastController.cs`
- [Forecast model](https://github.com/iammukeshm/onionarchitecture/blob/master/WebApi/WeatherForecast.cs): `WebApi/WeatherForecast.cs`

### Application CQRS

- [Application registration](https://github.com/iammukeshm/onionarchitecture/blob/master/Application/DependencyInjection.cs): `Application/DependencyInjection.cs`
- [Create product](https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Features/ProductFeatures/Commands/CreateProductCommand.cs): `Application/Features/ProductFeatures/Commands/CreateProductCommand.cs`
- [List products](https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Features/ProductFeatures/Queries/GetAllProductsQuery.cs): `Application/Features/ProductFeatures/Queries/GetAllProductsQuery.cs`
- [Get product](https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Features/ProductFeatures/Queries/GetProductByIdQuery.cs): `Application/Features/ProductFeatures/Queries/GetProductByIdQuery.cs`
- [Update product](https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Features/ProductFeatures/Commands/UpdateProductCommand.cs): `Application/Features/ProductFeatures/Commands/UpdateProductCommand.cs`
- [Delete product](https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Features/ProductFeatures/Commands/DeleteProductByIdCommand.cs): `Application/Features/ProductFeatures/Commands/DeleteProductByIdCommand.cs`
- [Database abstraction](https://github.com/iammukeshm/onionarchitecture/blob/master/Application/Interfaces/IApplicationDbContext.cs): `Application/Interfaces/IApplicationDbContext.cs`

### Product Domain

- [Product entity](https://github.com/iammukeshm/onionarchitecture/blob/master/Domain/Entities/Product.cs): `Domain/Entities/Product.cs`
- [Base entity](https://github.com/iammukeshm/onionarchitecture/blob/master/Domain/Common/BaseEntity.cs): `Domain/Common/BaseEntity.cs`

### Persistence

- [Persistence registration](https://github.com/iammukeshm/onionarchitecture/blob/master/Persistence/DependencyInjection.cs): `Persistence/DependencyInjection.cs`
- [EF Core context](https://github.com/iammukeshm/onionarchitecture/blob/master/Persistence/Context/ApplicationDbContext.cs): `Persistence/Context/ApplicationDbContext.cs`
- **Product database**

### Other components

- **API client**

## Connections

- API client → Product controller: sends requests (evidence: `README.md`)
- Product controller → Create product: dispatches create (evidence: `WebApi/Controllers/v1/ProductController.cs`)
- Product controller → List products: dispatches list (evidence: `WebApi/Controllers/v1/ProductController.cs`)
- Product controller → Get product: dispatches lookup (evidence: `WebApi/Controllers/v1/ProductController.cs`)
- Product controller → Update product: dispatches update (evidence: `WebApi/Controllers/v1/ProductController.cs`)
- Product controller → Delete product: dispatches delete (evidence: `WebApi/Controllers/v1/ProductController.cs`)
- Product controller → API base controller: inherits (evidence: `WebApi/Controllers/v1/ProductController.cs`)
- Weather endpoint → Forecast model: creates (evidence: `WebApi/Controllers/WeatherForecastController.cs`)
- API startup → Application registration: registers (evidence: `WebApi/Startup.cs`)
- API startup → Persistence registration: registers (evidence: `WebApi/Startup.cs`)
- API startup → Product controller: maps controllers (evidence: `WebApi/Startup.cs`)
- Create product → Database abstraction: writes through (evidence: `Application/Features/ProductFeatures/Commands/CreateProductCommand.cs`)
- List products → Database abstraction: reads through (evidence: `Application/Features/ProductFeatures/Queries/GetAllProductsQuery.cs`)
- Get product → Database abstraction: reads through (evidence: `Application/Features/ProductFeatures/Queries/GetProductByIdQuery.cs`)
- Update product → Database abstraction: updates through (evidence: `Application/Features/ProductFeatures/Commands/UpdateProductCommand.cs`)
- Delete product → Database abstraction: uses (evidence: `Application/Features/ProductFeatures/Commands/DeleteProductByIdCommand.cs`)
- EF Core context → Database abstraction: implements (evidence: `Persistence/Context/ApplicationDbContext.cs`)
- EF Core context → Product entity: models (evidence: `Persistence/Context/ApplicationDbContext.cs`)
- Product entity → Base entity: inherits (evidence: `Domain/Entities/Product.cs`)
- Persistence registration → EF Core context: registers (evidence: `Persistence/DependencyInjection.cs`)
- EF Core context → Product database: accesses
