# tinubaby006/smart_healthcare_system architecture

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

- Interactive diagram: https://gitdiagram.com/tinubaby006/smart_healthcare_system
- Repository: https://github.com/tinubaby006/smart_healthcare_system

## Overview

1. This repository is a desktop healthcare management application built around a classic layered Java structure: Swing UI at the top, service classes in the middle, and JDBC/MySQL persistence at the bottom. The main runtime is a local Java application, not a web service.

2. The entry point is `src/main/Main.java`, which likely boots the application and opens the initial screen, most likely `LoginFrame`. From there, users are routed into role-specific dashboards based on authentication results.

3. The presentation layer lives under `src/ui` and is the largest visible subsystem. It contains separate Swing frames for login, admin, doctor, and patient workflows, plus task-specific screens such as adding patients, booking appointments, viewing patients, managing appointments, and viewing medical history. This strongly suggests the UI is organized as independent windows rather than a single SPA-style shell.

4. Authentication and role routing are handled by `src/service/LoginService.java`, with separate dashboards for admin, doctor, and patient. The architecture implies a role-based access model where the login flow determines which features and screens are exposed.

5. Business logic is split into focused service classes: `PatientService`, `DoctorService`, `AppointmentService`, and `MedicalHistoryService`. These act as the application’s orchestration layer, encapsulating operations such as creating patients, booking or managing appointments, and recording diagnosis/treatment history.

6. The domain model appears to be intentionally lightweight. The `src/model` package includes `Patient.java` plus legacy-looking files `model.java` and other similarly named classes, suggesting the app uses simple Java objects to transfer data between services, database access, and UI components rather than a heavy framework or ORM.

7. Persistence is handled through direct database access in `src/db/DBConnection.java` and `src/db/db.java`. This indicates plain JDBC rather than Hibernate/JPA. The architecture is therefore tightly coupled to MySQL schema design and SQL queries, with the connection utility serving as the shared infrastructure boundary.

8. The database is a central part of the system design. `database.sql` and the README describe tables for `users`, `patients`, `doctors`, `appointments`, and `medical_history`. The data model is relational, with appointments linking doctors and patients and medical history linked back to patient/visit records.

9. The main data flows are straightforward: a user logs in through the Swing UI, the login service validates credentials against the database, then the app opens a role dashboard. From there, each workflow calls into the relevant service, which reads or writes through JDBC and updates the UI with the resulting records.

10. The role boundaries are important for any architecture diagram. Admin functions focus on patient registration and appointment management; doctor functions focus on approved appointments and medical history entry; patient functions focus on viewing appointments and history. These are separate feature areas, but they share the same underlying data store and service layer.

11. There is no evidence of external services, background workers, or distributed components. The system is a single-process desktop application with synchronous database calls, which makes the architecture simple: UI event → service logic → JDBC/database → UI refresh.

12. In short, the repo is best diagrammed as a three-tier Swing/JDBC application with role-based screens on top, a service layer in the middle, and a MySQL-backed relational schema beneath. The key architectural boundary is between UI interaction and persistence, mediated by the service classes.

