# jacan/mt_race architecture

> Architecture diagram of the GitHub repository jacan/mt_race, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jacan/mt_race
- Repository: https://github.com/jacan/mt_race

## Overview

This repository implements a message-driven patient research workflow across ConsentService, PatientService, and ManagementService. A client starts research through the consent API; messages then circulate through Azure Service Bus as consent and analytics stages run. The shown consumers republish events, including PatientEnlisted, which makes the documented-by-code flow a loop rather than a terminal analytics result. Source excerpts do not show every message contract or endpoint binding, so uncertain dispatch links are dashed; the README provides no additional product capabilities.

Main entry points: [`ConsentService/src/Controllers/ConsentController.cs`](https://github.com/jacan/mt_race/blob/main/ConsentService/src/Controllers/ConsentController.cs) (Consent API), [`PatientService/src/Consumers/PatientConsentedConsumer.cs`](https://github.com/jacan/mt_race/blob/main/PatientService/src/Consumers/PatientConsentedConsumer.cs) (Consent consumer), [`ManagementService/src/Consumers/AnalyticsInitiatedForConsentedPatientConsumer.cs`](https://github.com/jacan/mt_race/blob/main/ManagementService/src/Consumers/AnalyticsInitiatedForConsentedPatientConsumer.cs) (Analytics consumer), [`ConsentService/src/Consumers/PatientEnlistedConsumer.cs`](https://github.com/jacan/mt_race/blob/main/ConsentService/src/Consumers/PatientEnlistedConsumer.cs) (Enlistment consumer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_consent["Consent service"]
  node_consent_api["Consent API"]
  node_enlisted_consumer["Enlistment consumer"]
  node_consent_startup["Bus registration<br/>[Startup.cs]"]
end

subgraph group_patient["Patient service"]
  node_patient_consumer["Consent consumer"]
  node_patient_startup["Bus registration<br/>[Startup.cs]"]
end

subgraph group_management["Management service"]
  node_management_consumer["Analytics consumer"]
  node_management_startup["Bus registration<br/>[Startup.cs]"]
end

subgraph group_contracts["Message contracts"]
  node_enlisted_message["PatientEnlisted<br/>[PatientEnlisted.cs]"]
  node_analytics_message["Analytics initiated"]
end

node_client(("API client"))
node_service_bus["Azure Service Bus"]

node_client -->|"posts to"| node_consent_api
node_consent_api -->|"publishes"| node_enlisted_message
node_consent_api -->|"publishes via"| node_service_bus
node_consent_startup -->|"configures"| node_service_bus
node_patient_startup -->|"configures"| node_service_bus
node_management_startup -->|"configures"| node_service_bus
node_service_bus -.->|"dispatches"| node_enlisted_consumer
node_enlisted_consumer -->|"publishes consent"| node_service_bus
node_service_bus -.->|"dispatches"| node_patient_consumer
node_patient_consumer -->|"publishes"| node_analytics_message
node_patient_consumer -->|"publishes via"| node_service_bus
node_service_bus -.->|"dispatches"| node_management_consumer
node_management_consumer -->|"publishes"| node_enlisted_message
node_management_consumer -->|"publishes via"| node_service_bus

click node_consent_api "https://github.com/jacan/mt_race/blob/main/ConsentService/src/Controllers/ConsentController.cs"
click node_enlisted_consumer "https://github.com/jacan/mt_race/blob/main/ConsentService/src/Consumers/PatientEnlistedConsumer.cs"
click node_consent_startup "https://github.com/jacan/mt_race/blob/main/ConsentService/src/Startup.cs"
click node_patient_consumer "https://github.com/jacan/mt_race/blob/main/PatientService/src/Consumers/PatientConsentedConsumer.cs"
click node_patient_startup "https://github.com/jacan/mt_race/blob/main/PatientService/src/Startup.cs"
click node_management_consumer "https://github.com/jacan/mt_race/blob/main/ManagementService/src/Consumers/AnalyticsInitiatedForConsentedPatientConsumer.cs"
click node_management_startup "https://github.com/jacan/mt_race/blob/main/ManagementService/src/Startup.cs"
click node_enlisted_message "https://github.com/jacan/mt_race/blob/main/Contracts/PatientService.Messages/PatientEnlisted.cs"
click node_analytics_message "https://github.com/jacan/mt_race/blob/main/Contracts/ManagementService.Messages/AnalyticsInitiatedForConsentedPatient.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_consent_api,node_enlisted_consumer,node_consent_startup,node_client toneBlue
class node_patient_consumer,node_patient_startup toneAmber
class node_management_consumer,node_management_startup toneMint
class node_enlisted_message,node_analytics_message toneRose
class node_service_bus toneIndigo
```

## Components

### Consent service

- [Consent API](https://github.com/jacan/mt_race/blob/main/ConsentService/src/Controllers/ConsentController.cs): `ConsentService/src/Controllers/ConsentController.cs`
- [Enlistment consumer](https://github.com/jacan/mt_race/blob/main/ConsentService/src/Consumers/PatientEnlistedConsumer.cs): `ConsentService/src/Consumers/PatientEnlistedConsumer.cs`
- [Bus registration](https://github.com/jacan/mt_race/blob/main/ConsentService/src/Startup.cs): `ConsentService/src/Startup.cs`

### Patient service

- [Consent consumer](https://github.com/jacan/mt_race/blob/main/PatientService/src/Consumers/PatientConsentedConsumer.cs): `PatientService/src/Consumers/PatientConsentedConsumer.cs`
- [Bus registration](https://github.com/jacan/mt_race/blob/main/PatientService/src/Startup.cs): `PatientService/src/Startup.cs`

### Management service

- [Analytics consumer](https://github.com/jacan/mt_race/blob/main/ManagementService/src/Consumers/AnalyticsInitiatedForConsentedPatientConsumer.cs): `ManagementService/src/Consumers/AnalyticsInitiatedForConsentedPatientConsumer.cs`
- [Bus registration](https://github.com/jacan/mt_race/blob/main/ManagementService/src/Startup.cs): `ManagementService/src/Startup.cs`

### Message contracts

- [PatientEnlisted](https://github.com/jacan/mt_race/blob/main/Contracts/PatientService.Messages/PatientEnlisted.cs): `Contracts/PatientService.Messages/PatientEnlisted.cs`
- [Analytics initiated](https://github.com/jacan/mt_race/blob/main/Contracts/ManagementService.Messages/AnalyticsInitiatedForConsentedPatient.cs): `Contracts/ManagementService.Messages/AnalyticsInitiatedForConsentedPatient.cs`

### Other components

- **API client**
- **Azure Service Bus**

## Connections

- API client → Consent API: posts to (evidence: `ConsentService/src/Controllers/ConsentController.cs`)
- Consent API → PatientEnlisted: publishes (evidence: `ConsentService/src/Controllers/ConsentController.cs`)
- Consent API → Azure Service Bus: publishes via (evidence: `ConsentService/src/Controllers/ConsentController.cs`)
- Bus registration → Azure Service Bus: configures (evidence: `ConsentService/src/Startup.cs`)
- Bus registration → Azure Service Bus: configures (evidence: `PatientService/src/Startup.cs`)
- Bus registration → Azure Service Bus: configures (evidence: `ManagementService/src/Startup.cs`)
- Azure Service Bus → Enlistment consumer: dispatches
- Enlistment consumer → Azure Service Bus: publishes consent (evidence: `ConsentService/src/Consumers/PatientEnlistedConsumer.cs`)
- Azure Service Bus → Consent consumer: dispatches
- Consent consumer → Analytics initiated: publishes (evidence: `PatientService/src/Consumers/PatientConsentedConsumer.cs`)
- Consent consumer → Azure Service Bus: publishes via (evidence: `PatientService/src/Consumers/PatientConsentedConsumer.cs`)
- Azure Service Bus → Analytics consumer: dispatches
- Analytics consumer → PatientEnlisted: publishes (evidence: `ManagementService/src/Consumers/AnalyticsInitiatedForConsentedPatientConsumer.cs`)
- Analytics consumer → Azure Service Bus: publishes via (evidence: `ManagementService/src/Consumers/AnalyticsInitiatedForConsentedPatientConsumer.cs`)
