Skip to content

Adapter Implementation Results

var builder = WebApplication.CreateBuilder(args);
builder.Services
.RegisterAdapterPresentation()
.RegisterAdapterPersistence(builder.Configuration)
.RegisterAdapterInfrastructure(builder.Configuration);
var app = builder.Build();
app.UseAdapterPresentation();
app.Run();

Three Adapter registration methods are composed via Builder chaining. Each Adapter is registered independently and is replaceable.

AiGovernance (Host)
├── AiGovernance.Adapters.Presentation → Application
├── AiGovernance.Adapters.Persistence → Application, Domain
└── AiGovernance.Adapters.Infrastructure → Application, Domain
AiGovernance.Application → Domain
AiGovernance.Domain → Functorium (Framework)

Provides HTTP API based on FastEndpoints.

AreaEndpointHTTP MethodRoute Pattern
ModelRegisterModelEndpointPOST/api/models
ModelGetModelByIdEndpointGET/api/models/{id}
ModelSearchModelsEndpointGET/api/models
ModelClassifyModelRiskEndpointPUT/api/models/{id}/risk
DeploymentCreateDeploymentEndpointPOST/api/deployments
DeploymentGetDeploymentByIdEndpointGET/api/deployments/{id}
DeploymentSearchDeploymentsEndpointGET/api/deployments
DeploymentSubmitForReviewEndpointPOST/api/deployments/{id}/submit
DeploymentActivateDeploymentEndpointPOST/api/deployments/{id}/activate
DeploymentQuarantineDeploymentEndpointPOST/api/deployments/{id}/quarantine
AssessmentInitiateAssessmentEndpointPOST/api/assessments
AssessmentGetAssessmentByIdEndpointGET/api/assessments/{id}
IncidentReportIncidentEndpointPOST/api/incidents
IncidentGetIncidentByIdEndpointGET/api/incidents/{id}
IncidentSearchIncidentsEndpointGET/api/incidents

Total: 15 endpoints (Model 4, Deployment 6, Assessment 2, Incident 3)

Provides Repository and Query implementations via InMemory.

ImplementationPortObservable Wrapper
AIModelRepositoryInMemoryIAIModelRepositoryAIModelRepositoryInMemoryObservable
DeploymentRepositoryInMemoryIDeploymentRepositoryDeploymentRepositoryInMemoryObservable
AssessmentRepositoryInMemoryIAssessmentRepositoryAssessmentRepositoryInMemoryObservable
IncidentRepositoryInMemoryIIncidentRepositoryIncidentRepositoryInMemoryObservable
UnitOfWorkInMemoryIUnitOfWorkUnitOfWorkInMemoryObservable
AIModelQueryInMemoryIAIModelQueryAIModelQueryInMemoryObservable
ModelDetailQueryInMemoryIModelDetailQueryModelDetailQueryInMemoryObservable
DeploymentQueryInMemoryIDeploymentQueryDeploymentQueryInMemoryObservable
DeploymentDetailQueryInMemoryIDeploymentDetailQueryDeploymentDetailQueryInMemoryObservable
IncidentQueryInMemoryIIncidentQueryIncidentQueryInMemoryObservable

Total: 10 implementations (Repository 4, UnitOfWork 1, Query 5)

Supports switching to Sqlite (EF Core) implementation via PersistenceOptions.Provider branching.

ImplementationPortObservable Wrapper
AIModelRepositoryEfCoreIAIModelRepositoryAIModelRepositoryEfCoreObservable
DeploymentRepositoryEfCoreIDeploymentRepositoryDeploymentRepositoryEfCoreObservable
AssessmentRepositoryEfCoreIAssessmentRepositoryAssessmentRepositoryEfCoreObservable
IncidentRepositoryEfCoreIIncidentRepositoryIncidentRepositoryEfCoreObservable
UnitOfWorkEfCoreIUnitOfWorkUnitOfWorkEfCoreObservable

EF Core total: 5 implementations (Repository 4, UnitOfWork 1)

