How dalrho/daibetes works
1. This repository is split into two main deployable parts: a JavaFX desktop application in java-application and a separate Python AI inference service in python-ai-service. The Java side is the primary user-facing system; the Python side is an internal analysis boundary for model-based diagnosis.
2. The Java application is a modular desktop app built with Java 17+, Maven, JavaFX/FXML, and JDBC/MySQL. module-info.java and the many *.fxml views show a classic UI-driven desktop architecture rather than a web app.
3. The UI is organized around multiple portals and workflows: login/register, doctor dashboard, patient dashboard, image upload/camera capture, image processing, records, results, inbox, and report review. There are also several standalone launcher classes, which suggests each screen or feature can be started independently during development.
4. The newer, more structured code lives under org.example.daibetes, which contains the core architecture. That package is split into core (domain + database), modules (auth, detection, doctor, ai), and shared utilities. The flat top-level packages like login, register, patientsdashboard, and doctorDashboard look like older or parallel UI implementations.
5. The domain layer models the main actors and their relationships: User, Doctor, and Patient, with factory classes for object creation. This aligns with the README’s OOP goal of shared user behavior plus role-specific permissions and attributes.
6. Authentication and registration are isolated in modules/auth, with controller classes for doctor/patient registration and a LoginViewModel. Validation and password handling are centralized in shared/utils, which keeps credential logic out of the UI controllers.
7. Persistence is handled through core/database, which contains a MySQLConnection singleton-style connector plus DAO classes for specific areas such as doctor dashboard, patient dashboard, images, reports, and tests. The presence of generic CRUD helpers (CreateData, RetrieveData, UpdateData, DeleteData) and an SQL script (dbdaibetes.sql) indicates a relational MySQL-backed workflow for users, scans, and diagnostic records.
8. The retinal image pipeline is in modules/detection. It is divided into image preprocessing, camera capture UI, and a scan analysis service. The preprocessing layer uses a decorator-based design (BasePreprocessor, BrightnessDecorator, CLAHEDecorator, DenoiseDecorator, GrayscaleDecorator, ResizeDecorator, SharpenerDecorator), matching the README’s goal of chaining filters dynamically before analysis.
9. The AI boundary is explicit: AIInferenceService on the Java side corresponds to a standalone Python service containing inference_controller.py, dr_classification_service.py, model_loader.py, image_preprocessor.py, and a trained model file (diabetic_retinopathy_full_model.pth). This service is likely where image tensors are prepared and passed through the ML model, while the Java app stays responsible for orchestration and UI.
10. The Python service is layered too: API layer, application services, domain result objects, and infrastructure for preprocessing and loading the model. The presence of gemini_service.py and prompt_builder.py suggests an additional text-generation or narrative-report step alongside classification, which would feed doctor-facing summaries.
11. The doctor workflow appears to be: upload or capture retinal image, preprocess/analyze it, review the AI output, and generate/approve results for the patient. The doctor dashboard, generate-results screen, records, report review, and inbox screens support that approval-and-delivery loop.
12. The patient workflow is separate and simpler: authentication, dashboard access, and viewing finalized diagnosis/results. PatientDashboard*, records, results, and reviewResults form the patient-facing boundary for consuming approved reports rather than generating them.
13. The resource layout reinforces the UI architecture: each screen has its own FXML file, with CSS in styles/ and image assets in resources/images. That makes the architecture highly view-driven, with controllers acting as the glue between the FXML views and the services/DAOs.
14. For an architecture diagram, the key boundaries to show are: JavaFX UI/controllers at the top, domain and service layers in the middle, MySQL persistence below, and the Python AI service off to the side as an external analysis engine. The central business flow is image intake → preprocessing → AI inference → doctor review → stored result delivery to the patient.
Main entry points: auth Auth module · java Desktop UI · detection Detection module · database MySQL layer
Components 20
JavaFX app
Primary desktop application with UI, domain, services, and persistence.
- Desktop UI · Main desktop application surface with multiple screens and launchers.
java-application/src/main/java - Login · Standalone login screen and launcher flow.
java-application/src/main/java/login - Register · Standalone registration flow for account creation.
java-application/src/main/java/register - Doctor dashboard · Doctor-facing portal for reviewing cases and coordinating results.
java-application/src/main/java/org/example/daibetes/modules/doctor/ui - Patient dashboard · Patient-facing portal for viewing finalized information.
java-application/src/main/java/patientsdashboard - Image workflow · Image upload, capture, and processing screens for retinal scans.
java-application/src/main/java/org/example/daibetes/modules/detection/ui - Auth module · Login, registration, and credential coordination.
java-application/src/main/java/org/example/daibetes/modules/auth - Detection module · Retinal image preprocessing, camera capture, and scan analysis.
java-application/src/main/java/org/example/daibetes/modules/detection - Doctor flow · Doctor result-generation and inbox workflow boundary.
java-application/src/main/java/org/example/daibetes/modules/doctor - Domain model · Shared user and role model for doctors and patients.
java-application/src/main/java/org/example/daibetes/core/domain - MySQL layer · Database connection, CRUD helpers, and feature-specific DAOs.
java-application/src/main/java/org/example/daibetes/core/database - Shared utils · Password hashing, validation, and SQL schema support.
java-application/src/main/java/org/example/daibetes/shared/utils - AI client · Java-side bridge to the external Python inference service.
java-application/src/main/java/org/example/daibetes/modules/ai/service/AIInferenceService.java - Login VM · Presentation model used to separate login UI from auth logic.
java-application/src/main/java/org/example/daibetes/modules/auth/viewmodel/LoginViewModel.java - Preprocess chain · Composable image preprocessing filters before analysis.
java-application/src/main/java/org/example/daibetes/modules/detection/imageProcessing/implementations - Scan analysis · Coordinates preprocessing and downstream scan analysis requests.
java-application/src/main/java/org/example/daibetes/modules/detection/service/ScanAnalysisService.java
Python AI service
External inference boundary for model-based diabetic retinopathy analysis.
- Inference API · HTTP entrypoint for model inference requests.
python-ai-service/python/app/api/inference_controller.py - AI services · Classification, prompt building, and optional narrative generation.
python-ai-service/python/app/application - Model runtime · Model loading and image preprocessing infrastructure.
python-ai-service/python/app/infrastructure - Trained model · Saved diabetic retinopathy model used by the service.
python-ai-service/python/models/diabetic_retinopathy_full_model.pth
Connections 24
- Desktop UI → Login: launches · The desktop application includes a dedicated login flow.
- Desktop UI → Register: launches · The desktop application includes a dedicated registration flow.
- Desktop UI → Doctor dashboard: routes to · Doctors enter the review and results workflow from the UI.
- Desktop UI → Patient dashboard: routes to · Patients enter the read-only results workflow from the UI.
- Desktop UI → Image workflow: opens · The UI exposes image upload and capture screens.
- Login → Auth module: uses · Login screens delegate credential work to the auth module.
- Register → Auth module: uses · Registration screens delegate account creation to auth services.
- Auth module → Login VM: binds · Authentication UI is organized around a login view model.
- Auth module → Domain model: creates users · Authentication and registration operate on user role entities.
- Auth module → Shared utils: validates · Credential and input checks are centralized in shared utilities.
- Auth module → MySQL layer: persists · User accounts are stored through DAO-backed database access.
- Image workflow → Detection module: drives · Image upload and camera screens feed the detection pipeline.
- Detection module → Preprocess chain: applies · Image preprocessing is implemented as a decorator chain.
- Detection module → Scan analysis: coordinates · Detection workflows are orchestrated through scan analysis service logic.
- Scan analysis → AI client: calls · Java-side analysis service invokes the external AI boundary.
- AI client → Inference API: requests inference · The Java app sends images or payloads to the Python service.
- Inference API → AI services: dispatches · API requests flow into classification and prompt services.
- AI services → Model runtime: uses · Application services rely on preprocessing and model loading infrastructure.
- Model runtime → Trained model: loads · The service uses the trained retinopathy model artifact.
- Doctor dashboard → Doctor flow: hosts · Doctor dashboard screens belong to the doctor workflow boundary.
- Doctor flow → MySQL layer: reads/writes · Doctor review and result generation persist records through DAOs.
- Patient dashboard → MySQL layer: reads · Patient views are populated from stored records and reports.
- Detection module → MySQL layer: stores scans · Image and diagnostic data are saved via persistence helpers.
- Doctor flow → Patient dashboard: delivers results to · Approved results flow from the doctor workflow to the patient view.