How youmnagbr/e-commerce-asp.net--web-api- works
Main Components
• Domain Layer (Talabat.Core): This module contains the core entities such as BasketItem, CustomerBasket, Department, Employee, and Product-related classes. It also defines repository contracts (like IGenericRepository) and specifications used to drive query logic.
• Business Logic Layer (Talabat.Service): This layer abstracts the business operations and orchestrates calls to the repository.
• Presentation Layer (Talabat): Contains the Controllers (e.g., BasketController, ProductsController, EmployeeController), middleware (like the ExceptionMiddleware), DTOs, mapping profiles, and extensions. This is the Web API that handles HTTP requests from external clients.
• Frontend (Angular): Although not visible in the file tree, the README clearly describes an Angular application running separately. This component will communicate with the Web API for all e-commerce functionality.
• External Services:
• SQL Server: The database is implemented using SQL Server with code-first Entity Framework.
• JWT Authentication: For secure communications, the API uses JWT authentication to protect endpoints.
Relationships and Interactions
• The Angular Frontend interacts with the ASP.NET Web API by making HTTP requests to API endpoints (e.g., for products, basket actions, employee data).
• API Controllers (in the Talabat folder) receive requests from the frontend. They depend on the Business Logic Layer (Talabat.Service) to process the requests.
• The Service layer calls into the Repository layer (Talabat.Repository) which, in turn, uses the Domain Models and Specifications (from Talabat.Core) to query or persist data into the SQL Server database.
• Middleware, such as the ExceptionMiddleware, intercepts requests to handle errors and ensure proper API responses.
• The mapping profile and DTOs facilitate data transformation between the domain entities and the data exposed to the client.
Important Architectural Patterns and Principles
• Onion Architecture: Separates concerns by isolating the domain, application/service, infrastructure, and presentation layers.
• Repository and Unit of Work Patterns: Facilitate data abstraction and ensure cleaner database transaction management.
• Specification Pattern: Used to encapsulate complex query logic, making the repository queries more maintainable.
• JWT Authentication: Enables stateless and secure API requests.
• API Documentation and Middleware: The Swagger services extension aids in API documentation; middleware ensures proper error handling.
Relevant Technologies/Frameworks
• ASP.NET Core Web API (.NET 6) for backend development.
• Entity Framework Core for ORM.
• SQL Server for database.
• Angular for the frontend.
• JWT for authentication.
• Visual Studio for development and Git for version control.
Final Remarks
• Clarity by segmenting related areas together and using annotations that explain how each architectural choice (like the Onion pattern or the specification approach) adds value to the project.