Appearance
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.ContractsMermaid Dependency Diagram
Dependency Rules
These rules prevent circular dependencies and architectural drift:
| Rule | Rationale |
|---|---|
| Tier N can only depend on Tier N-1 or lower | Prevents circular chains |
Microtec.Domain has zero external package dependencies | Foundation must be stable |
Microtec.Contracts depends only on Domain | Events/DTOs must not pull infrastructure |
| Tier 2 packages do not depend on each other | Keeps infrastructure orthogonal |
Tier 3 (Web.*) is the first to aggregate multiple Tier 2 packages | Web layer is the composition root |
| Feature modules (Tier 4) do not depend on each other | No cross-feature coupling via packages |
Forbidden Dependencies
| From | May NOT depend on |
|---|---|
Microtec.Domain | Any Tier 2/3/4 package |
Microtec.Contracts | Any Tier 2/3/4 package |
Microtec.Persistence | Microtec.Messaging, Microtec.Web.Core |
Microtec.Messaging | Microtec.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 Package | Packages Rebuilt | % of Total |
|---|---|---|
Microtec.Domain | All 16 | 100% |
Microtec.Contracts | 14 (excluding Domain itself) | 87% |
Microtec.Persistence | 3 (Web.Hosting, Import.Infra, Zatca.Infra) | 19% |
Microtec.Messaging | 2 (Web.Core, Web.Hosting) | 12% |
Microtec.Web.Core | 4 (Web.Hosting + all Tier 4) | 31% |
Microtec.Web.Hosting | 0 (leaf node) | 0% |
Microtec.Import.Domain | 2 (Import.Infra, Import.Integration) | 12% |
Microtec.Zatca.Infrastructure | 1 (Zatca.Integration) | 6% |
External Dependencies Summary
Key external NuGet packages used across the platform:
| External Package | Used By |
|---|---|
Microsoft.EntityFrameworkCore (8.x) | Persistence |
MassTransit + MassTransit.AzureServiceBus | Messaging |
StackExchange.Redis | Messaging |
MediatR (12.x) | Web.Core |
FluentValidation.AspNetCore | Web.Core |
Serilog + Serilog.Sinks.Seq | Web.Hosting |
OpenTelemetry.Exporter.OpenTelemetryProtocol | Web.Hosting |
Refit | PublicApi |
ClosedXML | Import.Infrastructure, Reporting |
BouncyCastle.NetCore | Zatca.Infrastructure |
Keycloak.Net (admin client) | Keycloak |