How greatsluggard/logandstore works
Main Components
• API Layer (LogAndStore.API): Contains the controllers (MyDataController, RequestLogController) that expose endpoints. This layer handles HTTP requests and responses, and integrates Swagger for API documentation.
• Application Layer (LogAndStore.Application): Contains business logic, dependency injection configurations, mapping profiles (using AutoMapper), and service implementations (e.g., MyDataService and RequestLoggerService). This layer orchestrates requests between the API and Data Access layers.
• Data Access Layer (LogAndStore.DAL): Responsible for database connections and operations. It includes the Entity Framework Core context (ApplicationDbContext), migration scripts, repository implementations, and configurations (such as MyDataConfiguration and RequestLogConfiguration).
• Domain Layer (LogAndStore.Domain): Defines the core entities (MyData, RequestLog), Data Transfer Objects (DTOs), and interfaces. This layer encapsulates business models and contracts.
• External Components: PostgreSQL (as the database) deployed via Docker, and Docker infrastructure orchestration via docker-compose. Swagger UI and logging via request logs to the RequestLogs table are also key external/interface elements.
Relationships and Interactions
• The API Layer receives HTTP requests and uses dependency-injected services from the Application Layer.
• The Application Layer uses AutoMapper for DTO to Entity conversions and interacts with the DAL for storage and retrieval.
• The DAL interacts with PostgreSQL via Entity Framework Core for data persistence and applies migrations at startup (managed by MigrationHostedService).
• The Domain Layer provides the essential business objects and interfaces that guide both the Application and DAL layers.
• Docker orchestrates the entire environment, spinning up the Web API application and PostgreSQL container, ensuring they work together.
Architectural Patterns and Design Principles
• Layered Architecture: Clear separation into API, Application, DAL, and Domain layers improves maintainability and testability.
• Dependency Injection: Both the Application and DAL projects provide DI configurations, promoting loose coupling.
• Repository Pattern: Used within the DAL to encapsulate data access logic, interfacing with EF Core.
• AutoMapper Integration: Simplifies object mapping between Entities and DTOs.
• Containerization: Docker and docker-compose are used to containerize the application along with PostgreSQL, ensuring consistency across environments.
• EF Core Migrations: Automatic migrations at startup ensure the database schema is updated as needed.
Relevant Technologies, Frameworks, and Libraries
• ASP.NET Core 8 for building the Web API.
• Entity Framework Core 9 for ORM and migrations.
• PostgreSQL as the primary database.
• Swagger UI for API documentation.
• AutoMapper for object-to-object mapping.
• Docker & docker-compose for containerized deployment.