3.2 KiB
3.2 KiB
Architecture
System Overview
The application is a state-driven desktop client with an event-processing pipeline:
- ingest prediction events from MQTT,
- persist accepted values in SQLite,
- evaluate risk based on recent history,
- update UI state and rendering,
- export animation state for external consumers.
Module Structure
vassistent.bootstrap
Application startup/shutdown orchestration (ApplicationInitializer,ApplicationShutdownManager)vassistent.service
Runtime services and integrations (MQTT, persistence, statistics, evaluation, process management)vassistent.model
Core state/data objects (AppState,ProblemLevel,DatabaseEntry,RatioPoint)vassistent.controller
Connects app state/services with Swing viewsvassistent.ui
Window and visual componentsvassistent.util
Configuration loading/validation and logging
Runtime Flow
Startup sequence
App.maininitializes look-and-feel.ApplicationInitializer.initialize()validates config and wires all services.- MQTT subscription is registered on configured topic.
- Optional external processes are started via
ProcessManagerService. - UI window/controller is created on the Swing event thread.
- JVM shutdown hook is registered through
ApplicationShutdownManager.
Event processing sequence
- MQTT message arrives (
MqttClientService.messageArrived). - Payload is routed to
BinaryEventService.handlePayload. - Payload validation checks:
valid == true_idis presentpredictionis0or1- duplicate
_idvs last processed message is rejected
- Accepted value is stored by
DataPersistenceService. EvaluationServicerequests ratio fromStatisticsService.getRatio(20).- Ratio is mapped to a
ProblemLevel. AppStateupdates notify registered listeners.AnimationFileServicewrites the corresponding animation JSON file.
Core Domain Rules
EvaluationService maps ratios to levels:
< 0.5->NONE>= 0.5->WARNING>= 0.8->HIGH>= 0.9->DISASTER
Persistence schema (binary_event):
id(autoincrement primary key)value(0/1)timestamp(ISO local date-time string)
Integration Boundaries
- MQTT: Eclipse Paho client, broker URL and topic from config.
- Database: local SQLite file (
data/health.dbby default). - UI streaming tab: JCEF browser for a configured URL (
streaming.url). - External processes: optional Python simulator and Unreal launcher script.
- Animation output: JSON file written to
animation.output.path.
Shutdown Behavior
ApplicationShutdownManager performs:
- MQTT disconnect,
- managed process shutdown,
- runtime database file deletion (
data/health.db), - logger shutdown.
Architectural Tradeoffs
- Pros
- Clear service boundaries and explicit startup wiring.
- Good testability for service layer and integration logic.
- Configuration validation catches many misconfigurations early.
- Current tradeoffs
- Local database lifecycle is ephemeral by default (deleted on shutdown).
- Startup is tightly coupled to external-process configuration when enabled.
- UI logic is mostly verified indirectly through state and service tests.