Skip to content

Architecture Overview

This section documents the core architectural decisions and patterns that shape the Microtec ERP platform. The architecture is designed for cloud-native multi-tenancy, developer velocity, and operational independence between services.


Four Architectural Pillars

PillarPatternTechnologyDetails
Separation of ConcernsClean Architecture.NET 8Four strict layers per service; no cross-layer shortcuts
Command/Query SeparationCQRSMediatRRead and write models are independent
Tenant IsolationDatabase-per-TenantEF Core + SQL ServerComplete data isolation per customer
Async DecouplingEvent-DrivenMassTransit + Azure Service BusServices communicate via messages, not direct calls

C4 Level-1: Platform Architecture


Container Apps Environment Split

Public vs Private CAE

The two-CAE model is a deliberate security boundary. The public CAE has an internet-facing IP and handles only two workloads: the API Gateway (Ocelot/YARP) and Keycloak. All business microservices live in the private CAE with no public IP — they are reachable only through the gateway.


Architectural Layers per Service

Each of the 13 backend microservices follows the same four-layer Clean Architecture structure:

{ServiceName}/
├── {ServiceName}.Apis/            # Presentation: REST controllers, Swagger, middleware
├── {ServiceName}.Application/     # Application: CQRS handlers, validators, DTOs
├── {ServiceName}.Domain/          # Domain: Entities, value objects, domain events
└── {ServiceName}.Infrastructure/  # Infrastructure: EF Core, repos, external services

Dependency Rule

Dependencies only point inward. Infrastructure depends on Application; Application depends on Domain. The Domain layer has zero external dependencies.


Key Architectural Decisions

The following Architecture Decision Records capture the most significant choices made during platform design. Refer to the linked ADRs for full context, alternatives considered, and consequences.

ADRDecisionStatus
ADR-001Adopt microservices architectureAccepted
ADR-002Use Azure Container Apps over AKSAccepted
ADR-003Webpack Module Federation for MFEAccepted
ADR-004Self-hosted Keycloak for SSOAccepted
ADR-005Migrate from RabbitMQ to Azure Service BusAccepted
ADR-006Clean Architecture with CQRS/MediatRAccepted
ADR-007Centralized DevSecOps pipeline templatesAccepted
ADR-008Database-per-tenant multi-tenancyAccepted
ADR-009Shared code as private NuGet packagesAccepted

Architecture Deep Dives

TopicPageAudience
Clean Architecture + CQRSclean-architecture.mdBE-DEV, ARCH
Multi-Tenancy Strategymulti-tenancy.mdBE-DEV, ARCH, SRE
Service Communicationservice-communication.mdBE-DEV, DEVOPS, SRE
Event-Driven Designevent-driven.mdBE-DEV, ARCH
Micro-Frontend Architecturemicro-frontend.mdFE-DEV, ARCH

Non-Functional Requirements

ConcernApproach
ScalabilityKEDA autoscaling on Container Apps (min/max replicas per service in services-config.json)
AvailabilityMultiple replicas in prod; AFD health probes; CAE restart policies
SecuritymTLS in private CAE; WAF on AFD; Keycloak OIDC; Key Vault for all secrets
ObservabilityOpenTelemetry traces + Serilog structured logs → Seq + Application Insights
ResiliencePolly retry/circuit-breaker on HTTP clients; MassTransit dead-letter queues
PortabilityDocker containers; Bicep IaC; environment parity across 5 environments
ComplianceZATCA Phase 2 (Saudi), ETA (Egypt); SBOM per image; audit logs

Internal Documentation — Microtec Platform Team