Skip to content

C4 — Component View

The component view (C4 Level 3) zooms into a single microservice. Every factory and generated service shares the same Clean Architecture component structure, inherited from the ConnectSoft.MicroserviceTemplate. We use the Knowledge Platform ContextBuilderService as the representative example.

flowchart TB
    subgraph api [Api Layer]
        rest["REST Controllers"]
        grpc["gRPC Endpoints"]
        consumers["MassTransit Consumers"]
    end
    subgraph app [Application Layer]
        handlers["Command / Query Handlers"]
        usecases["Use Cases"]
        ports["Ports (interfaces)"]
    end
    subgraph domain [Domain Model]
        aggregates["Aggregates<br/>(ContextPackage, ContextBuildRequest)"]
        events["Domain Events"]
        vos["Value Objects"]
    end
    subgraph infra [Infrastructure]
        repo["NHibernate Repositories"]
        vector["Qdrant Adapter"]
        graph["Graph Adapter"]
        flow["MassTransit Publisher"]
    end

    rest --> handlers
    grpc --> handlers
    consumers --> handlers
    handlers --> usecases
    usecases --> aggregates
    usecases --> ports
    ports --> repo
    ports --> vector
    ports --> graph
    aggregates --> events
    events --> flow
Hold "Alt" / "Option" to enable pan & zoom

Layers and dependency rule

Layer Project (per naming) Depends on
Api ...{Service}.Api Application, ApplicationModel
Application ...{Service}.Application DomainModel, ApplicationModel (ports only)
Application Model ...{Service}.ApplicationModel — (DTOs/contracts)
Domain Model ...{Service}.DomainModel — (pure domain)
Persistence ...{Service}.PersistenceModel.NHibernate DomainModel (implements ports)
Flow (messaging) ...{Service}.FlowModel.MassTransit DomainModel, ApplicationModel
Migrations ...{Service}.DatabaseModel.Migrations
Options ...{Service}.Options

Dependencies point inward: the domain model has no outward dependencies; infrastructure implements ports defined by the application layer. This is the same structure for factory platform services and for the services the factory generates, ensuring uniformity and reuse.

Cross-cutting components

Every service composes the shared ConnectSoft.Extensions.* libraries for observability (Observability, Telemetry, Logging.Serilog), validation (Validation.FluentValidation), mapping (ObjectMapping.*), persistence (PersistenceModel.*), messaging (MessagingModel.MassTransit), and SaaS multi-tenancy (Saas.*).