How rymucong/onlinepollapp works
Main Components
• Presentation Layer: Represented by the Web API project (Presentations/T3H.Poll.WebApi). Its controllers, configuration options, models, and program startup code provide the interface (Swagger endpoints and API debugging) for client interactions.
• Application Layer: Implemented in the Core directory (Core/T3H.Poll.Application). It contains Commands, Queries, DTOs, Dispatchers, and Services (such as CrudService, UserService, etc.) that implement the application’s business logic. This layer uses patterns like CQRS (commands and queries) and the Mediator pattern through handlers.
• Domain Layer: Found in Core/T3H.Poll.Domain. It houses domain entities (like Poll, User, Roles, etc.), domain events, and constants. This area encapsulates the core business rules, invariants, and specifications.
• Infrastructure Layer: This layer is diverse. It includes:
• Persistence: Under Infrastructure/T3H.Poll.Persistence, with database context (CrmDbContext), repositories (for users, roles, and common settings), mapping configurations, and locking mechanisms (distributed locks).
• Identity: Infrastructure/T3H.Poll.Infrastructure/Identity which includes stores, password validation, and token providers.
• Interceptors, Logging, Swagger, HealthChecks, and additional cross-cutting functions are also part of Infrastructure.
• Additionally, the Infrastructure/libs directory includes external libraries used by the project.
• Cross-Cutting Concerns: Organized under CrossCuttingConcerns, providing Circuit Breaker implementations, exception handling, date/time providers, extension methods, and locking utilities.
• Data and Migration: The Data folder (simple JSON files like banks.json) and Presentations/T3H.Poll.Migration supply migration scripts and database initialization (seeding) required to set up the database.
Architectural Patterns and Notable Components
• CQRS Pattern: Emphasize how commands (like AddUpdatePollCommand, DeleteUserCommand) and queries (GetUserQuery, BaseSearchQuery) are dispatched through central dispatchers and handled by specific command/query handlers.
• Domain-Driven Design Elements: Separate Domain Entities and value objects encapsulate business rules; domain events (like EntityCreatedEvent) propagate state changes.
• Repository and Unit of Work Patterns: Illustrate how repository interfaces (IUserRepository, IRoleRepository) and the Unit of Work (IUnitOfWork) in the Persistence layer abstract database operations.
• Cross-Cutting Concerns: Incorporate shared components such as CircuitBreaker, Exception Handling, Logging (using interceptors, ActivityEnricher), and Notifications.