In the EF Core implementation, Queries reuse InMemory queries (replaceable with Dapper queries in the future).

Provides external services (IO advanced features) and pipelines.

ImplementationPortIO Pattern
ModelHealthCheckServiceIModelHealthCheckServiceTimeout(10s) + Catch
ModelMonitoringServiceIModelMonitoringServiceRetry(exponential, 3 times) + Catch
ParallelComplianceCheckServiceIParallelComplianceCheckServiceFork + awaitAll
ModelRegistryServiceIModelRegistryServiceBracket(Acquire/Use/Release)

Total: 4 external services

Registration items:

  • Mediator + ObservableDomainEventNotificationPublisher
  • FluentValidation (2 assemblies)
  • OpenTelemetry 3-Pillar
  • Pipeline (UseObservability + UseValidation + UseException + Custom)
  • Domain Services (RiskClassificationService, DeploymentEligibilityService)
CategoryTest File CountTest Target
Value Objects15Creation, validation, Smart Enum transitions for 16 VOs
Aggregates4AIModel, ModelDeployment, ComplianceAssessment, ModelIncident
Domain Services1RiskClassificationService
Architecture3Domain/application architecture rules, layer dependencies
Total23

Integration tests (AiGovernance.Tests.Integration)

Section titled “Integration tests (AiGovernance.Tests.Integration)”
CategoryTest File CountTest Target
Models3Register, GetById, Search endpoints
Deployments2Create, Workflow (full lifecycle) endpoints
Assessments1Initiate endpoint
Incidents1Report endpoint
Total7

Total test files: 30 (268 tests across 2 assemblies for the entire solution)

samples/ai-model-governance/
├── ai-model-governance.slnx
├── Directory.Build.props
├── Directory.Build.targets
├── domain/ # Domain layer docs (4)
├── application/ # Application layer docs (4)
├── adapter/ # Adapter layer docs (4)
├── Src/
│ ├── AiGovernance.Domain/ # Domain layer
│ │ ├── SharedModels/Services/ # Domain Services (2 types)
│ │ └── AggregateRoots/ # Aggregates (4 types)
│ │ ├── Models/ # AIModel + VOs(4) + Specs(2)
│ │ ├── Deployments/ # ModelDeployment + VOs(4) + Specs(3)
│ │ ├── Assessments/ # ComplianceAssessment + Child Entity + VOs(3) + Specs(3)
│ │ └── Incidents/ # ModelIncident + VOs(4) + Specs(4)
│ ├── AiGovernance.Application/ # Application layer
│ │ └── Usecases/ # Commands(8) + Queries(7) + EventHandlers(2) + Ports(9)
│ ├── AiGovernance.Adapters.Persistence/ # Persistence adapter
│ │ ├── Repositories/ # Per-Aggregate Repository/Query implementations (10 types)
│ │ └── Registrations/
│ ├── AiGovernance.Adapters.Infrastructure/ # Infrastructure adapter
│ │ ├── ExternalServices/ # IO advanced features (4 types)
│ │ └── Registrations/
│ ├── AiGovernance.Adapters.Presentation/ # Presentation adapter
│ │ ├── Endpoints/ # FastEndpoints (15 types)
│ │ └── Registrations/
│ └── AiGovernance/ # Host
│ └── Program.cs
└── Tests/
├── AiGovernance.Tests.Unit/ # Unit tests (23 files)
└── AiGovernance.Tests.Integration/ # Integration tests (7 files)
ItemCount
Aggregate Root4
Child Entity1
Value Object16 (String 6, Comparable 2, Smart Enum 8)
Domain Service2
Specification12
Domain Event18
Command8
Query7
Event Handler2
Repository (Port)4
Query Port5
External Service Port4
HTTP Endpoint15
InMemory Implementation10
Advanced IO Pattern4 (Timeout, Retry, Fork, Bracket)
Observable Port19 (InMemory 5, EfCore 5, Query 5, ExternalService 4)
Unit test files23
Integration test files7
Total test files30
Total tests268