How phuhoang07/swd_group05_be works
Main Components
• Presentation Layer:
• The “GoodsExchangeAtFUManagement” project contains Controllers (e.g., AuthenticationController, CampusController, etc.) that expose Web API endpoints.
• A ChatHub for real-time communications hints at SignalR usage.
• Middlewares (AuthorizeMiddleware, GlobalExceptionMiddleware) that handle security and error handling.
• Service Layer:
• The “GoodsExchangeAtFUManagement.Service” project includes many domain-specific services (AuthenticationService, CampusService, CategoryService, CoinPackService, etc.) that encapsulate business logic.
• Utility classes (JwtGenerator, PasswordHasher, CustomException, etc.) support cross-cutting concerns.
• Repository/Data Access Layer:
• The “GoodsExchangeAtFUManagement.Repository” implements repository patterns for each domain (e.g., ICampusRepository, ICategoryRepository) with direct mappings in the “GoodsExchangeAtFUManagement.DAO”.
• The “GoodsExchangeAtFUManagement.DAO” includes the DB context (GoodsExchangeAtFuContext) and generic data access methods.
• Business Objects/Domain Models:
• The “BusinessObjects” folder contains DTOs, models, enums, and custom data annotations that define the domain structure and data transfer contracts across layers.
• Database:
• The SQL script file (ScriptDB_v1.0.sql) suggests an underlying database where the entities are stored.
Relationships and Data Flow
• UI/API (Controllers) makes calls to Services.
• Services handle business logic then interact with the Repository layer using the repository interfaces.
• The Repository accesses the database via the Data Access (DAO) layer.
• Communication between layers is facilitated using DTOs defined in the BusinessObjects.
• The SignalR Hub (ChatHub) in the presentation layer is used for facilitating real-time client-server communication.
• Utility classes (found in the “Ultis” folder) are leveraged across layers for tasks like JWT token generation, password hashing, and email handling.
• External interactions include payment integrations via VnPay and email functionality.
Architectural Patterns and Design Principles
• Layered (n-tier) Architecture separating presentation, service, repository, and data access.
• Repository Pattern to abstract and encapsulate data access logic.
• Dependency Injection is likely used, as indicated by the use of interfaces (e.g., IUserService, ICategoryRepository).
• Use of DTOs and custom annotations to clearly define contracts and validation.
• SignalR integration provides a dedicated component for handling real-time communications.
Essential Architectural Elements
• Clearly delineate the flow from the front-end (API controllers and SignalR hubs) through the service layer to the repository/DAO and finally to the database.
• Cross-layer utilities (JWT generation, email handling) separately to show how they support the main workflow.
• Use of interfaces and dependency injection by noting the “IService” and “IRepository” naming conventions.