"Forge" is a backend service built with ASP.NET Core that provides a RESTful API for managing events and their related packages. The project is structured using Clean Architecture, a design philosophy that separates the code into independent layers: Domain, Core (Application), Infrastructure, and Presentation (API). This separation makes the application highly maintainable, testable, and scalable by ensuring that the core business logic is independent of external factors like the database or UI.
The system is designed for a full DevOps lifecycle, with a Continuous Integration and Continuous Deployment (CI/CD) pipeline that automatically builds and deploys the application to Microsoft Azure upon every code change to the main branch.
When a client makes a request to the API, it flows through the application's layers to fetch data and return a response.
-
API Endpoint Hit: A request, such as
GET /Event/{guid}, first reaches the Presentation Layer at theEventController. -
Business Logic Execution: The controller delegates the task to the Core Layer by calling a method on the
IEventService, for instance,GetEventByGuid(guid). -
Data Access Request: The
EventServicethen requests the data from the Infrastructure Layer by calling a method on theIEventRepository, such asGetAsync(e => e.Id == id). -
Database Interaction: The
EventRepository, which inherits from a genericBaseRepository, uses Entity Framework Core to query the database. It translates the domain-level query into a SQL query that the database can understand. -
Data Conversion (Entity → Domain): Once the data is retrieved from the database as an
EventEntity, theEventFactoryin the Infrastructure Layer converts it into aEventdomain model. This ensures the rest of the application is not tightly coupled to the database schema. -
Data Conversion (Domain → DTO): The
Eventdomain model is passed back to theEventServicein the Core Layer. The service then uses theEventDtoFactoryto convert theEventmodel into anEventDisplayDTO (Data Transfer Object). This DTO is a data structure specifically shaped for the API client. -
Response Generation: The
EventControllerreceives theEventDisplayDTO and uses theApiResponseHelperto wrap it in a standardized HTTPIResult(like a 200 OK status with the data as a JSON payload) before sending it back to the client.
Here is the technology stack used in the Forge project:
- Backend Framework: ASP.NET Core. The build workflow specifies .NET 9.x.
- Database ORM: Entity Framework Core is used to map C# objects to the database schema and handle data operations.
- Database: Azure SQL Database, as indicated by the
UseAzureSqlconfiguration. - Cloud Platform & Hosting:
- Azure App Service is the target for deployment, as defined in the GitHub Actions workflow.
- Azure Key Vault is used for secure management of application secrets like connection strings.
- API Documentation:
- Swagger (OpenAPI) for generating interactive API documentation and a UI.
- Scalar for an alternative, clean API reference view.
- DevOps: GitHub Actions for automating the CI/CD pipeline (build, test, and deploy).
- Architecture: Clean Architecture (also known as Onion Architecture).
- Dependency Injection: The framework's built-in DI container is used extensively to manage dependencies between layers.