Main entry points: [`src/db/DBConnection.java`](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/db/DBConnection.java) (DB Connection), [`src/service/LoginService.java`](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/LoginService.java) (Login Service), [`src/ui/AdminDashboard.java`](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/AdminDashboard.java) (Admin Dashboard), [`src/service/PatientService.java`](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/PatientService.java) (Patient Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_main(("Main<br/>entrypoint<br/>[Main.java]"))
end

subgraph group_ui["Presentation"]
  node_login_ui["Login<br/>swing frame<br/>[LoginFrame.java]"]
  node_admin_dash["Admin Dashboard<br/>swing frame"]
  node_doctor_dash["Doctor Dashboard<br/>swing frame"]
  node_patient_dash["Patient Dashboard<br/>swing frame"]
  node_add_patient["Add Patient<br/>swing frame"]
  node_book_appointment["Book Appointment<br/>swing frame"]
  node_manage_appointments["Manage Appointments<br/>swing frame"]
  node_view_patients["View Patients<br/>swing frame"]
  node_doctor_appointments["Doctor Appointments<br/>swing frame"]
  node_add_history["Add History<br/>swing frame"]
  node_patient_appointments["Patient Appointments<br/>swing frame"]
  node_patient_history["Patient History<br/>swing frame"]
end

subgraph group_service["Services"]
  node_login_service["Login Service<br/>auth service<br/>[LoginService.java]"]
  node_patient_service["Patient Service<br/>domain service"]
  node_doctor_service["Doctor Service<br/>domain service<br/>[DoctorService.java]"]
  node_appointment_service["Appointment Service<br/>domain service"]
  node_history_service["History Service<br/>domain service"]
end

subgraph group_domain["Domain"]
  node_patient_model["Patient<br/>data object<br/>[Patient.java]"]
  node_legacy_model["Legacy Model<br/>data object<br/>[model.java]"]
end

subgraph group_db["Persistence"]
  node_db_connection[("DB Connection<br/>jdbc utility<br/>[DBConnection.java]")]
  node_db_legacy[("DB Helper<br/>jdbc utility<br/>[db.java]")]
  node_schema[("Schema<br/>[database.sql]")]
end

node_main -->|"opens"| node_login_ui
node_login_ui -->|"authenticates"| node_login_service
node_login_service -->|"queries"| node_db_connection
node_login_service -->|"routes admin"| node_admin_dash
node_login_service -->|"routes doctor"| node_doctor_dash
node_login_service -->|"routes patient"| node_patient_dash
node_admin_dash -->|"launches"| node_add_patient
node_admin_dash -->|"launches"| node_manage_appointments
node_admin_dash -->|"launches"| node_view_patients
node_add_patient -->|"creates"| node_patient_service
node_view_patients -->|"reads"| node_patient_service
node_doctor_dash -->|"launches"| node_doctor_appointments
node_doctor_dash -->|"launches"| node_add_history
node_doctor_appointments -->|"loads"| node_appointment_service
node_add_history -->|"records"| node_history_service
node_patient_dash -->|"launches"| node_patient_appointments
node_patient_dash -->|"launches"| node_patient_history
node_patient_appointments -->|"reads"| node_appointment_service
node_patient_history -->|"reads"| node_history_service
node_patient_service -->|"uses"| node_patient_model
node_patient_service -->|"persists"| node_db_connection
node_doctor_service -->|"queries"| node_db_connection
node_appointment_service -->|"persists"| node_db_connection
node_history_service -->|"persists"| node_db_connection
node_db_connection -->|"connects to"| node_schema
node_db_legacy -->|"connects to"| node_schema
node_legacy_model -->|"used by"| node_db_legacy

click node_main "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/main/Main.java"
click node_login_ui "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/LoginFrame.java"
click node_admin_dash "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/AdminDashboard.java"
click node_doctor_dash "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/DoctorDashboard.java"
click node_patient_dash "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/PatientDashboard.java"
click node_add_patient "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/AddPatientFrame.java"
click node_book_appointment "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/BookAppointmentFrame.java"
click node_manage_appointments "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/ManageAppointmentsFrame.java"
click node_view_patients "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/ViewPatientsFrame.java"
click node_doctor_appointments "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/DoctorAppointmentsFrame.java"
click node_add_history "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/AddMedicalHistoryFrame.java"
click node_patient_appointments "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/PatientAppointmentsFrame.java"
click node_patient_history "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/PatientHistoryFrame.java"
click node_login_service "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/LoginService.java"
click node_patient_service "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/PatientService.java"
click node_doctor_service "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/DoctorService.java"
click node_appointment_service "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/AppointmentService.java"
click node_history_service "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/MedicalHistoryService.java"
click node_patient_model "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/model/Patient.java"
click node_legacy_model "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/model/model.java"
click node_db_connection "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/db/DBConnection.java"
click node_db_legacy "https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/db/db.java"
click node_schema "https://github.com/tinubaby006/smart_healthcare_system/blob/main/database.sql"

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_main toneBlue
class node_login_ui,node_admin_dash,node_doctor_dash,node_patient_dash,node_add_patient,node_book_appointment,node_manage_appointments,node_view_patients,node_doctor_appointments,node_add_history,node_patient_appointments,node_patient_history toneAmber
class node_login_service,node_patient_service,node_doctor_service,node_appointment_service,node_history_service toneMint
class node_patient_model,node_legacy_model toneRose
class node_db_connection,node_db_legacy,node_schema toneIndigo
```

## Components

### Runtime

Desktop application entry and startup flow

- [Main](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/main/Main.java): entrypoint · Application bootstrap and initial screen launch · `src/main/Main.java`

### Presentation

Swing frames for role-based workflows

- [Login](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/LoginFrame.java): swing frame · Authentication screen and first user entry point · `src/ui/LoginFrame.java`
- [Admin Dashboard](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/AdminDashboard.java): swing frame · Admin workspace for managing clinic data · `src/ui/AdminDashboard.java`
- [Doctor Dashboard](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/DoctorDashboard.java): swing frame · Doctor workspace for appointments and history · `src/ui/DoctorDashboard.java`
- [Patient Dashboard](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/PatientDashboard.java): swing frame · Patient workspace for viewing appointments and history · `src/ui/PatientDashboard.java`
- [Add Patient](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/AddPatientFrame.java): swing frame · Patient registration form · `src/ui/AddPatientFrame.java`
- [Book Appointment](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/BookAppointmentFrame.java): swing frame · Appointment creation form · `src/ui/BookAppointmentFrame.java`
- [Manage Appointments](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/ManageAppointmentsFrame.java): swing frame · Admin appointment control screen · `src/ui/ManageAppointmentsFrame.java`
- [View Patients](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/ViewPatientsFrame.java): swing frame · Patient list and lookup screen · `src/ui/ViewPatientsFrame.java`
- [Doctor Appointments](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/DoctorAppointmentsFrame.java): swing frame · Doctor view of assigned appointments · `src/ui/DoctorAppointmentsFrame.java`
- [Add History](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/AddMedicalHistoryFrame.java): swing frame · Medical history entry form · `src/ui/AddMedicalHistoryFrame.java`
- [Patient Appointments](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/PatientAppointmentsFrame.java): swing frame · Patient view of appointment records · `src/ui/PatientAppointmentsFrame.java`
- [Patient History](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/ui/PatientHistoryFrame.java): swing frame · Patient view of medical history · `src/ui/PatientHistoryFrame.java`

### Services

Application logic and role routing

- [Login Service](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/LoginService.java): auth service · Validates credentials and routes by role · `src/service/LoginService.java`
- [Patient Service](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/PatientService.java): domain service · Patient creation and retrieval logic · `src/service/PatientService.java`
- [Doctor Service](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/DoctorService.java): domain service · Doctor-centric workflow logic · `src/service/DoctorService.java`
- [Appointment Service](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/AppointmentService.java): domain service · Appointment booking and management logic · `src/service/AppointmentService.java`
- [History Service](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/service/MedicalHistoryService.java): domain service · Medical history recording and retrieval logic · `src/service/MedicalHistoryService.java`

### Domain

Lightweight data objects used across layers

- [Patient](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/model/Patient.java): data object · Patient record passed between layers · `src/model/Patient.java`
- [Legacy Model](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/model/model.java): data object · Additional lightweight model class · `src/model/model.java`

### Persistence

JDBC access and relational schema

- [DB Connection](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/db/DBConnection.java): jdbc utility · Shared database connection helper · `src/db/DBConnection.java`
- [DB Helper](https://github.com/tinubaby006/smart_healthcare_system/blob/main/src/db/db.java): jdbc utility · Additional database access utility · `src/db/db.java`
- [Schema](https://github.com/tinubaby006/smart_healthcare_system/blob/main/database.sql): mysql schema · Relational tables for users, patients, doctors, appointments, and history · `database.sql`

## Connections

- Main → Login: opens · Application startup shows the login screen
- Login → Login Service: authenticates · Login form validates credentials through the auth service
- Login Service → DB Connection: queries · Authentication reads users from the database
- Login Service → Admin Dashboard: routes admin · Successful admin login opens admin workflow
- Login Service → Doctor Dashboard: routes doctor · Successful doctor login opens doctor workflow
- Login Service → Patient Dashboard: routes patient · Successful patient login opens patient workflow
- Admin Dashboard → Add Patient: launches · Admin can open patient registration
- Admin Dashboard → Manage Appointments: launches · Admin can open appointment management
- Admin Dashboard → View Patients: launches · Admin can browse patient records
- Add Patient → Patient Service: creates · Patient form delegates patient creation
- View Patients → Patient Service: reads · Patient listing loads patient data
- Doctor Dashboard → Doctor Appointments: launches · Doctor dashboard opens appointment view
- Doctor Dashboard → Add History: launches · Doctor dashboard opens history entry
- Doctor Appointments → Appointment Service: loads · Doctor appointment screen reads appointment data
- Add History → History Service: records · History form writes diagnosis and treatment data
- Patient Dashboard → Patient Appointments: launches · Patient dashboard opens appointment view
- Patient Dashboard → Patient History: launches · Patient dashboard opens history view
- Patient Appointments → Appointment Service: reads · Patient appointment screen fetches appointment records
- Patient History → History Service: reads · Patient history screen fetches medical history
- Patient Service → Patient: uses · Patient logic works with patient data objects
- Patient Service → DB Connection: persists · Patient service writes and reads via JDBC
- Doctor Service → DB Connection: queries · Doctor workflow uses shared database access
- Appointment Service → DB Connection: persists · Appointment operations use JDBC connection helper
- History Service → DB Connection: persists · Medical history operations use JDBC connection helper
- DB Connection → Schema: connects to · Connection helper targets the MySQL schema
- DB Helper → Schema: connects to · Legacy helper also accesses the relational schema
- Legacy Model → DB Helper: used by · Legacy model participates in lower-level database access
