# avinashcreates/wirachain-healthcare-consent architecture

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

- Interactive diagram: https://gitdiagram.com/avinashcreates/wirachain-healthcare-consent
- Repository: https://github.com/avinashcreates/wirachain-healthcare-consent

## Overview

WiraChain is a consent-aware healthcare exchange prototype spanning a React client, ASP.NET Core API, and blockchain log service. The principal workflow is a user working through the client to manage patient, clinic, and doctor records and patient-to-clinic permissions; the backend exposes domain APIs, with FHIR interoperability and Ethereum-backed permission provenance as documented platform capabilities. Controller-to-service links are supported by excerpts; broader integration links are documented in the README, while unsampled implementation details are not asserted.

Main entry points: [`wirachain-frontend-main/wirachain-frontend-main/src/redux/api/CustomBaseQuery.tsx`](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-frontend-main/wirachain-frontend-main/src/redux/api/CustomBaseQuery.tsx) (API query layer), [`wirachain-frontend-main/wirachain-frontend-main/src/main.tsx`](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-frontend-main/wirachain-frontend-main/src/main.tsx) (React client), [`wirachain-backend-main/wirachain-backend-main/Program.cs`](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Program.cs) (ASP.NET API), [`wirachain-backend-main/wirachain-backend-main/Patients/Controllers/Rest/PatientsController.cs`](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Patients/Controllers/Rest/PatientsController.cs) (Patient workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client application"]
  node_frontend["React client<br/>[main.tsx]"]
  node_authstate["Auth state<br/>[AuthSlice.tsx]"]
  node_token["Token manager<br/>[TokenManager.tsx]"]
  node_apiquery["API query layer"]
end

subgraph group_api["Healthcare API"]
  node_backend["ASP.NET API<br/>[Program.cs]"]
  node_patients["Patient workflows"]
  node_patientservice["Patient services<br/>[PatientService.cs]"]
  node_clinics["Clinic workflows"]
  node_doctors["Doctor workflows"]
  node_medical["Consultations and tests"]
  node_db[("MySQL persistence<br/>[AppDbContext.cs]")]
end

subgraph group_consent["Consent and interoperability"]
  node_permission["Patient clinic consent"]
  node_fhir["FHIR interoperability"]
end

subgraph group_audit["Blockchain audit"]
  node_ethereum["Ethereum event integration<br/>[EthereumService.cs]"]
  node_chainservice["Contract API<br/>[server.ts]"]
  node_logs["Permission event logs<br/>[logs.controller.ts]"]
end

node_user(("Healthcare user"))
node_chain(("Ethereum network"))

node_user -->|"uses"| node_frontend
node_frontend -->|"manages session"| node_authstate
node_apiquery -->|"reads tokens"| node_token
node_apiquery -->|"refreshes session"| node_authstate
node_frontend -.->|"requests API"| node_apiquery
node_apiquery -.->|"calls API"| node_backend
node_backend -.->|"routes requests"| node_patients
node_backend -.->|"routes requests"| node_clinics
node_patients -->|"calls"| node_patientservice
node_clinics -.->|"persists records"| node_db
node_doctors -.->|"persists records"| node_db
node_medical -.->|"persists records"| node_db
node_patients -->|"grants or revokes"| node_permission
node_doctors -->|"requests access"| node_permission
node_patientservice -.->|"exchanges FHIR"| node_fhir
node_permission -.->|"records consent events"| node_ethereum
node_ethereum -.->|"emits events"| node_chain
node_chainservice -->|"routes log requests"| node_logs
node_logs -->|"queries permission events"| node_chain

click node_frontend "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-frontend-main/wirachain-frontend-main/src/main.tsx"
click node_authstate "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-frontend-main/wirachain-frontend-main/src/redux/slices/AuthSlice.tsx"
click node_token "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-frontend-main/wirachain-frontend-main/src/features/auth/utils/TokenManager.tsx"
click node_apiquery "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-frontend-main/wirachain-frontend-main/src/redux/api/CustomBaseQuery.tsx"
click node_backend "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Program.cs"
click node_patients "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Patients/Controllers/Rest/PatientsController.cs"
click node_patientservice "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Patients/Services/PatientService.cs"
click node_clinics "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Clinics/Controllers/Rest/ClinicsController.cs"
click node_doctors "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Doctors/Controllers/Rest/DoctorsController.cs"
click node_medical "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/MedicalConsultations/Api/Rest/Controllers/MedicalConsultationsController.cs"
click node_db "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Shared/Persistence/Context/AppDbContext.cs"
click node_permission "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Permissions/Api/Rest/Controllers/PatientClinicPermissionsController.cs"
click node_fhir "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Shared/Integration/Fhir/Service/FhirPatientService.cs"
click node_ethereum "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Shared/Integration/Ethereum/Services/EthereumService.cs"
click node_chainservice "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-smart-contract-deployment-main/wirachain-smart-contract-deployment-main/src/server.ts"
click node_logs "https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-smart-contract-deployment-main/wirachain-smart-contract-deployment-main/src/api/logs/logs.controller.ts"

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_frontend,node_authstate,node_token,node_apiquery,node_user toneBlue
class node_backend,node_patients,node_patientservice,node_clinics,node_doctors,node_medical,node_db toneAmber
class node_permission,node_fhir toneMint
class node_ethereum,node_chainservice,node_logs toneRose
class node_chain toneIndigo
```

## Components

### Client application

- [React client](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-frontend-main/wirachain-frontend-main/src/main.tsx): `wirachain-frontend-main/wirachain-frontend-main/src/main.tsx`
- [Auth state](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-frontend-main/wirachain-frontend-main/src/redux/slices/AuthSlice.tsx): `wirachain-frontend-main/wirachain-frontend-main/src/redux/slices/AuthSlice.tsx`
- [Token manager](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-frontend-main/wirachain-frontend-main/src/features/auth/utils/TokenManager.tsx): `wirachain-frontend-main/wirachain-frontend-main/src/features/auth/utils/TokenManager.tsx`
- [API query layer](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-frontend-main/wirachain-frontend-main/src/redux/api/CustomBaseQuery.tsx): `wirachain-frontend-main/wirachain-frontend-main/src/redux/api/CustomBaseQuery.tsx`

### Healthcare API

- [ASP.NET API](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Program.cs): `wirachain-backend-main/wirachain-backend-main/Program.cs`
- [Patient workflows](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Patients/Controllers/Rest/PatientsController.cs): `wirachain-backend-main/wirachain-backend-main/Patients/Controllers/Rest/PatientsController.cs`
- [Patient services](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Patients/Services/PatientService.cs): `wirachain-backend-main/wirachain-backend-main/Patients/Services/PatientService.cs`
- [Clinic workflows](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Clinics/Controllers/Rest/ClinicsController.cs): `wirachain-backend-main/wirachain-backend-main/Clinics/Controllers/Rest/ClinicsController.cs`
- [Doctor workflows](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Doctors/Controllers/Rest/DoctorsController.cs): `wirachain-backend-main/wirachain-backend-main/Doctors/Controllers/Rest/DoctorsController.cs`
- [Consultations and tests](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/MedicalConsultations/Api/Rest/Controllers/MedicalConsultationsController.cs): `wirachain-backend-main/wirachain-backend-main/MedicalConsultations/Api/Rest/Controllers/MedicalConsultationsController.cs`
- [MySQL persistence](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Shared/Persistence/Context/AppDbContext.cs): `wirachain-backend-main/wirachain-backend-main/Shared/Persistence/Context/AppDbContext.cs`

### Consent and interoperability

- [Patient clinic consent](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Permissions/Api/Rest/Controllers/PatientClinicPermissionsController.cs): `wirachain-backend-main/wirachain-backend-main/Permissions/Api/Rest/Controllers/PatientClinicPermissionsController.cs`
- [FHIR interoperability](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Shared/Integration/Fhir/Service/FhirPatientService.cs): `wirachain-backend-main/wirachain-backend-main/Shared/Integration/Fhir/Service/FhirPatientService.cs`

### Blockchain audit

- [Ethereum event integration](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-backend-main/wirachain-backend-main/Shared/Integration/Ethereum/Services/EthereumService.cs): `wirachain-backend-main/wirachain-backend-main/Shared/Integration/Ethereum/Services/EthereumService.cs`
- [Contract API](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-smart-contract-deployment-main/wirachain-smart-contract-deployment-main/src/server.ts): `wirachain-smart-contract-deployment-main/wirachain-smart-contract-deployment-main/src/server.ts`
- [Permission event logs](https://github.com/avinashcreates/wirachain-healthcare-consent/blob/main/wirachain-smart-contract-deployment-main/wirachain-smart-contract-deployment-main/src/api/logs/logs.controller.ts): `wirachain-smart-contract-deployment-main/wirachain-smart-contract-deployment-main/src/api/logs/logs.controller.ts`

### Other components

- **Healthcare user**
- **Ethereum network**

## Connections

- Healthcare user → React client: uses
- React client → Auth state: manages session (evidence: `wirachain-frontend-main/wirachain-frontend-main/src/main.tsx`)
- API query layer → Token manager: reads tokens (evidence: `wirachain-frontend-main/wirachain-frontend-main/src/redux/api/CustomBaseQuery.tsx`)
- API query layer → Auth state: refreshes session (evidence: `wirachain-frontend-main/wirachain-frontend-main/src/redux/api/CustomBaseQuery.tsx`)
- React client → API query layer: requests API
- API query layer → ASP.NET API: calls API
- ASP.NET API → Patient workflows: routes requests
- ASP.NET API → Clinic workflows: routes requests
- Patient workflows → Patient services: calls (evidence: `wirachain-backend-main/wirachain-backend-main/Patients/Controllers/Rest/PatientsController.cs`)
- Clinic workflows → MySQL persistence: persists records
- Doctor workflows → MySQL persistence: persists records
- Consultations and tests → MySQL persistence: persists records
- Patient workflows → Patient clinic consent: grants or revokes (evidence: `wirachain-backend-main/wirachain-backend-main/Patients/Controllers/Rest/PatientsController.cs`)
- Doctor workflows → Patient clinic consent: requests access (evidence: `wirachain-backend-main/wirachain-backend-main/Doctors/Controllers/Rest/DoctorsController.cs`)
- Patient services → FHIR interoperability: exchanges FHIR
- Patient clinic consent → Ethereum event integration: records consent events
- Ethereum event integration → Ethereum network: emits events
- Contract API → Permission event logs: routes log requests (evidence: `wirachain-smart-contract-deployment-main/wirachain-smart-contract-deployment-main/src/server.ts`)
- Permission event logs → Ethereum network: queries permission events (evidence: `wirachain-smart-contract-deployment-main/wirachain-smart-contract-deployment-main/src/api/logs/logs.controller.ts`)
