How drekhai123/fall2024-swd392-se1707-group1 works
Main Components
• Backend (Web API):
• API Controllers (e.g., AccountController, CustomerController, etc.) that expose RESTful endpoints.
• Data Access Layer including Entity Framework’s DbContext (KDOSDbContext.cs) and Migrations.
• Domain Models and DTOs: The “Models” directory contains both domain objects and data transfer objects, segregating data concerns.
• Repositories: Both interface definitions (IAccountRepository, ICustomerRepository, etc.) and their SQL-based implementations that encapsulate data access logic.
• Services: Custom business logic components such as MailingService and VNPay integration, along with helpers for things like AutoMapper configuration.
• Configuration Files and Settings: appsettings.json and launchSettings.json for environment configuration.
• Frontend (React Application):
• Application Structure: A “src” folder with main entry point (index.js, App.js) and routing configuration.
• Components: Separated by roles (admin, customer, deliveryStaff, healthcare, staff) which show different views and functionalities.
• API Integration: Dedicated “api” folder with modules responsible for handling AJAX calls to the backend endpoints.
• UI/UX Elements: Components organized into common, form, and provider sections indicate design elements, utility functions, and state management (i.e., notification providers).
• Assets and Styling: Public assets and CSS files support the user interface.
Analyzing the Interactions
• Frontend ↔ Backend:
• The frontend makes HTTP requests (using APIs defined in the “api” folder) to the backend endpoints exposed by the controllers.
• API wrappers (for authentication, orders, payments, etc.) ensure the UI communicates with the correct backend services.
• Backend Data Flow:
• Controllers receive requests, map input data to DTOs, and then delegate processing to services.
• Services interact with repositories to perform CRUD operations on the database via KDOSDbContext.
• Mapping (via AutoMapperProfile) converts domain entities to DTOs for transmission back to the client.
• External Services:
• VNPay: Integration for payment processing.
• Mailing Services: To handle email notifications (registration, password reset, order invoices, etc.).
Architectural Patterns and Design Principles
• Layered Architecture: The clear separation between Controllers, Services, Repositories, and Data Models demonstrates the layered approach.
• API-First Design: Frontend and backend are decoupled via RESTful APIs.
• Separation of Concerns: Distinct directories for DTOs, domain models, and business logic ensure modularity and testability.
• Configuration Management: Use of environment-specific JSON settings for backend configuration.
To represent the system accurately, include the following elements:
a. A Frontend layer depicting the React application along with routing and UI components (e.g., admin dashboard, customer order pages, etc.).
b. A Backend layer consisting of:
• Controllers that expose API endpoints.
• A Service layer that encapsulates business logic (including VNPay and Mailing Services).
• A Repository layer for data access with interfaces and SQL-based implementations.
• A Database (Entity Framework-managed via migrations) representing persistent data storage.
• Auxiliary components such as AutoMapper for object mapping and configuration files (appsettings).
c. An External Integration section highlight:
• Payment Gateway (VNPay).
• Email/Mailing system.
• HTTP/REST communication from Frontend to Backend.
• Data flow within the backend between Controllers → Services → Repositories → Database.
• Communication with external services.