Skip to content

Package Dependency Hierarchy

Section: 16 — Packages
Last Updated: 2026-05-30
Scope: 4-tier dependency graph, ASCII tree, Mermaid diagram, rules


The 4-Tier Model

┌─────────────────────────────────────────────────────────────┐
│  TIER 4 — Feature Modules                                   │
│  Import.Domain → Import.Infrastructure → Import.Integration │
│  Zatca.Infrastructure → Zatca.Integration                   │
└─────────────────────────────┬───────────────────────────────┘
                              │ depends on
┌─────────────────────────────▼───────────────────────────────┐
│  TIER 3 — Web Layer                                         │
│  Web.Core ←── Web.Hosting                                   │
└─────────────────────────────┬───────────────────────────────┘
                              │ depends on
┌─────────────────────────────▼───────────────────────────────┐
│  TIER 2 — Infrastructure                                    │
│  Persistence │ Messaging │ Keycloak │ PublicApi             │
│  Reporting   │ Attachment.Client │ Notifications.Client     │
└─────────────────────────────┬───────────────────────────────┘
                              │ depends on
┌─────────────────────────────▼───────────────────────────────┐
│  TIER 1 — Foundation (zero external deps)                   │
│  Domain ←── Contracts                                       │
└─────────────────────────────────────────────────────────────┘

Full ASCII Dependency Tree

Microtec.Domain (Tier 1)

├── Microtec.Contracts (Tier 1)
│   └── (depends on Domain only)

├── Microtec.Persistence (Tier 2)
│   ├── → Microtec.Domain
│   └── → EF Core 8 (external)

├── Microtec.Messaging (Tier 2)
│   ├── → Microtec.Domain
│   ├── → Microtec.Contracts
│   ├── → MassTransit.AzureServiceBus (external)
│   └── → StackExchange.Redis (external)

├── Microtec.Keycloak (Tier 2)
│   ├── → Microtec.Domain
│   └── → Keycloak.Net (external)

├── Microtec.PublicApi (Tier 2)
│   ├── → Microtec.Contracts
│   └── → Refit (external)

├── Microtec.Reporting (Tier 2)
│   ├── → Microtec.Domain
│   └── → NPOI / ClosedXML (external)

├── Microtec.Attachment.Client (Tier 2)
│   └── → Microtec.Contracts

├── Microtec.Notifications.Client (Tier 2)
│   └── → Microtec.Contracts

├── Microtec.Web.Core (Tier 3)
│   ├── → Microtec.Domain
│   ├── → Microtec.Contracts
│   ├── → Microtec.Messaging
│   ├── → Microtec.Keycloak
│   ├── → MediatR (external)
│   ├── → FluentValidation (external)
│   └── → Microsoft.AspNetCore.* (external)

├── Microtec.Web.Hosting (Tier 3)
│   ├── → Microtec.Web.Core
│   ├── → Microtec.Messaging
│   ├── → Microtec.Persistence
│   ├── → OpenTelemetry.* (external)
│   └── → Serilog.* (external)

├── Microtec.Import.Domain (Tier 4)
│   └── → Microtec.Domain

├── Microtec.Import.Infrastructure (Tier 4)
│   ├── → Microtec.Import.Domain
│   ├── → Microtec.Persistence
│   ├── → Microtec.Web.Core
│   └── → ClosedXML (external)

├── Microtec.Import.Integration (Tier 4)
│   ├── → Microtec.Import.Domain
│   └── → Microtec.Contracts

├── Microtec.Zatca.Infrastructure (Tier 4)
│   ├── → Microtec.Domain
│   ├── → Microtec.Persistence
│   ├── → Microtec.Web.Core
│   └── → BouncyCastle (external)

└── Microtec.Zatca.Integration (Tier 4)
    ├── → Microtec.Zatca.Infrastructure
    └── → Microtec.Contracts

Mermaid Dependency Diagram


Dependency Rules

These rules prevent circular dependencies and architectural drift:

RuleRationale
Tier N can only depend on Tier N-1 or lowerPrevents circular chains
Microtec.Domain has zero external package dependenciesFoundation must be stable
Microtec.Contracts depends only on DomainEvents/DTOs must not pull infrastructure
Tier 2 packages do not depend on each otherKeeps infrastructure orthogonal
Tier 3 (Web.*) is the first to aggregate multiple Tier 2 packagesWeb layer is the composition root
Feature modules (Tier 4) do not depend on each otherNo cross-feature coupling via packages

Forbidden Dependencies

FromMay NOT depend on
Microtec.DomainAny Tier 2/3/4 package
Microtec.ContractsAny Tier 2/3/4 package
Microtec.PersistenceMicrotec.Messaging, Microtec.Web.Core
Microtec.MessagingMicrotec.Persistence, Microtec.Web.Core
Microtec.Import.*Microtec.Zatca.* and vice versa

WARNING

Adding a forbidden dependency will cause the smart pipeline to refuse the build. Any new package dependency requires an architectural review.


Rebuild Impact Matrix

When a package changes, all packages in its transitive dependent tree must be rebuilt:

Changed PackagePackages Rebuilt% of Total
Microtec.DomainAll 16100%
Microtec.Contracts14 (excluding Domain itself)87%
Microtec.Persistence3 (Web.Hosting, Import.Infra, Zatca.Infra)19%
Microtec.Messaging2 (Web.Core, Web.Hosting)12%
Microtec.Web.Core4 (Web.Hosting + all Tier 4)31%
Microtec.Web.Hosting0 (leaf node)0%
Microtec.Import.Domain2 (Import.Infra, Import.Integration)12%
Microtec.Zatca.Infrastructure1 (Zatca.Integration)6%

External Dependencies Summary

Key external NuGet packages used across the platform:

External PackageUsed By
Microsoft.EntityFrameworkCore (8.x)Persistence
MassTransit + MassTransit.AzureServiceBusMessaging
StackExchange.RedisMessaging
MediatR (12.x)Web.Core
FluentValidation.AspNetCoreWeb.Core
Serilog + Serilog.Sinks.SeqWeb.Hosting
OpenTelemetry.Exporter.OpenTelemetryProtocolWeb.Hosting
RefitPublicApi
ClosedXMLImport.Infrastructure, Reporting
BouncyCastle.NetCoreZatca.Infrastructure
Keycloak.Net (admin client)Keycloak

Internal Documentation — Microtec Platform Team