How cuongtq1210/ocms_be works
Project Type & Purpose
• This is a back-end system meant to handle certification, user management, and related administrative tasks for an online certification platform.
• The README simply identifies it as the “Online Certification Management System – BackEnd,” which confirms its scope mainly consists of business logic, data access, and web API endpoints.
Key Architectural Components
a. Business Objects (OCMS_BOs):
• Contains entity classes (e.g., Candidate, Certificate, Course, User, etc.), data models, and database migrations that define your database schema.
• Includes helper classes for JWT token creation, password hashing, and mapping between models.
• Has dedicated folders for Request and Response models, as well as ViewModels, ensuring a clear separation between data transfer objects (DTOs) and business entities.
b. Repository Layer (OCMS_Repositories):
• Implements generic repositories and specific repository interfaces (e.g., ICandidateRepository, ICourseRepository) to abstract database access.
• Uses a UnitOfWork pattern (UnitOfWork.cs) to coordinate and commit repository changes.
• This layer is responsible for all data interactions, providing a decoupled mechanism for CRUD operations.
c. Service Layer (OCMS_Services):
• Contains service interfaces and their concrete implementations (e.g., IAuthenticationService, IEmailService) that encapsulate business logic.
• This layer consumes the repository layer to process data and applies various business rules before handing data off to the API layer.
• Implements important services like authentication, blob handling, and email notifications.
d. Presentation/API Layer (OCMS_WebAPI):
• Contains controllers (e.g., CandidateController, CertificateTemplateController, etc.) that expose RESTful endpoints.
• Integrates authorization through custom attributes (see the AuthorizeSettings folder) and settings defined in appsettings.json.
• Includes the Program.cs and Docker-related files (Dockerfile, .dockerignore) for application startup and deployment.
Relationships and Interactions
• Front Door: API Controllers act as the gateway, receiving HTTP requests and orchestrating service operations.
• The Service Layer sits between the controllers and the repository layer. Controllers call service methods, which in turn use the repositories to interact with the database.
• The Repository Layer abstracts direct database operations; repositories execute CRUD operations leveraging the migrations and Entity Framework context (OCMSDbContext.cs in OCMS_BOs).
• Business Objects and DTOs facilitate data exchange across layers, ensuring data integrity and clean mapping between external requests/responses and internal structures.
Architectural Patterns & Design Principles
• Layered Architecture: Clearly separates concerns into Business (BOs), Data Access (Repositories), Business Logic (Services), and Presentation (WebAPI Controllers).
• Unit of Work: Coordinating various repository transactions to ensure atomic operations.
• Dependency Injection: Likely used to inject repositories into services and services into controllers.
• RESTful API Design: Controllers expose endpoints in a standard RESTful manner.
• Security: JWT token handling for authentication and custom authorization attributes safeguard endpoints.
Relevant Technologies, Frameworks, & Deployment
• ASP.NET Core for building and hosting the WebAPI.
• Entity Framework for managing migrations and database interactions.
• Docker for containerizing the application (as evident from the Dockerfile and .dockerignore).
• GitHub Actions for CI/CD (see the .github/workflows folder).
• Service Layer (with various services like CandidateService, CertificateTemplateService, etc.).
• Business Logic (through entities and DTOs that enforce state and transformations).
• Next, connect the Service Layer to the Repository Layer that abstracts data operations.
• Finally, illustrate the database (or data store) that the repository operations interact with.
• Side components like authentication utilities (JWT token helper) and background tasks (EmailService, BlobService).