/competex-backend
- /API
- Controllers
- MembersController.cs
- DTOs
- MemberDTO.cs
- /BLL
- Interfaces
- IMemberService.cs
- Services
- MemberService.cs
- /DAL
- Repositories
- MemberRepository.cs
- /Models
- Member.cs
In this directory we store all that is relevant to communication to and from the api.
We store the api controllers in this folder. Each api controller has CRUD functionality.
When we communicate via the api, the api controllers use contract based-models in form of Data Transfer Objects (DTOs)
The Business Logic Layer is responsible for all the domain specific logic.
Here we can perform various calculations and other stuff specific to the domain. Controllers also communicate with the DAL layer through the services in the BLL. The service layer utilizes a nuget package called "AutoMapper". It requires a MappingProfile (Inherits from 'Profile'), but when configured, the mapping to and from DTOs and models, is as done in the following way.
_mapper.Map<MemberDTO>(member)
Where MemberDTO is the destination type and member is the source object (consisting of a type)
The data access layer handles communication with external data providers such as SQL databases. We have chosen to implement Postgres as the database.
We define interfaces such that the database can be changed without much hassle. A database specific implementation is required, to add a database. This must inherit the IRepository, i.e. IMemberRepository in postgres would look like
PostgresMemberRepository : IMemberRepository
The repositories is specific queries for entities, such as MemberRepository - which contains the queries related to the Member entity.
Use your models(e.g., Member) to represent the domain entities of your application.
You must push to develop.
When doing so, the following action will run.
.github/workflows/dotnet-build-and-run-tests.yml
It build the .net solution and runs the tests located in: ´./competex-backend-tests´
the main
branch is branc-protected. Only pull requests from the develop
branch is allowed.
When performing a pull request to main, the following action, which check the upstream branch runs:
.github/workflows/main-pull-request-protection.yml
- Layered Architecture: Separates the application into distinct layers (API, BLL, DAL, Models).
- Repository Pattern: Encapsulates data access logic within repositories.
- Dependency Injection: Promotes loose coupling and facilitates testing.
- Data Transfer Object (DTO) Pattern: Simplifies data transfer between layers.
- Interface Segregation Principle: Defines clear contracts for services.
- MVC Pattern: Handles the separation of concerns within the API.