Skip to content

BOUNDED_CONTEXT_MIGRATION_MATRIX.md: Domain Decomposition & Migration Sequencing ​

NOTE

Historical record (Phase 0 discovery, September 2026). It describes the system as it was then. Neo4j, listed here as the designer's store, is retired (ADR-2245); protocol versions become immutable PostgreSQL snapshots in the kernel. Current system: ARCHITECTURE.md.

Project: Cadence Clinical Research Software Platform Target Runtime: .NET 10 (C# 14 / ASP.NET Core 10 Minimal APIs) Governing ADRs: ADR-2233, ADR-2428Regulatory Standards: 21 CFR Part 11, ICH GCP E6(R2), PRD-SYS-053


1. Bounded Context Decomposition & Domain Boundaries ​

Cadence decomposes into 18 isolated bounded contexts, each adhering to Single-Assembly Clean Architecture (Domain/, Application/, Infrastructure/, Endpoints/):

Context Catalog & Responsibilities ​

Bounded ContextProject AssemblyDomain Boundary & Primary AggregatesState Persistence Layer
MDR / Protocol DesignCadence.Apps.DesignerStudy, StudyArm, StudyEpoch, Encounter, Activity, BiomedicalConcept, SoaMatrixNeo4j Graph DB (USDM v3/v4)
EDC Execution RuntimeCadence.Apps.ExecutionSubject, ClinicalObservation, FormSubmission, ClinicalQuery, RandomizationRecord, LabAssessmentPostgreSQL (cadence_edc)
Identity & GatewayCadence.Apps.GatewayReverse-proxy router, token translation, Keycloak OIDC introspection, HMAC signingStateless (In-Memory Route Table)
Trial Master FileCadence.Apps.EtmfTmfZone, TmfSection, TmfArtifact, EdlRecord, EtmfDocument, QcTaskPostgreSQL (cadence_etmf) + S3
Investigator Site FileCadence.Apps.EisfSiteBinder, RegulatoryBinderDocument, PiAttestationLedgerPostgreSQL / SQLite (cadence_eisf)
CTMS OperationsCadence.Apps.CtmsClinicalSite, MonitoringVisitReport, SiteGreenlightChecklist, DoaTaskDelegationPostgreSQL (cadence_ctms)
Quality & GovernanceCadence.Apps.QualityProtocolDeviation, CapaInvestigation, CsmForensicScan, AuditInspectionPostgreSQL (cadence_quality)
Safety & PVCadence.Apps.SafetySafetyCase, AdverseEventReport, CtcaeGradingRecord, IcsrTransmissionPostgreSQL / SQLite (cadence_safety)
Clinical Issue HubCadence.Apps.TicketsSupportTicket, DiscrepancyQuery, TicketComment, SlaTimerPostgreSQL / SQLite (cadence_tickets)
NotificationsCadence.Apps.NotificationsNotificationMessage, ChannelConfiguration, DispatchReceiptPostgreSQL / SQLite (cadence_notifications)
Electronic ConsentCadence.Apps.EconsentConsentTemplate, SubjectConsentState, CryptographicSignatureManifestPostgreSQL / SQLite (cadence_econsent)
Organization DirectoryCadence.Apps.OrgOrganization, SiteLocation, PersonnelProfile, DelegationLogPostgreSQL (cadence_edc)
Site PaymentsCadence.Apps.PaymentsSiteBudget, PayableCalculation, ParticipantWallet, TaxRecord1099PostgreSQL / SQLite (cadence_payments)
EHR InteroperabilityCadence.Apps.InteropFhirResourceDraft, CrcReconciliationItem, SensorBiometricStreamPostgreSQL / SQLite (cadence_interop)
Clinical AI GatewayCadence.Apps.AiGatewayMedicalCodingMatch, DeidTokenMap, ReasoningTask, RagKnowledgeSliceEphemeral Vector Cache / REST
Storage & MediaCadence.Apps.FileshareDocumentEnvelope, StoragePort, TranscodeTask, VirusScanResultMinIO / S3 + PostgreSQL / SQLite
Oncology ImagingCadence.Apps.ImagingDicomSeries, BlindedReaderReview, RecistEvaluation, AdjudicationTaskPostgreSQL / SQLite (cadence_imaging)
SOP Knowledge HubCadence.Apps.KnowledgeKnowledgeArticle, ArticleVersion, CategoryTree, ContextualRulePostgreSQL / SQLite (cadence_knowledge)

2. Coupling Scorecard & Architecture Sentinels ​

To prevent cross-boundary pollution and enforce GxP modularity, the coupling rules are codified into tests/Cadence.ArchitectureTests.csproj using ArchUnitNET:

Coupling DimensionLegacy Python RiskTarget .NET 10 ConstraintEnforcement Mechanism
Database Sharingapps/org and apps/execution shared cadence_edc connection string.Zero cross-service entity mapping. Distinct DbContext per microservice with independent migrations.ArchUnitNET rule: DbContext classes cannot reference sibling entities.
Synchronous In-Process CouplingDirect Python module imports between services (e.g. apps.execution.models in apps.ctms).Strictly prohibited. Services interact exclusively via REST endpoints using Cadence.Contracts.ArchUnitNET rule: Cadence.Apps.<A> cannot reference Cadence.Apps.<B>.
Direct Shared State MutationsDirect updates to foreign tables without audit logging.Cross-service mutations must execute via Transactional Outbox domain events or authenticated REST APIs.Compiler-enforced boundary + IGxPAuditable on all entity aggregates.
Domain PurityLeaking web framework or ORM types into business logic (from fastapi import Request in domain).Domain layers (Domain/) have zero external references—only pure C# 14 and Cadence.Core.Domain.ArchUnitNET rule: Types().That().ResideInNamespace("*.Domain").Should().NotDependOnAny(...).

3. Migration Graph & Phased Execution Sequence ​

Migration must follow a disciplined, topologically sorted dependency graph across four distinct tiers:

Tier 1: Leaf Nodes & Shared Foundations (Prerequisites — Completed in Tracer Bullet) ​

  • Cadence.Core.Domain (packages/engine_core): Fundamental domain abstractions (AggregateRoot<T>, Entity<T>, ValueObject, Result<T, DomainError>, IGxPAuditable, USDM v3/v4 protocol primitives).
  • Cadence.Security (packages/security): HMAC-SHA256 signature generator (HmacSigner), canonical RFC 8785 JSON serializer, sig_token re-authentication verifier, and Keycloak JWT validation filters.
  • Cadence.Database (packages/database): EF Core DbContext base configurations, GxPAuditInterceptor with SHA-256 Merkle block hashing, and PostgreSQL connection resiliency.
  • Cadence.Contracts (packages/contracts): Inter-service DTO records, HTTP API client interfaces (IExecutionApiClient, IDesignerApiClient), and MassTransit event contracts.
  • Cadence.Testing (packages/testing): Entity factories (SubjectFactory), in-memory repository fakes (InMemoryRepository<T>), and mock security context helpers.
  • Cadence.Deid (packages/deid): HIPAA Safe Harbor & Expert Determination rule engine with high-throughput compiled C# 14 regex PHI redactors and SHA-256 date-shifting.
  • Cadence.Storage (packages/storage): Multi-backend storage port (StoragePort) with AWS S3 envelope encryption, local disk spooling, and Google Drive API v3 video evidence uploads.
  • Cadence.Ddf (packages/ddf): Digital Data Flow compiler, tripartite transformer, and Dataset-JSON 1.0 columnar ETL pipeline.
  • Cadence.Cli (packages/cli): Native developer CLI built with Spectre.Console.

Tier 2: Core Entities & Persistent Engines (Tracer Bullet Slices) ​

  • Cadence.Apps.Execution (apps/execution): Core EDC engine handling subject enrollment, dynamic schema projection, eCRF form entries, real-time edit checks, and lab reference ranges.
  • Cadence.Apps.Designer (apps/designer): CDISC USDM protocol authoring, Neo4j graph driver, high-density Schedule of Activities (SoA) matrix compiler, and protocol amendment diffing.
  • Cadence.Apps.Org (apps/org): Organization hierarchy, site directories, user credentials, and Principal Investigator electronic Delegation of Authority (DOA) log.

Tier 3: Orchestrators & Regulatory Services ​

  • Cadence.Apps.Ctms (apps/ctms): Clinical trial site milestones, monitoring visit reports (MVR), 6-facet greenlight activation engine.
  • Cadence.Apps.Etmf (apps/etmf): DIA TMF Reference Model v3.2.0 document ingestion, automated QC review stages, and document expiration tracking.
  • Cadence.Apps.Eisf (apps/eisf): Investigator Site File binders, PI sign-offs, and bidirectional synchronization with eTMF.
  • Cadence.Apps.Quality (apps/quality): Protocol deviation tracking, CAPA workflows, and Centralized Statistical Monitoring (CSM) forensics. Sequenced in Tier 3 following Cadence.Execution and utilizing typed IExecutionApiClient contracts (ADR-2239).
  • Cadence.Apps.Safety (apps/safety): Adverse event intake, CTCAE laboratory toxicity evaluation, ICH E2B(R3) ISO 27953-2 XML generation, and B2B AS2 transmission.
  • Cadence.Apps.Econsent (apps/econsent): Dynamic informed consent templates, Flesch-Kincaid readability grading, cryptographic signature stamping, and protocol amendment re-consent gating.
  • Cadence.Apps.Payments (apps/payments): Procedure-based grant budgets, CRA SDV trigger-based payables, participant stipends, and 1099 reporting enforcing the Universal Decimal Precision Standard (System.Decimal) under ADR-2239.
  • Cadence.Apps.Tickets (apps/tickets): Clinical discrepancy escalation hub, dual-target SLA tracking, and 21 CFR Part 11 reopening reason audit logs.

Tier 4: Edge, Consumers & External Integrations ​

  • Cadence.Apps.Gateway (apps/gateway): Central reverse proxy router, Keycloak OIDC authentication, HMAC injection, and dynamic HTTP OpenAPI aggregation (ADR-2239).
  • Cadence.Apps.Notifications (apps/notifications): Asynchronous multi-channel dispatch engine (SMTP email via MailKit, SMS, and HMAC signed webhooks).
  • Cadence.Apps.Interop (apps/interop): SMART on FHIR USCDI clinical ingestion, split-screen CRC reconciliation drawer, and continuous biometric sensor streams.
  • Cadence.Apps.AiGateway (apps/ai_gateway): Outbound PHI/PII de-identification air-gap, three-tier model router, and hybrid semantic medical coding (MedDRA / WHODrug).
  • Cadence.Apps.Fileshare (apps/fileshare): Binary blob storage broker, MinIO/S3 presigned transfer URLs, and media transcoding pipelines (FFMpegCore, nClam).
  • Cadence.Apps.Imaging (apps/imaging): Blinded dual-reader RECIST 1.1 oncology adjudication and WebGL multi-planar reconstruction (MPR) viewer.
  • Cadence.Apps.Knowledge (apps/knowledge): Contextual SOP delivery, hierarchical specificity scoring, and two-tier controlled article governance.
  • Cadence.Compliance (packages/compliance): Automated IQ/OQ/PQ regulatory test runner, RTM synchronization, and 21 CFR Part 11 verification.
  • apps/web (apps/web): Primary Clinical Investigator, CRC, and Data Manager Vue 3 SPA frontend.
  • apps/subject-portal (apps/subject-portal): Patient/Subject-facing eCOA and eConsent Vue 3 application.