docs/architecture/templates-and-dashboards.md

Templates And Dashboards

This slice covers reusable manual-entry templates and user-defined dashboards.

Template Management

flowchart LR
    subgraph UI["UI"]
        MENU["Templates menu"]
        EDITOR["TemplateEditor"]
        DRAWER["Type-specific element drawer"]
        CANVAS["Blank canvas"]
    end

    subgraph API["REST API Gateway"]
        LISTDOSE["POST /dose/elements/list"]
        LISTTEST["POST /test/elements/list"]
        LISTTEMPLATE["POST /user/template"]
        SAVETEMPLATE["POST /user/template/save"]
        DELETETEMPLATE["POST /user/template/delete"]
    end

    subgraph Lambdas["Lambdas"]
        L_DOSE["dose-list-dose-elements"]
        L_TEST["test-list-test-elements"]
        L_LIST["user-entry-template-list"]
        L_SAVE["user-entry-template-save"]
        L_DELETE["user-entry-template-delete"]
    end

    subgraph Data["DynamoDB"]
        DOSEE["env-dose-element"]
        TESTE["env-test-element"]
        TEMPLATE["env-user-entry-template"]
    end

    MENU --> EDITOR
    EDITOR --> DRAWER
    DRAWER --> LISTDOSE --> L_DOSE --> DOSEE
    DRAWER --> LISTTEST --> L_TEST --> TESTE
    EDITOR --> LISTTEMPLATE --> L_LIST --> TEMPLATE
    CANVAS --> SAVETEMPLATE --> L_SAVE --> TEMPLATE
    EDITOR --> DELETETEMPLATE --> L_DELETE --> TEMPLATE

Template Consumers

flowchart TB
    TEMPLATE["env-user-entry-template"] --> TEST["Manual test add/edit"]
    TEMPLATE --> DOSE["Dose history add/edit"]
    TEMPLATE --> PROGRAM["Program history add/edit"]

    TEST --> TESTSAVE["POST /test/history/save"]
    DOSE --> DOSESAVE["POST /dose/history/save"]
    PROGRAM --> PROGSAVE["POST /program/history/save"]

Dashboard Management

flowchart LR
    subgraph UI["UI"]
        HOME["Home dashboard"]
        ANALYTICS["Canned analytics board"]
        STABILITY["Reef Stability"]
        RISK["Focused Element Watchlist"]
        CORRECTIONS["Correction Progress"]
        FOLLOWUP["ICP Follow-Up Dashboard"]
        DRAFTQ["Draft Quality"]
        DASHEDIT["Dashboard editor"]
        DRAWER["Test picker drawer"]
        CARD["Custom chart card"]
        RAW["Raw data modal"]
    end

    subgraph API["REST API Gateway"]
        LISTDASH["POST /user/dashboard"]
        SAVEDASH["POST /user/dashboard/save"]
        DELETEDASH["POST /user/dashboard/delete"]
        LISTTEST["POST /test/elements/list"]
        LISTDOSE["POST /dose/elements/list"]
        LISTTESTH["POST /test/history/list"]
        LISTDOSEH["POST /dose/history/list"]
        LISTREVIEWS["POST /user/reef-reviews"]
    end

    subgraph Lambdas["Lambdas"]
        L_LISTDASH["user-dashboard-list"]
        L_SAVEDASH["user-dashboard-save"]
        L_DELETEDASH["user-dashboard-delete"]
        L_LISTTEST["test-list-test-elements"]
        L_LISTDOSE["dose-list-dose-elements"]
        L_LISTTESTH["test-list-test-history"]
        L_LISTDOSEH["dose-list-dose-history"]
        L_REVIEWS["reef-review"]
    end

    subgraph Data["DynamoDB"]
        DASH["env-user-dashboard"]
        GOLD["env-gold-tank-element-summary"]
        REVIEWS["env-reef-review"]
        TESTE["env-test-element"]
        DOSEE["env-dose-element"]
        TESTH["env-test-history"]
        DOSEH["env-dose-history"]
    end

    HOME --> LISTDASH --> L_LISTDASH --> DASH
    LISTDASH --> L_LISTDASH --> GOLD
    HOME --> LISTREVIEWS --> L_REVIEWS --> REVIEWS
    HOME --> ANALYTICS
    ANALYTICS --> STABILITY
    ANALYTICS --> RISK
    ANALYTICS --> CORRECTIONS
    ANALYTICS --> FOLLOWUP
    ANALYTICS --> DRAFTQ
    DASHEDIT --> LISTDASH
    DASHEDIT --> DRAWER --> LISTTEST --> L_LISTTEST --> TESTE
    CARD --> LISTDOSE --> L_LISTDOSE --> DOSEE
    DASHEDIT --> SAVEDASH --> L_SAVEDASH --> DASH
    DASHEDIT --> DELETEDASH --> L_DELETEDASH --> DASH
    HOME --> LISTTESTH --> L_LISTTESTH --> TESTH
    HOME --> LISTDOSEH --> L_LISTDOSEH --> DOSEH
    CARD --> RAW

Notes

  • Templates are scoped by user, tank, and template type: Test, Dose, or Program.
  • Template editing uses the Tailwind command-center pattern with native controls, a drag/drop item canvas, fixed item cards, and a custom delete confirmation.
  • Dashboards are scoped by user and tank.
  • Basic users can save one dashboard per tank; Pro users can save unlimited dashboards.
  • Dashboard custom charts select a measured test element and up to two dose elements.
  • Dashboard editing uses the Tailwind command-center pattern with native controls, a drag/drop test canvas, per-chart dosing selectors, and a custom delete confirmation.
  • The Home dashboard starts with canned analytics cards for Reef Stability, a focused Element Watchlist, Correction Progress, the ICP Follow-Up Dashboard, and Draft Recommendation Quality.
  • The canned analytics board combines Gold current-state rows, Reef Review actions/decisions/outcomes, full tank test/dose history, and measured/dosed trend points. The chart date range controls the chart view; canned analytics keep full tank context so risk and follow-up cards are not accidentally narrowed by a short visual range.
  • The focused Element Watchlist defaults to high-value reef signals such as Copper, Tin, Aluminum, Iodine, Iron, Manganese, Selenium, Vanadium, Phosphate/Phosphorus, and Nitrate. Each row presents current value, target range, direction, risk, last action, and predicted next status.
  • The ICP Follow-Up Dashboard turns HILT capture into visible feedback by comparing what RaM recommended, what the user applied, which draft was linked, what the next ICP showed, and whether the recommendation helped, hurt, or remains inconclusive.
  • Consumption vs Replacement and dose-response signals are still derived from measured/dosed trend points plus Gold response status, but they feed the focused watchlist instead of rendering as separate duplicate cards.
  • Chart clicks can navigate to the relevant test-history or dose-history record.