How tinubaby006/smart_healthcare_system works
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: DBConnection.java DB Connection · LoginService.java Login Service · AdminDashboard.java Admin Dashboard · PatientService.java Patient Service
Components 23
Runtime
Desktop application entry and startup flow
- Main · Application bootstrap and initial screen launch
src/main/Main.java
Presentation
Swing frames for role-based workflows
- Login · Authentication screen and first user entry point
src/ui/LoginFrame.java - Admin Dashboard · Admin workspace for managing clinic data
src/ui/AdminDashboard.java - Doctor Dashboard · Doctor workspace for appointments and history
src/ui/DoctorDashboard.java - Patient Dashboard · Patient workspace for viewing appointments and history
src/ui/PatientDashboard.java - Add Patient · Patient registration form
src/ui/AddPatientFrame.java - Book Appointment · Appointment creation form
src/ui/BookAppointmentFrame.java - Manage Appointments · Admin appointment control screen
src/ui/ManageAppointmentsFrame.java - View Patients · Patient list and lookup screen
src/ui/ViewPatientsFrame.java - Doctor Appointments · Doctor view of assigned appointments
src/ui/DoctorAppointmentsFrame.java - Add History · Medical history entry form
src/ui/AddMedicalHistoryFrame.java - Patient Appointments · Patient view of appointment records
src/ui/PatientAppointmentsFrame.java - Patient History · Patient view of medical history
src/ui/PatientHistoryFrame.java
Services
Application logic and role routing
- Login Service · Validates credentials and routes by role
src/service/LoginService.java - Patient Service · Patient creation and retrieval logic
src/service/PatientService.java - Doctor Service · Doctor-centric workflow logic
src/service/DoctorService.java - Appointment Service · Appointment booking and management logic
src/service/AppointmentService.java - History Service · Medical history recording and retrieval logic
src/service/MedicalHistoryService.java
Domain
Lightweight data objects used across layers
- Patient · Patient record passed between layers
src/model/Patient.java - Legacy Model · Additional lightweight model class
src/model/model.java
Persistence
JDBC access and relational schema
- DB Connection · Shared database connection helper
src/db/DBConnection.java - DB Helper · Additional database access utility
src/db/db.java - Schema · Relational tables for users, patients, doctors, appointments, and history
database.sql
Connections 27
- 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