Build and maintain a hexagonal architecture microservices insurance platform using C#/.NET 8, PostgreSQL, with PropostaService and ContratacaoService following Clean Architecture principles.
This skill enables you to work with a microservices insurance platform built using C#/.NET 8, PostgreSQL, and Hexagonal (Ports & Adapters) architecture.
The platform consists of two main microservices:
1. **PropostaService**: Manages insurance proposal creation, listing, status changes via REST API
2. **ContratacaoService**: Handles contracting of approved proposals, persists contracts, communicates with PropostaService via HTTP
Each service follows a four-layer hexagonal architecture:
Dependencies flow inward: API → Application → Domain → Infrastructure (Clean Architecture).
1. **Build**: Execute `dotnet build` from solution or service directory
2. **Run a service**: Use `dotnet run --project <Service>.API/<Service>.API.csproj`
3. **Database setup**: PostgreSQL required; connection strings located in each service's `appsettings.json`
4. **Run tests**: Execute `dotnet test` in the `PropostaService.Tests` project (uses repository fakes)
1. **Create migration**:
```bash
dotnet ef migrations add <Name> \
--project <Service>.Infrastructure/<Service>.Infrastructure.csproj \
--startup-project <Service>.API/<Service>.API.csproj \
--context <DbContext>
```
2. **Apply migration**:
```bash
dotnet ef database update \
--project <Service>.Infrastructure/<Service>.Infrastructure.csproj \
--startup-project <Service>.API/<Service>.API.csproj \
--context <DbContext>
```
1. Create request/response DTOs as records in `API/DTOs/` (not inside controllers)
2. Add controller method in appropriate controller (`PropostasController.cs` or `ContratacoesController.cs`)
3. Implement business logic in the Application service layer
4. If data access needed, use repository interfaces from Domain layer
5. Register any new dependencies in `Program.cs`
1. Define a port interface in the Application layer
2. Implement the adapter in Infrastructure layer (e.g., HTTP adapters in `Infrastructure/Adapters`)
3. Register the implementation in dependency injection container in `Program.cs`
4. For inter-service communication, follow the pattern of ContratacaoService calling PropostaService via HTTP adapter
1. Update entity classes in `Domain/Entities/` (e.g., `Proposta.cs`, `Contratacao.cs`)
2. Implement business logic methods directly on entities (e.g., `Aprovar`, `Rejeitar` for status transitions)
3. Update repository interfaces in `Domain/Repositories/` if new data access methods needed
4. Implement repository changes in `Infrastructure/Repositories/`
5. Create and apply database migration
To add a proposal approval workflow:
1. Create `AprovarPropostaRequest` record in `PropostaService.API/DTOs/`
2. Add `Aprovar` method in `PropostasController` that accepts the DTO
3. Implement approval logic in `PropostaService` (Application layer)
4. Call domain method `proposta.Aprovar()` that changes status
5. Persist changes via `IPropostaRepository`
6. Return appropriate DTO response
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/microservices-insurance-platform-cnet/raw