Skip to content

Refactor monolithic front‑end and decouple domain logic #51

Description

@BigSimmo

Problem

  • The clinical dashboard front‑end is a single React component spanning thousands of lines. It imports numerous modules, manages dozens of state variables and effect hooks, and orchestrates query polling, chat interactions, search filtering, content previews and patient‑sheet editing. This monolithic architecture makes the UI difficult to reason about, test and evolve.
  • Business logic such as search filtering, chunk grouping, note‑taking and summarisation is embedded directly in UI components and scripts. This coupling reduces reusability and hampers unit testing.
  • The ingestion worker (worker/main.ts) is ~1200 lines and implements job claiming, document extraction, image captioning, classification, embedding, deep‑memory enrichment and retry logic. Each stage has its own error handling and metrics, increasing the likelihood of hidden bugs and making onboarding difficult.

Recommended refactor

  • Break the dashboard into smaller, domain‑driven components (e.g. search panel, chat panel, document viewer, sheet editor) and extract service calls into custom hooks. This modular approach improves readability and reduces the risk of regressions.
  • Centralise domain functions in reusable modules so they can be unit tested and reused by CLI tools or batch processing tasks.
  • Split the ingestion worker into modular stages (fetch, extract, caption, chunk, embed, persist) with clear interfaces and unit tests for each stage. Isolating these stages will ease maintenance and allow concurrency improvements.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions