How ardaguness/clean-architecture-webapi works
This is a .NET Web API for account authentication and product/category operations, organized into API, application, domain, and infrastructure layers. The principal workflow begins at an HTTP controller, enters feature handlers for account and category operations, and uses domain services or repositories backed by EF Core and SQLite. Product CRUD, AutoMapper, rate limiting, and Serilog are documented capabilities, but the supplied excerpts do not establish all of their runtime connections. Dashed edges mark undocumented or uncertain links.
Main entry points: ServiceRegistration.cs Infrastructure registration · Context.cs EF Core context · AuthService.cs Authentication service · GenericRepository.cs Generic repository
Components 34
HTTP API
- Account endpoints
WebApi/Controllers/AccountController.cs - Category endpoints
WebApi/Controllers/CategoryController.cs - Product endpoints
WebApi/Controllers/ProductController.cs - Error handling
WebApi/ErrorHandlingMiddleware.cs - API host
WebApi/Program.cs
Application Features
- Account commands
Application/Features/Account/AccountCommands/AccountCommands.cs - Account handlers
Application/Features/Account/AccountCommands/AccountCommandHandlers.cs - Account queries
Application/Features/Account/AccountQueries/AccountQueries.cs - Account responses
Application/Features/Account/AccountQueries/AccountQueriesResponse.cs - Category queries
Application/Features/Category/CategoryQueries/CategoryQueries.cs - Category handlers
Application/Features/Category/CategoryQueries/CategoryQueriesHandlers.cs - Product commands
Application/Features/Product/ProductCommands/AllProductCommands.cs - Product command handlers
Application/Features/Product/ProductCommands/AllProductCommandHandlers.cs - Product queries
Application/Features/Product/ProductQueries/AllProductQueries.cs - Product query handlers
Application/Features/Product/ProductQueries/AllProductQueriesHandlers.cs - Application registration
Application/ServiceRegistration.cs
Domain Model
- Product and category
Domain/Entities/Product.cs - Identity entities
Domain/Entities/Identity/ApplicationUser.cs - Registration model
Domain/Entities/Identity/RegisterUser.cs - Repository contracts
Domain/Interfaces/Generic/IGenericRepository.cs - Product repository contract
Domain/Interfaces/IProductRepository.cs - Category repository contract
Domain/Interfaces/ICategoryRepository.cs - Authentication contract
Domain/Interfaces/IAuthService.cs - User service contract
Domain/Interfaces/IUserService.cs
Infrastructure
- EF Core context
Infrastructure/Contexts/Context.cs - SQLite database
WebApi/Database/webapidatabase.db - Generic repository
Infrastructure/Repositories/Generic/GenericRepository.cs - Product repository
Infrastructure/Repositories/ProductRepository.cs - Category repository
Infrastructure/Repositories/CategoryRepository.cs - Authentication service
Infrastructure/Services/AuthService.cs - User service
Infrastructure/Services/UserService.cs - Infrastructure registration
Infrastructure/ServiceRegistration.cs - Database configuration
Infrastructure/Configuration.cs
Other components
- API client
Connections 44
- API client → Account endpoints: sends requests
- API client → Category endpoints: sends requests
- API client → Product endpoints: sends requests
- Account endpoints → Account commands: references commands
WebApi/Controllers/AccountController.cs - Account endpoints → Account queries: references queries
WebApi/Controllers/AccountController.cs - Category endpoints → Category queries: references queries
WebApi/Controllers/CategoryController.cs - Product endpoints → Product commands: dispatches operations
- Product endpoints → Product queries: dispatches operations
- Account commands → Account handlers: handled by
Application/Features/Account/AccountCommands/AccountCommandHandlers.cs - Account handlers → Authentication contract: calls
Application/Features/Account/AccountCommands/AccountCommandHandlers.cs - Account handlers → Registration model: maps to
Application/Features/Account/AccountCommands/AccountCommandHandlers.cs - Account queries → Account responses: defines responses
Application/Features/Account/AccountQueries/AccountQueriesResponse.cs - Account responses → User service contract: uses
Application/Features/Account/AccountQueries/AccountQueriesResponse.cs - Category queries → Category handlers: handled by
Application/Features/Category/CategoryQueries/CategoryQueriesHandlers.cs - Category handlers → Category repository contract: calls
Application/Features/Category/CategoryQueries/CategoryQueriesHandlers.cs - Category handlers → Product and category: returns category
- Product commands → Product command handlers: handled by
- Product command handlers → Product repository contract: calls
Application/Features/Product/ProductCommands/AllProductCommandHandlers.cs - Product queries → Product query handlers: handled by
- Product query handlers → Product repository contract: calls
Application/Features/Product/ProductQueries/AllProductQueriesHandlers.cs - Product commands → Product and category: operates on
Application/Features/Product/ProductCommands/AllProductCommands.cs - Product queries → Product and category: returns product
Application/Features/Product/ProductQueries/AllProductQueries.cs - Generic repository → Repository contracts: implements
Infrastructure/Repositories/Generic/GenericRepository.cs - Product repository → Generic repository: extends
Infrastructure/Repositories/ProductRepository.cs - Product repository → Product repository contract: implements
Infrastructure/Repositories/ProductRepository.cs - Category repository → Generic repository: extends
Infrastructure/Repositories/CategoryRepository.cs - Category repository → Category repository contract: implements
Infrastructure/Repositories/CategoryRepository.cs - Authentication service → Authentication contract: implements
Infrastructure/Services/AuthService.cs - Authentication service → Identity entities: creates user
Infrastructure/Services/AuthService.cs - Authentication service → Registration model: accepts
Infrastructure/Services/AuthService.cs - EF Core context → Product and category: maps entities
Infrastructure/Contexts/Context.cs - EF Core context → Identity entities: maps identity
Infrastructure/Contexts/Context.cs - Generic repository → EF Core context: reads and writes
- EF Core context → SQLite database: persists data
- Infrastructure registration → Product repository: registers
Infrastructure/ServiceRegistration.cs - Infrastructure registration → Category repository: registers
Infrastructure/ServiceRegistration.cs - Infrastructure registration → Authentication service: registers
Infrastructure/ServiceRegistration.cs - Infrastructure registration → User service: registers
Infrastructure/ServiceRegistration.cs - Infrastructure registration → EF Core context: configures
Infrastructure/ServiceRegistration.cs - Infrastructure registration → Database configuration: uses connection string
Infrastructure/ServiceRegistration.cs - API host → Error handling: configures
WebApi/Program.cs - API host → Database configuration: uses
WebApi/Program.cs - Application registration → Account commands: registers features
Application/ServiceRegistration.cs - Application registration → Category queries: registers features
Application/ServiceRegistration.cs