How phuocleoceo/plc-base-asp works
Main Components
• Client/External Requestor – Represents API consumers (e.g., web/mobile clients) that send HTTP requests.
• Nginx Reverse Proxy – The configuration in the “.nginx” directory and the presence of a Dockerfile and docker-compose.yml suggest that Nginx is used for request routing.
• ASP.NET Core Application – This is the core – it is organized into:
– Base Layer (src/Base): contains common controllers, DTOs, error handling, filtering, and repositories.
– Features (src/Features): multiple feature modules such as Auth, AccessControl, Address, Event, Issue, Project, Payment, etc. Each represents a domain module with its own set of Controllers, DTOs, Entities, Repositories, and Services.
– Common & Shared Libraries (src/Common and src/Shared): these include EF Core DataContext, configurations, migrations, mapping utilities, logging, helpers (like JWT, Redis, AWS S3, etc.), and extensions to build the pipelines and service collections.
• Data Layer:
– EF Core DataContext (inside src/Common/Data): Manage database connections and migrations.
– Database (SQL Server or another relational DB – typically external or containerized as part of docker-compose).
• External Services/Infrastructures:
– Certificate handling module from src/Certificate.
– AWS S3, Redis, and other external integrations found in src/Shared/Helpers.
– Message queue/service bus (if applicable, as referenced by MessageQueueExtension in service collections).
Component Relationships and Data Flow
• Requests from the Client (browser/mobile) first hit the Nginx reverse proxy.
• Nginx forwards requests to the ASP.NET Core container hosting the API.
• Incoming requests travel through middleware (ErrorHandler, JWT authentication, SuccessHandler, etc.) that are defined in src/Middlewares and further configured by the pipeline extensions (found in src/Extensions/Pipelines).
• Requests are then routed by the proper controller within the appropriate Feature module.
• Each controller calls its corresponding service, which then uses repositories to perform CRUD operations via the EF Core DataContext.
• Data flows from the Data Layer (database) back through the repository to the service and finally out through the controller’s response.
• External services (e.g., sending mail, generating JWT tokens, or interacting with AWS S3) are invoked from the shared helpers or service extensions.
Architectural Patterns and Design Principles
• Modular Feature-based Architecture – Each domain concern (Auth, Address, Issue, etc.) is isolated in its own folder.
• Repository & Unit of Work Patterns – Abstract data access logic.
• Dependency Injection – Utilized in the service collections and pipeline configurations (see src/Extensions/ServiceCollections).
• Middleware Pipeline – Custom middleware for error handling, authentication, health checks, and swagger are configured.
• Dockerized Production Environment – The Dockerfile, docker-compose, and Nginx configuration illustrate containerization and effective request routing.
• EF Core Code-First Approach and Migrations – Database schema evolution is managed via EF Core migrations (src/Common/Data/Migrations).
Technologies & Frameworks
• ASP.NET Core (.NET 5/6/7 – based on your solution file and project files)
• EF Core (for ORM and migrations)
• Docker & Docker Compose (for containerization and environment setup)
• Nginx (as reverse proxy)
• Cshapier (for formatting) and Husky (for Git hooks)
• External libraries/plugins for JWT, AWS (S3, etc.), Redis, and external mail services
What
• Clear and descriptive labels for every component.
• Client → Nginx → ASP.NET Core (middleware) → Controllers → Services → Repositories → DataContext → Database.
• Annotations to note key technologies (e.g., “EF Core Code-First”, “Middleware Pipelines”, “Dependency Injection”) alongside each component.