How nttung2k3k/diamondluxurywebapp works
Main Components (Containers)
• Presentation Layer:
• The Admin Web Application (DiamondLuxurySolution.AdminCrewApp): An ASP.NET MVC application used by administrators to manage products, orders, customers, etc.
• The Customer Web Application (DiamondLuxurySolution.WebApp): An ASP.NET MVC application for customers to browse, explore product details, and complete purchases.
• API Layer:
• Backend API (DiamondLuxurySolution.BackendApi): An ASP.NET API project that provides data services for the applications. It exposes endpoints used internally and possibly by other systems.
• Business Logic & Data Access:
• Application Layer (DiamondLuxurySolution.Application): Contains business logic and repository implementations to abstract data operations.
• Data Layer (DiamondLuxurySolution.Data): Contains the Entity Framework context, configurations, and entity definitions. This module wires up the database (in this case Azure DB or a local DB via a connection string).
• Cross-cutting / Supporting Libraries:
• Utilities (DiamondLuxurySolution.Utilities): Contains constants, helper methods, and other shared resources.
• View Models (DiamondLuxurySolution.ViewModel): Holds the DTOs and view model classes which structure data communication between layers.
• Background Services:
• BackgroundServiceHost (DiamondLuxurySolution.BackgroundServiceHost): Provides worker services that run automated tasks like price crawling or other scheduled operations.
Relationships and Data Flow
• Both web applications (admin and customer) interact with the API Layer or directly with the Application Layer where business rules and data repository calls are implemented.
• The API layer itself acts as a gateway to the Application and Data layers; it encapsulates the business logic and ensures secure data access.
• The Application Layer abstracts and coordinates repository calls to the Data Layer, which in turn handles database interactions.
• The Background Service runs independently and uses the same Application/Data layers to perform scheduled tasks (like automated price crawling).
• Common cross-cutting utilities (like logging, error handling, or constants) are used across all layers by referencing the Utilities and ViewModel projects.
• External integrations such as Firebase (for image storage and OTP for authentication), VNPay Sandbox, PayPal, and OAuth (Facebook and Google) are connected to the Presentation/Authentication parts of the Admin and Web applications.
Architectural Patterns and Design Principles
• The system follows a layered (or n-tier) architecture with clear separation of concerns (presentation, business, data access, and infrastructure).
• It implements the repository pattern in the Application layer and the use of Dependency Injection (as suggested by the many interface/service implementations) for modularity, testability, and loose coupling.
• The MVC pattern is in use in both the admin and customer web applications (with controllers, views, and models clearly separated).
• The API project follows RESTful principles providing stateless communication to the client side.
• Background processing is separated as a worker service to run asynchronous, scheduled tasks.