# haroun08/ehr-management-system architecture

> Architecture diagram of the GitHub repository haroun08/ehr-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/haroun08/ehr-management-system
- Repository: https://github.com/haroun08/ehr-management-system

## Overview

This is a .NET microservices platform for healthcare records, appointments, user access, AI-assisted chat, notifications, lab integration, and health content. The main user journey is to authenticate, access or update patient records, arrange care, and receive AI, laboratory, or notification results. Kafka and REST connect service boundaries; SignalR supports real-time communication. Shared infrastructure supplies CQRS conventions, persistence abstractions, authorization, and event-bus implementations. The README documents platform capabilities, but the excerpts mostly show repository behavior, so service-to-service flows are not inferred where their callers were not shown.

Main entry points: [`src/EHR-Management-System.SharedLibrary/Infrastructure/EventBus/Kafka/KafkaEventBus.cs`](https://github.com/haroun08/ehr-management-system/blob/main/src/EHR-Management-System.SharedLibrary/Infrastructure/EventBus/Kafka/KafkaEventBus.cs) (Event bus), [`src/GatewayAPI/ApiGateway.Host/Program.cs`](https://github.com/haroun08/ehr-management-system/blob/main/src/GatewayAPI/ApiGateway.Host/Program.cs) (API gateway), [`src/Services/EHR (Health Records) Service`](https://github.com/haroun08/ehr-management-system/tree/main/src/Services/EHR%20(Health%20Records)%20Service) (Health records), [`src/Services/AppointmentService`](https://github.com/haroun08/ehr-management-system/tree/main/src/Services/AppointmentService) (Appointments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_care["Care workflows"]
  node_ehr["Health records"]
  node_ehrquery["Patient record queries"]
  node_appointments["Appointments"]
  node_schedulequery["Schedule queries"]
  node_ehrstore[("EHR document store")]
  node_scheduledata[("Schedule SQL data")]
end

subgraph group_access["Identity and platform access"]
  node_gateway["API gateway<br/>[Program.cs]"]
  node_identity["User management"]
end

subgraph group_engagement["Patient engagement"]
  node_ai["AI chatbot"]
  node_chatquery["Chat session queries"]
  node_notifications["Notifications"]
  node_faqblog["FAQ and blog"]
  node_redis[("Redis chat data")]
end

subgraph group_integration["External and event integration"]
  node_lab["Lab integration"]
  node_labquery["Lab result queries"]
  node_eventbus["Event bus<br/>[KafkaEventBus.cs]"]
  node_kafka["Kafka broker"]
  node_signalr["SignalR"]
  node_labdata[("Lab SQL data")]
end

subgraph group_shared["Shared runtime"]
  node_shared["Shared application runtime"]
end

node_patient(("Patient or clinician"))

node_patient -.->|"sends API requests"| node_gateway
node_gateway -.->|"routes requests"| node_identity
node_gateway -.->|"routes requests"| node_ehr
node_gateway -.->|"routes requests"| node_appointments
node_gateway -.->|"routes requests"| node_ai
node_ehrquery -->|"reads records"| node_ehrstore
node_schedulequery -->|"queries schedules"| node_scheduledata
node_labquery -->|"queries results"| node_labdata
node_chatquery -->|"reads sessions"| node_redis
node_eventbus -.->|"publishes events"| node_kafka
node_patient -.->|"uses real-time chat"| node_signalr
node_ehr -.->|"emits integration events"| node_eventbus
node_appointments -.->|"emits integration events"| node_eventbus
node_ai -.->|"emits integration events"| node_eventbus
node_lab -.->|"emits integration events"| node_eventbus
node_notifications -.->|"uses event messaging"| node_eventbus
node_ehr -.->|"uses shared kernel"| node_shared
node_identity -.->|"uses shared kernel"| node_shared

click node_gateway "https://github.com/haroun08/ehr-management-system/blob/main/src/GatewayAPI/ApiGateway.Host/Program.cs"
click node_identity "https://github.com/haroun08/ehr-management-system/tree/main/src/Services/EHR-UserManagementService"
click node_ehr "https://github.com/haroun08/ehr-management-system/tree/main/src/Services/EHR%20(Health%20Records)%20Service"
click node_ehrquery "https://github.com/haroun08/ehr-management-system/blob/main/src/Services/EHR%20(Health%20Records)%20Service/EHR%20(Health%20Records)%20Service.Infrastructure/Repositories/PatientRepo/PatientQueryRepository.cs"
click node_appointments "https://github.com/haroun08/ehr-management-system/tree/main/src/Services/AppointmentService"
click node_schedulequery "https://github.com/haroun08/ehr-management-system/blob/main/src/Services/AppointmentService/AppointmentService.Infrastructure/Repositories/DoctorScheduleRepo/DoctorScheduleQueryRepository.cs"
click node_lab "https://github.com/haroun08/ehr-management-system/tree/main/src/Services/ExternalIntegrationService"
click node_labquery "https://github.com/haroun08/ehr-management-system/blob/main/src/Services/ExternalIntegrationService/ExternalIntegrationService.Infrastructure/Repositories/LabResultQueryRepository.cs"
click node_ai "https://github.com/haroun08/ehr-management-system/tree/main/src/Services/AIChatbotChatService"
click node_chatquery "https://github.com/haroun08/ehr-management-system/blob/main/src/Services/AIChatbotChatService/AIChatbotChatService.Infrastructure/Repositories/ChatSessionRepo/ChatSessionQueryRepository.cs"
click node_notifications "https://github.com/haroun08/ehr-management-system/tree/main/src/Services/NotificationService"
click node_faqblog "https://github.com/haroun08/ehr-management-system/tree/main/src/Services/FAQBlog%20Service"
click node_eventbus "https://github.com/haroun08/ehr-management-system/blob/main/src/EHR-Management-System.SharedLibrary/Infrastructure/EventBus/Kafka/KafkaEventBus.cs"
click node_ehrstore "https://github.com/haroun08/ehr-management-system/blob/main/src/Services/EHR%20(Health%20Records)%20Service/EHR%20(Health%20Records)%20Service.Infrastructure/Repositories/PatientRepo/PatientQueryRepository.cs"
click node_scheduledata "https://github.com/haroun08/ehr-management-system/blob/main/src/Services/AppointmentService/AppointmentService.Infrastructure/Repositories/DoctorScheduleRepo/DoctorScheduleQueryRepository.cs"
click node_labdata "https://github.com/haroun08/ehr-management-system/blob/main/src/Services/ExternalIntegrationService/ExternalIntegrationService.Infrastructure/Repositories/LabResultQueryRepository.cs"
click node_redis "https://github.com/haroun08/ehr-management-system/blob/main/src/Services/AIChatbotChatService/AIChatbotChatService.Infrastructure/Repositories/ChatSessionRepo/ChatSessionQueryRepository.cs"
click node_shared "https://github.com/haroun08/ehr-management-system/tree/main/src/EHR-Management-System.SharedLibrary"

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_ehr,node_ehrquery,node_appointments,node_schedulequery,node_ehrstore,node_scheduledata toneBlue
class node_gateway,node_identity toneAmber
class node_ai,node_chatquery,node_notifications,node_faqblog,node_redis toneMint
class node_lab,node_labquery,node_eventbus,node_kafka,node_signalr,node_labdata toneRose
class node_shared,node_patient toneIndigo
```

## Components

### Care workflows

- [Health records](https://github.com/haroun08/ehr-management-system/tree/main/src/Services/EHR%20(Health%20Records)%20Service): `src/Services/EHR (Health Records) Service`
- [Patient record queries](https://github.com/haroun08/ehr-management-system/blob/main/src/Services/EHR%20(Health%20Records)%20Service/EHR%20(Health%20Records)%20Service.Infrastructure/Repositories/PatientRepo/PatientQueryRepository.cs): `src/Services/EHR (Health Records) Service/EHR (Health Records) Service.Infrastructure/Repositories/PatientRepo/PatientQueryRepository.cs`
- [Appointments](https://github.com/haroun08/ehr-management-system/tree/main/src/Services/AppointmentService): `src/Services/AppointmentService`
- [Schedule queries](https://github.com/haroun08/ehr-management-system/blob/main/src/Services/AppointmentService/AppointmentService.Infrastructure/Repositories/DoctorScheduleRepo/DoctorScheduleQueryRepository.cs): `src/Services/AppointmentService/AppointmentService.Infrastructure/Repositories/DoctorScheduleRepo/DoctorScheduleQueryRepository.cs`
- [EHR document store](https://github.com/haroun08/ehr-management-system/blob/main/src/Services/EHR%20(Health%20Records)%20Service/EHR%20(Health%20Records)%20Service.Infrastructure/Repositories/PatientRepo/PatientQueryRepository.cs): `src/Services/EHR (Health Records) Service/EHR (Health Records) Service.Infrastructure/Repositories/PatientRepo/PatientQueryRepository.cs`
- [Schedule SQL data](https://github.com/haroun08/ehr-management-system/blob/main/src/Services/AppointmentService/AppointmentService.Infrastructure/Repositories/DoctorScheduleRepo/DoctorScheduleQueryRepository.cs): `src/Services/AppointmentService/AppointmentService.Infrastructure/Repositories/DoctorScheduleRepo/DoctorScheduleQueryRepository.cs`

### Identity and platform access

- [API gateway](https://github.com/haroun08/ehr-management-system/blob/main/src/GatewayAPI/ApiGateway.Host/Program.cs): `src/GatewayAPI/ApiGateway.Host/Program.cs`
- [User management](https://github.com/haroun08/ehr-management-system/tree/main/src/Services/EHR-UserManagementService): `src/Services/EHR-UserManagementService`

### Patient engagement

- [AI chatbot](https://github.com/haroun08/ehr-management-system/tree/main/src/Services/AIChatbotChatService): `src/Services/AIChatbotChatService`
- [Chat session queries](https://github.com/haroun08/ehr-management-system/blob/main/src/Services/AIChatbotChatService/AIChatbotChatService.Infrastructure/Repositories/ChatSessionRepo/ChatSessionQueryRepository.cs): `src/Services/AIChatbotChatService/AIChatbotChatService.Infrastructure/Repositories/ChatSessionRepo/ChatSessionQueryRepository.cs`
- [Notifications](https://github.com/haroun08/ehr-management-system/tree/main/src/Services/NotificationService): `src/Services/NotificationService`
- [FAQ and blog](https://github.com/haroun08/ehr-management-system/tree/main/src/Services/FAQBlog%20Service): `src/Services/FAQBlog Service`
- [Redis chat data](https://github.com/haroun08/ehr-management-system/blob/main/src/Services/AIChatbotChatService/AIChatbotChatService.Infrastructure/Repositories/ChatSessionRepo/ChatSessionQueryRepository.cs): `src/Services/AIChatbotChatService/AIChatbotChatService.Infrastructure/Repositories/ChatSessionRepo/ChatSessionQueryRepository.cs`

### External and event integration

- [Lab integration](https://github.com/haroun08/ehr-management-system/tree/main/src/Services/ExternalIntegrationService): `src/Services/ExternalIntegrationService`
- [Lab result queries](https://github.com/haroun08/ehr-management-system/blob/main/src/Services/ExternalIntegrationService/ExternalIntegrationService.Infrastructure/Repositories/LabResultQueryRepository.cs): `src/Services/ExternalIntegrationService/ExternalIntegrationService.Infrastructure/Repositories/LabResultQueryRepository.cs`
- [Event bus](https://github.com/haroun08/ehr-management-system/blob/main/src/EHR-Management-System.SharedLibrary/Infrastructure/EventBus/Kafka/KafkaEventBus.cs): `src/EHR-Management-System.SharedLibrary/Infrastructure/EventBus/Kafka/KafkaEventBus.cs`
- **Kafka broker**
- **SignalR**
- [Lab SQL data](https://github.com/haroun08/ehr-management-system/blob/main/src/Services/ExternalIntegrationService/ExternalIntegrationService.Infrastructure/Repositories/LabResultQueryRepository.cs): `src/Services/ExternalIntegrationService/ExternalIntegrationService.Infrastructure/Repositories/LabResultQueryRepository.cs`

### Shared runtime

- [Shared application runtime](https://github.com/haroun08/ehr-management-system/tree/main/src/EHR-Management-System.SharedLibrary): `src/EHR-Management-System.SharedLibrary`

### Other components

- **Patient or clinician**

## Connections

- Patient or clinician → API gateway: sends API requests
- API gateway → User management: routes requests
- API gateway → Health records: routes requests
- API gateway → Appointments: routes requests
- API gateway → AI chatbot: routes requests
- Patient record queries → EHR document store: reads records (evidence: `src/Services/EHR (Health Records) Service/EHR (Health Records) Service.Infrastructure/Repositories/PatientRepo/PatientQueryRepository.cs`)
- Schedule queries → Schedule SQL data: queries schedules (evidence: `src/Services/AppointmentService/AppointmentService.Infrastructure/Repositories/DoctorScheduleRepo/DoctorScheduleQueryRepository.cs`)
- Lab result queries → Lab SQL data: queries results (evidence: `src/Services/ExternalIntegrationService/ExternalIntegrationService.Infrastructure/Repositories/LabResultQueryRepository.cs`)
- Chat session queries → Redis chat data: reads sessions (evidence: `src/Services/AIChatbotChatService/AIChatbotChatService.Infrastructure/Repositories/ChatSessionRepo/ChatSessionQueryRepository.cs`)
- Event bus → Kafka broker: publishes events
- Patient or clinician → SignalR: uses real-time chat
- Health records → Event bus: emits integration events
- Appointments → Event bus: emits integration events
- AI chatbot → Event bus: emits integration events
- Lab integration → Event bus: emits integration events
- Notifications → Event bus: uses event messaging
- Health records → Shared application runtime: uses shared kernel (evidence: `src/Services/EHR (Health Records) Service/EHR (Health Records) Service.Infrastructure/Repositories/PatientRepo/PatientQueryRepository.cs`)
- User management → Shared application runtime: uses shared kernel (evidence: `src/Services/EHR-UserManagementService/EHR-UserManagementService.Infrastructure/Repositories/UserRepo/UserQueryRepository.cs`)
