HILIGTHer_FLIM_DigitalTwin

Architecture Intent Map: HILIGHTer Digital Twin

Product Intent

HILIGHTer is now a Python-first desktop engineering workspace for virtual FLIM instrument design, precision benchmarking, synthetic-image validation, and automation. The repository no longer carries active MATLAB application code. The desktop Qt workspace, backend service layer, HTTP API, MCP server, and export/reporting features all share one computational engine.

The core product goals are:

The current product intent also includes:

Sanitised Workspace Layout

The repository is organised around the active Python application:

There are no active MATLAB source trees, .m launchers, or MATLAB project metadata in the main workspace any longer.

Architectural Principles

1. One Core Engine

All physics, fitting, phasor, optimisation, and storage logic should live in the Python backend once and be reused everywhere else.

2. Simulation-First

The main workflows are synthetic precision studies, validation-image studies, and instrument optimisation. File import remains a compatibility utility, not the product center.

3. Desktop-First, API-Complete

The Qt workspace is the primary operator experience, but every major workflow must remain scriptable through the service API, HTTP API, desktop automation API, and MCP server.

4. Workspace Persistence

Users should be able to save and load full workspaces, not only export plots. Instrument profiles, controller state, generated data, and derived maps must persist in a forward-compatible format.

Layered Architecture

Layer Main Module Intent
Physics Engine python/backend/twin_engine.py Excitation modelling, decay PDFs, gate distillation, Fisher estimation, Monte Carlo, validation-image generation, fitting, pixel payloads, and phasor products.
Shared Models python/backend/models.py Configuration and lightweight application state objects shared across the stack.
Decay Model Registry python/backend/decay_model_store.py Built-in and custom decay-model metadata, parameter definitions, sweep defaults, and persisted custom expressions.
Service Layer python/backend/service_api.py Stable workflow orchestration for scripts, tests, APIs, and automation.
Storage Layer python/backend/storage.py Workspace persistence and restoration.
Profile Store python/backend/profile_store.py Instrument profile load/save/import/export/migration helpers.
HTTP API python/backend/main.py Remote REST access to backend workflows and data products.
Desktop Workspace python/gui/main_window.py and widgets Controller-driven Qt application for simulation, validation, optimisation, and export.
Browser Frontend python/frontend/ React/Vite client that consumes a subset of the HTTP API and mirrors backend outputs in the browser.
Desktop Automation python/gui/automation_api.py Programmatic control of the live Qt workspace.
MCP Server python/mcp_server.py Tool/resource/prompt bridge for LLM hosts.
Documentation docs/ Architecture, operator manual, API guidance, and benchmark notes.

Workflow Intent

Precision Workflow

The precision workflow produces:

Validation-Image Workflow

The validation-image workflow produces:

The desktop view preset for this workflow is:

Optimisation Workflow

The optimisation workflow is integrated into the main desktop workspace. It should support:

Throughput-style optimisation objectives should be evaluated in the all-photon basis internally, even when the operator chooses a different Fisher reporting basis for display. This keeps rate-driven comparisons coherent under collection losses, dead time, and pile-up. For count-rate optimisation, throughput selection should also honor an explicit estimator-accuracy guard rather than simply preferring the highest scanned rate, and the search should refine around the feasible boundary instead of relying on a single fixed grid.

State Intent

The backend configuration object is the single source of truth for:

The GUI must mirror this state rather than maintaining a separate hidden model.

Batch-sweep default value sets are persisted as profile-style JSON data under python/profiles/batch_sweeps/. The installation snapshot in defaults.install.json is the immutable reset target, while defaults.current.json is the editable runtime copy used by the Batch Sweep tab for load, save, import, export, and reset operations.

Testing Intent

The cleaned repository should be validated with:

Benchmark comparisons against legacy reports can still exist as documentation or optional utility scripts, but they are not a separate application tier.

Documentation Intent

The HTML manual should always describe the current Python workspace, including: