How david-torosyan/onion-architecture works
MyApp is a .NET user-management REST API organized around onion architecture. The main workflow accepts user creation, credential validation, or active-user listing requests, applies application logic and domain specifications, and persists or reads users through repository and unit-of-work abstractions backed by EF Core. Separate infrastructure capabilities provide logging and email delivery. The README documents broader architectural patterns and technologies; the graph focuses on capabilities evidenced by the tree and sampled source, so uncertain wiring is omitted.
Main entry points: UserService.cs User service · BaseRepositoryAsync.cs EF repository · UserController.cs User endpoints · UnitOfWork.cs Unit of work
Components 22
API presentation
- Web API host
src/MyApp.WebApi/Program.cs - User endpoints
src/MyApp.WebApi/Controllers/UserController.cs
Application services
- User service
src/MyApp.Application/Services/UserService.cs - User service contract
src/MyApp.Application/Interfaces/IUserService.cs - User requests and responses
src/MyApp.Application/Models - User DTO
src/MyApp.Application/Models/DTOs/UserDTO.cs
User domain
- User entity
src/MyApp.Domain/Entities/User.cs - User status
src/MyApp.Domain/Enums/UserStatus.cs - User specifications
src/MyApp.Domain/Specifications/UserSpecifications.cs - User exceptions
src/MyApp.Domain/Exceptions - Repository contract
src/MyApp.Domain/Core/Repositories/IBaseRepositoryAsync.cs - Unit of work contract
src/MyApp.Domain/Core/Repositories/IUnitOfWork.cs - Specification contract
src/MyApp.Domain/Core/Specifications/ISpecification.cs
Infrastructure
- Unit of work
src/MyApp.Infrastructure/Repositories/UnitOfWork.cs - EF repository
src/MyApp.Infrastructure/Repositories/BaseRepositoryAsync.cs - Specification evaluator
src/MyApp.Infrastructure/Repositories/SpecificationEvaluator.cs - EF database context
src/MyApp.Infrastructure/Data/MyAppDbContext.cs - Logger service
src/MyApp.Infrastructure/Services/LoggerService.cs - Email service
src/MyApp.Infrastructure/Services/EmailService.cs
Other components
- API client
- SQL Server database
- SMTP or pickup delivery
Connections 22
- API client → User endpoints: sends requests
- Web API host → User endpoints: maps controllers
- User endpoints → User service contract: calls
- User endpoints → User requests and responses: accepts and returns
- User service contract → User service: implemented by
- User service → Unit of work contract: calls
- User service → User specifications: builds queries
- User service → User entity: creates and reads
- User service → User status: checks status
- User service → User exceptions: throws
- User service → User DTO: maps results
- User service → Logger service: logs events
- Unit of work contract → Unit of work: implemented by
- Unit of work → Repository contract: provides repositories
- Unit of work → EF database context: saves changes
- Repository contract → EF repository: implemented by
- EF repository → Specification evaluator: evaluates specifications
- EF repository → Specification contract: accepts specifications
- EF repository → EF database context: queries and updates
- EF database context → SQL Server database: persists users
- Web API host → SQL Server database: runs migrations
- Email service → SMTP or pickup delivery: sends messages