# aayushships/mediflow architecture

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

- Interactive diagram: https://gitdiagram.com/aayushships/mediflow
- Repository: https://github.com/aayushships/mediflow

## Overview

MediFlow is a Spring Boot clinic-management backend. Its principal workflow accepts appointment requests through REST controllers, delegates appointment operations to a service, persists clinic data, and is designed to publish events for background notifications. The graph also preserves patient and doctor/availability management, authentication, and notification-state handling. The README describes some asynchronous capabilities as planned; the source index confirms appointment publishing and storage references, but does not expose the consumer wiring, so that connection is shown only as documented.

Main entry points: [`src/main/java/com/project/MediFlow/Service/Impl/AppointmentServiceImpl.java`](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/Impl/AppointmentServiceImpl.java) (Appointment operations), [`src/main/java/com/project/MediFlow/RabbitMQ/Producer/AppointmentProducer.java`](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/RabbitMQ/Producer/AppointmentProducer.java) (Appointment producer), [`src/main/java/com/project/MediFlow/RabbitMQ/Consumer/NotificationConsumer.java`](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/RabbitMQ/Consumer/NotificationConsumer.java) (Notification consumer), [`src/main/java/com/project/MediFlow/Controller/DoctorController.java`](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Controller/DoctorController.java) (Doctor API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_appointments_api["Appointment API"]
  node_patients_api["Patient API"]
  node_doctors_api["Doctor API"]
  node_availability_api["Availability API"]
  node_auth_api["Authentication API"]
end

subgraph group_clinic["Clinic workflows"]
  node_appointment_service["Appointment operations"]
  node_patient_service["Patient operations<br/>[PatientImpl.java]"]
  node_doctor_service["Doctor operations"]
  node_availability_service["Availability operations"]
  node_appointment_store["Appointment repository"]
  node_doctor_store["Doctor repository"]
  node_patient_store["Patient repository"]
  node_availability_store["Availability repository"]
  node_appointment_entity["Appointment record<br/>[Appointment.java]"]
  node_domain_records["Patient and doctor records<br/>[Patient.java]"]
  node_availability_record["Doctor availability record"]
end

subgraph group_identity["Identity and access"]
  node_auth_service["Authentication operations"]
  node_jwt_service["JWT service<br/>[JwtService.java]"]
end

subgraph group_notifications["Async notifications"]
  node_appointment_event["Appointment event"]
  node_appointment_producer["Appointment producer"]
  node_notification_consumer["Notification consumer"]
  node_email_service["Appointment email"]
  node_notification_state["Notification state"]
end

node_client(("API client"))
node_rabbitmq["RabbitMQ"]
node_postgres[("PostgreSQL")]

node_client -->|"calls"| node_appointments_api
node_appointments_api -->|"delegates"| node_appointment_service
node_client -->|"calls"| node_patients_api
node_patients_api -->|"delegates"| node_patient_service
node_doctors_api -->|"delegates"| node_doctor_service
node_doctors_api -->|"queries slots"| node_appointment_service
node_availability_api -->|"delegates"| node_availability_service
node_auth_api -.->|"delegates"| node_auth_service
node_appointment_service -->|"reads and writes"| node_appointment_store
node_appointment_service -->|"queries"| node_doctor_store
node_appointment_service -->|"queries"| node_patient_store
node_appointment_service -->|"checks slots"| node_availability_store
node_appointment_store -->|"stores"| node_appointment_entity
node_doctor_store -.->|"stores doctor"| node_domain_records
node_patient_store -.->|"stores patient"| node_domain_records
node_availability_store -->|"stores"| node_availability_record
node_appointment_service -->|"publishes event"| node_appointment_producer
node_appointment_producer -.->|"creates payload"| node_appointment_event
node_appointment_producer -.->|"publishes"| node_rabbitmq
node_rabbitmq -.->|"dispatches"| node_notification_consumer
node_notification_consumer -.->|"sends email"| node_email_service
node_notification_consumer -.->|"tracks delivery"| node_notification_state
node_auth_service -->|"creates token"| node_jwt_service
node_appointment_service -.->|"persists appointments"| node_postgres
node_patient_service -.->|"persists patients"| node_postgres
node_availability_service -.->|"persists availability"| node_postgres

click node_appointments_api "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Controller/AppointmentController.java"
click node_patients_api "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Controller/PatientController.java"
click node_doctors_api "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Controller/DoctorController.java"
click node_availability_api "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Controller/DoctorAvailabilityController.java"
click node_auth_api "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Controller/AuthController.java"
click node_appointment_service "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/Impl/AppointmentServiceImpl.java"
click node_patient_service "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/Impl/PatientImpl.java"
click node_doctor_service "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/Impl/DoctorServiceImpl.java"
click node_availability_service "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/Impl/DoctorAvailabilityServiceImpl.java"
click node_appointment_store "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Repository/AppointmentRepository.java"
click node_doctor_store "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Repository/DoctorRepository.java"
click node_patient_store "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Repository/PatientRepository.java"
click node_availability_store "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Repository/DoctorAvailabilityRepository.java"
click node_appointment_entity "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/entities/Appointment.java"
click node_domain_records "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/entities/Patient.java"
click node_availability_record "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/entities/DoctorAvailability.java"
click node_auth_service "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/Impl/AuthServiceImpl.java"
click node_jwt_service "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/security/JwtService.java"
click node_appointment_event "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/RabbitMQ/Event/AppointmentEvent.java"
click node_appointment_producer "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/RabbitMQ/Producer/AppointmentProducer.java"
click node_notification_consumer "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/RabbitMQ/Consumer/NotificationConsumer.java"
click node_email_service "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Email/AppointmentEmailService.java"
click node_notification_state "https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/NotificationStateService.java"

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_appointments_api,node_patients_api,node_doctors_api,node_availability_api,node_auth_api,node_client toneBlue
class node_appointment_service,node_patient_service,node_doctor_service,node_availability_service,node_appointment_store,node_doctor_store,node_patient_store,node_availability_store,node_appointment_entity,node_domain_records,node_availability_record,node_postgres toneAmber
class node_auth_service,node_jwt_service toneMint
class node_appointment_event,node_appointment_producer,node_notification_consumer,node_email_service,node_notification_state toneRose
class node_rabbitmq toneIndigo
```

## Components

### REST API

- [Appointment API](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Controller/AppointmentController.java): `src/main/java/com/project/MediFlow/Controller/AppointmentController.java`
- [Patient API](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Controller/PatientController.java): `src/main/java/com/project/MediFlow/Controller/PatientController.java`
- [Doctor API](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Controller/DoctorController.java): `src/main/java/com/project/MediFlow/Controller/DoctorController.java`
- [Availability API](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Controller/DoctorAvailabilityController.java): `src/main/java/com/project/MediFlow/Controller/DoctorAvailabilityController.java`
- [Authentication API](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Controller/AuthController.java): `src/main/java/com/project/MediFlow/Controller/AuthController.java`

### Clinic workflows

- [Appointment operations](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/Impl/AppointmentServiceImpl.java): `src/main/java/com/project/MediFlow/Service/Impl/AppointmentServiceImpl.java`
- [Patient operations](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/Impl/PatientImpl.java): `src/main/java/com/project/MediFlow/Service/Impl/PatientImpl.java`
- [Doctor operations](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/Impl/DoctorServiceImpl.java): `src/main/java/com/project/MediFlow/Service/Impl/DoctorServiceImpl.java`
- [Availability operations](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/Impl/DoctorAvailabilityServiceImpl.java): `src/main/java/com/project/MediFlow/Service/Impl/DoctorAvailabilityServiceImpl.java`
- [Appointment repository](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Repository/AppointmentRepository.java): `src/main/java/com/project/MediFlow/Repository/AppointmentRepository.java`
- [Doctor repository](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Repository/DoctorRepository.java): `src/main/java/com/project/MediFlow/Repository/DoctorRepository.java`
- [Patient repository](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Repository/PatientRepository.java): `src/main/java/com/project/MediFlow/Repository/PatientRepository.java`
- [Availability repository](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Repository/DoctorAvailabilityRepository.java): `src/main/java/com/project/MediFlow/Repository/DoctorAvailabilityRepository.java`
- [Appointment record](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/entities/Appointment.java): `src/main/java/com/project/MediFlow/entities/Appointment.java`
- [Patient and doctor records](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/entities/Patient.java): `src/main/java/com/project/MediFlow/entities/Patient.java`
- [Doctor availability record](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/entities/DoctorAvailability.java): `src/main/java/com/project/MediFlow/entities/DoctorAvailability.java`

### Identity and access

- [Authentication operations](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/Impl/AuthServiceImpl.java): `src/main/java/com/project/MediFlow/Service/Impl/AuthServiceImpl.java`
- [JWT service](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/security/JwtService.java): `src/main/java/com/project/MediFlow/security/JwtService.java`

### Async notifications

- [Appointment event](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/RabbitMQ/Event/AppointmentEvent.java): `src/main/java/com/project/MediFlow/RabbitMQ/Event/AppointmentEvent.java`
- [Appointment producer](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/RabbitMQ/Producer/AppointmentProducer.java): `src/main/java/com/project/MediFlow/RabbitMQ/Producer/AppointmentProducer.java`
- [Notification consumer](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/RabbitMQ/Consumer/NotificationConsumer.java): `src/main/java/com/project/MediFlow/RabbitMQ/Consumer/NotificationConsumer.java`
- [Appointment email](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Email/AppointmentEmailService.java): `src/main/java/com/project/MediFlow/Email/AppointmentEmailService.java`
- [Notification state](https://github.com/aayushships/mediflow/blob/main/src/main/java/com/project/MediFlow/Service/NotificationStateService.java): `src/main/java/com/project/MediFlow/Service/NotificationStateService.java`

### Other components

- **API client**
- **RabbitMQ**
- **PostgreSQL**

## Connections

- API client → Appointment API: calls
- Appointment API → Appointment operations: delegates (evidence: `src/main/java/com/project/MediFlow/Controller/AppointmentController.java`)
- API client → Patient API: calls
- Patient API → Patient operations: delegates (evidence: `src/main/java/com/project/MediFlow/Controller/PatientController.java`)
- Doctor API → Doctor operations: delegates (evidence: `src/main/java/com/project/MediFlow/Controller/DoctorController.java`)
- Doctor API → Appointment operations: queries slots (evidence: `src/main/java/com/project/MediFlow/Controller/DoctorController.java`)
- Availability API → Availability operations: delegates (evidence: `src/main/java/com/project/MediFlow/Controller/DoctorAvailabilityController.java`)
- Authentication API → Authentication operations: delegates
- Appointment operations → Appointment repository: reads and writes (evidence: `src/main/java/com/project/MediFlow/Service/Impl/AppointmentServiceImpl.java`)
- Appointment operations → Doctor repository: queries (evidence: `src/main/java/com/project/MediFlow/Service/Impl/AppointmentServiceImpl.java`)
- Appointment operations → Patient repository: queries (evidence: `src/main/java/com/project/MediFlow/Service/Impl/AppointmentServiceImpl.java`)
- Appointment operations → Availability repository: checks slots (evidence: `src/main/java/com/project/MediFlow/Service/Impl/AppointmentServiceImpl.java`)
- Appointment repository → Appointment record: stores (evidence: `src/main/java/com/project/MediFlow/Repository/AppointmentRepository.java`)
- Doctor repository → Patient and doctor records: stores doctor
- Patient repository → Patient and doctor records: stores patient (evidence: `src/main/java/com/project/MediFlow/Repository/PatientRepository.java`)
- Availability repository → Doctor availability record: stores (evidence: `src/main/java/com/project/MediFlow/Repository/DoctorAvailabilityRepository.java`)
- Appointment operations → Appointment producer: publishes event (evidence: `src/main/java/com/project/MediFlow/Service/Impl/AppointmentServiceImpl.java`)
- Appointment producer → Appointment event: creates payload
- Appointment producer → RabbitMQ: publishes
- RabbitMQ → Notification consumer: dispatches
- Notification consumer → Appointment email: sends email
- Notification consumer → Notification state: tracks delivery
- Authentication operations → JWT service: creates token (evidence: `src/main/java/com/project/MediFlow/Service/Impl/AuthServiceImpl.java`)
- Appointment operations → PostgreSQL: persists appointments
- Patient operations → PostgreSQL: persists patients
- Availability operations → PostgreSQL: persists availability
