How josueomar320/crud-api works
Main Components
• API Layer: This is represented by the "API" directory which contains the ASP.NET Core controllers (e.g., CategoriesController, ClientController, ProductsController, and WeatherForecastController) and the Program.cs file to configure the application. This layer handles HTTP requests and uses Swagger for endpoint documentation.
• Application Layer: Found in the "Application" directory. It includes the DependencyInjection configuration, interfaces, and services (ClientService, ProductService). This layer encapsulates the business logic and service abstractions.
• DataLayer: Contained in the "DataLayer" directory, it holds the Entity Framework DbContext (AppDbContext), entities (Category, Client, Product, ProductCategory), and migrations. This layer manages the persistence and data access.
Relationships and Interactions
• The API layer receives HTTP requests from clients, which are then passed to the appropriate controllers.
• Controllers invoke methods on the services in the Application layer (which follow defined interfaces) to perform business logic.
• Services in the Application layer access, update, or query the data by interacting with the DataLayer (via the AppDbContext).
• Dependency Injection is used to wire up controllers, services, and the data context seamlessly.
Architectural Patterns and Design Principles
• Layered Architecture: The clear separation between the API (presentation), Application (business logic), and DataLayer (data access).
• Dependency Injection: Used to inject services and the data context, ensuring loose coupling and easier testing.
• Repository/Unit-of-Work-like Pattern: Although not explicitly defined, the DataLayer encapsulates data access logic.
• Service-Oriented Design: The Application layer defines interfaces and service implementations that abstract the underlying data operations.
Relevant Technologies
• ASP.NET Core for the API.
• Entity Framework Core for database operations and migrations.
• Swagger for API documentation.
• C# .NET along with dependency injection containers built into ASP.NET Core.