How alankhanal/asp.net-clean-architecture-basic-crud works
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: ProductService.cs Product service · Program.cs Application host · MappingProfile.cs DTO mapping · ProductRepository.cs Product repository
Components 15
Browser client
- Static client
CleanArchitecture/wwwRoot/Index.js
HTTP API
- Products controller
CleanArchitecture/Controllers/ProductsController.cs - Application host
CleanArchitecture/Program.cs
Application and domain
- Product service
Application/Services/ProductService.cs - Service contract
Application/Interfaces/IProductService.cs - DTO mapping
Application/Mappings/MappingProfile.cs - Create DTO
Application/DTOs/CreateProductDto.cs - Product DTO
Application/DTOs/ProductDto.cs - Update DTO
Application/DTOs/UpdateProductDto.cs - Product entity
Domain/Entities/Product.cs - Repository contract
Domain/Interfaces/IProductRepository.cs
Persistence
- Product repository
Infrastructure/Repositories/ProductRepository.cs - EF database context
Infrastructure/Data/ApplicationDbContext.cs
Other components
- User
- SQL Server
Connections 23
- User → Static client: uses
- Application host → Static client: hosts static files
CleanArchitecture/Program.cs - User → Products controller: sends product requests
CleanArchitecture/Controllers/ProductsController.cs - Products controller → Product service: calls
CleanArchitecture/Controllers/ProductsController.cs - Application host → Product service: registers
CleanArchitecture/Program.cs - Application host → Product repository: registers
CleanArchitecture/Program.cs - Application host → DTO mapping: registers
CleanArchitecture/Program.cs - Application host → EF database context: configures
CleanArchitecture/Program.cs - Application host → SQL Server: configures provider
CleanArchitecture/Program.cs - Products controller → Service contract: depends on
CleanArchitecture/Controllers/ProductsController.cs - Product service → Repository contract: calls
Application/Services/ProductService.cs - Product service → DTO mapping: maps products
Application/Services/ProductService.cs - Product service → Create DTO: accepts
Application/Services/ProductService.cs - Product service → Update DTO: accepts
Application/Services/ProductService.cs - Product service → Product DTO: returns
Application/Services/ProductService.cs - DTO mapping → Product entity: maps
Application/Mappings/MappingProfile.cs - DTO mapping → Create DTO: maps
Application/Mappings/MappingProfile.cs - DTO mapping → Update DTO: maps
Application/Mappings/MappingProfile.cs - DTO mapping → Product DTO: maps
Application/Mappings/MappingProfile.cs - Product repository → EF database context: reads and writes
Infrastructure/Repositories/ProductRepository.cs - Product repository → Product entity: operates on
Infrastructure/Repositories/ProductRepository.cs - EF database context → Product entity: stores set of
Infrastructure/Data/ApplicationDbContext.cs - Product repository → Repository contract: implements
Infrastructure/Repositories/ProductRepository.cs