How kenji-34/cab302-project works
1. Overall shape
- This is a Java 21 / Maven JavaFX desktop application for studying sessions.
- The app is organized around a UI layer driven by FXML screens, a small domain layer for timers/users/sessions, and a SQLite-backed persistence layer.
2. Primary runtime flow
- The entry point is com.studytimer.studytimerapp.
- Typical flow is: login/create account → main timer screen → session tracking/history/settings.
- UI navigation is controller-driven and screen-based, not web-based.
3. Presentation layer
- controller/ contains the main JavaFX controllers:
- logincontroller, createusercontroller, resetpasswordcontroller
- TimerController
- SessionHistoryController
- SettingsController
- The UI is defined in src/main/resources/com/studytimer/*.fxml with shared styling in style.css.
4. Timer and session control
- TimerLogic and AppState are the core state/behavior classes behind the study timer.
- TimerController is the orchestration point for:
- manual start/pause/end session actions
- automatic pause/resume behavior based on presence detection
- updating the timer UI state
5. Computer-vision / AI boundary
- The README says the app uses OpenCV Haar Cascade face detection to start/pause the timer automatically.
- The repo includes haarcascade_frontalface_default.xml plus a python/ directory with server.py and model files (best.pt, yolov8n.pt), suggesting a separate or experimental vision subsystem outside the main Java controllers.
- Architecturally, this is the main external sensing boundary: webcam frames are processed in the background, and the timer reacts to “face detected / not detected” events.
6. User and authentication model
- user/ holds the account domain:
- User
- UserManager
- UserSettings
- UserDAO
- UserSettingsDAO
- encrypt/PasswordEncrypt handles password hashing/encryption before persistence.
- These classes isolate authentication and preferences from the UI controllers.
7. Persistence layer
- database/DatabaseConnection is the low-level DB gateway.
- study_app.db at the repo root indicates SQLite is the backing store.
- session/StudySession and StudySessionDAO persist study-session records for history views.
- UserDAO and UserSettingsDAO persist identity and per-user configuration.
8. Secondary features
- audio/MusicPlayer provides background study music playback; the MP3 asset lives under src/main/resources/com/studytimer/audio/.
- speech/TextToSpeechController and TextToSpeechGui add a TTS-related feature set, likely as an auxiliary tool rather than part of the core timer loop.
- These are side services that the UI can invoke, but they are not the central application flow.
9. Localization and app-wide state
- LanguageManager suggests the UI is localized or at least has language-string management.
- AppState appears to be a shared state holder used across screens/controllers, likely for current user/session/UI mode.
10. Resources and assets
- The app is mostly resource-driven: FXML layouts, CSS, audio, and OpenCV classifier data are packaged into src/main/resources.
- This makes the JavaFX screens and the detection model part of the deployable artifact, not external runtime dependencies.
11. Testing structure
- Tests cover the most important boundaries:
- DB connectivity and DAOs
- UserManager
- LanguageManager
- AppState
- TimerController
- keyboard bindings
- That suggests the architecture is intentionally split so logic can be tested outside the JavaFX runtime where possible.
12. Build and delivery
- The project is built with Maven, with helper scripts for Windows and Unix (build.bat, build.sh) and GitHub Actions in .github/workflows/build.yml.
- The presence of target/ artifacts shows the app is packaged as a standard Maven build output, likely a runnable JAR plus JavaFX resources.
13. Best way to diagram it
- The clean architectural diagram would show:
- JavaFX UI/controllers
- domain logic for timer/users/sessions
- SQLite persistence
- webcam/vision detection as an asynchronous external input
- optional audio/TTS side services
- The key data flow is: user action or face detection event → controller/timer logic → state update → persistence/UI refresh.
Main entry points: TimerController.java Timer screen · UserManager.java User manager · StudySessionDAO.java Session DAO · logincontroller.java Login
Components 23
Application
JavaFX entry and shared runtime state
Presentation
FXML screens and JavaFX controllers
- Login · User sign-in screen and navigation
src/main/java/com/studytimer/controller/logincontroller.java - Create user · Account creation flow
src/main/java/com/studytimer/controller/createusercontroller.java - Reset password · Password reset flow
src/main/java/com/studytimer/controller/resetpasswordcontroller.java - Timer screen · Main study timer orchestration and UI updates
src/main/java/com/studytimer/controller/TimerController.java - Session history · Displays past study sessions
src/main/java/com/studytimer/controller/SessionHistoryController.java - Settings · User preferences and app settings screen
src/main/java/com/studytimer/controller/SettingsController.java
Domain
Timer, users, language, and study-session rules
- Timer logic · Core timer behavior and study-session state transitions
src/main/java/com/studytimer/TimerLogic.java - User manager · Coordinates authentication and user updates
src/main/java/com/studytimer/user/UserManager.java - User · Identity and account data
src/main/java/com/studytimer/user/User.java - User settings · Per-user configuration
src/main/java/com/studytimer/user/UserSettings.java - Study session · Recorded study-session data
src/main/java/com/studytimer/session/StudySession.java - Language manager · Language and UI text management
src/main/java/com/studytimer/LanguageManager.java
Persistence
SQLite gateway and DAOs
- DB connection · Low-level SQLite connection access
src/main/java/com/studytimer/database/DatabaseConnection.java - User DAO · Persists user identity records
src/main/java/com/studytimer/user/UserDAO.java - Settings DAO · Persists per-user preferences
src/main/java/com/studytimer/user/UserSettingsDAO.java - Session DAO · Persists study-session history
src/main/java/com/studytimer/session/StudySessionDAO.java - Password encrypt · Hashes or encrypts passwords before storage
src/main/java/com/studytimer/encrypt/PasswordEncrypt.java
Sensing
Webcam/vision boundary that drives auto pause/resume
- Vision server · Separate or experimental webcam/ML processing boundary
python/server.py - Face cascade · Haar cascade classifier used for face detection
src/main/resources/haarcascade_frontalface_default.xml
Side services
Auxiliary audio and text-to-speech features
- Music player · Background study music playback
src/main/java/com/studytimer/audio/MusicPlayer.java - Text to speech · Auxiliary TTS UI and controller
src/main/java/com/studytimer/speech/TextToSpeechController.java
Connections 25
- App entry → Login: opens · Bootstraps initial authentication screen
- App entry → Timer screen: navigates · Loads the main timer screen after authentication
- Login → User manager: authenticates · Delegates sign-in checks to account logic
- Create user → User manager: creates · Creates new accounts through the user service
- Reset password → User manager: updates · Resets credentials through account logic
- Timer screen → Timer logic: drives · Starts, pauses, and ends study sessions
- Timer screen → App state: reads/writes · Synchronizes UI with shared app state
- Timer screen → Session DAO: records · Persists completed sessions and history entries
- Session history → Session DAO: loads · Reads session history for display
- Settings → User manager: persists · Applies user preference changes
- User manager → User DAO: uses · Stores and retrieves user records
- User manager → Settings DAO: uses · Stores and retrieves user settings
- User DAO → DB connection: connects · Uses the shared SQLite gateway
- Settings DAO → DB connection: connects · Uses the shared SQLite gateway
- Session DAO → DB connection: connects · Uses the shared SQLite gateway
- User manager → Password encrypt: hashes · Encrypts passwords before persistence
- Login → Language manager: localizes · Uses language strings for UI text
- Settings → Language manager: configures · Changes language-related preferences
- Timer screen → Vision server: reacts to · Consumes face-detection events for auto pause/resume
- Vision server → Face cascade: loads · Face detection classifier model
- Timer screen → Music player: controls · Starts and stops background music
- Timer screen → Text to speech: invokes · Opens or uses speech features from the UI
- Study session → Session DAO: stored by · Study sessions are persisted through the DAO
- User → User DAO: stored by · User identities flow through the user DAO
- User settings → Settings DAO: stored by · Preferences flow through the settings DAO