Skip to content

deyoyow/flowy

Repository files navigation

Flow Control v2 — Deployment Guide

A rebuilt dashboard using FastAPI backend + vanilla HTML/CSS/JS frontend. Runs alongside the existing Streamlit dashboard — zero risk to the live system.

File layout

Copy the entire v2/ folder into C:\Users\ENGINEERING\Desktop\Flowmeter\:

C:\Users\ENGINEERING\Desktop\Flowmeter\
├── app.py              (existing — Streamlit, unchanged, on :8501)
├── fetcher.py          (existing — Modbus poller, unchanged)
├── db.py               (existing — shared, v2 imports this)
├── config_loader.py    (existing — shared, v2 imports this)
├── alerts.py           (existing — shared, v2 imports this)
├── config.yaml         (existing — shared)
├── flowmeter_data.db   (existing — shared DB, single source of truth)
├── audio/              (existing — sound files, v2 serves from here)
│
└── v2/                 (NEW — the rebuilt dashboard)
    ├── api.py                             # FastAPI backend
    ├── install_services_v2.bat            # NSSM installer
    └── static/
        ├── index.html
        ├── style.css
        ├── app.js
        └── vendor/
            ├── chart.umd.js
            └── chartjs-adapter-date-fns.bundle.min.js

Installation

Step 1 — Install FastAPI in the conda env

conda activate flowmeter_env
pip install fastapi uvicorn

Step 2 — Test manually before installing as a service

cd C:\Users\ENGINEERING\Desktop\Flowmeter\v2
uvicorn api:app --host 0.0.0.0 --port 8502

Open http://localhost:8502 in your browser. You should see the new dashboard. If it looks good, stop it with Ctrl+C.

Step 3 — Install as Windows service

cd C:\Users\ENGINEERING\Desktop\Flowmeter\v2
install_services_v2.bat

This adds FlowMeterDashboardV2 as a new NSSM service on port 8502. It does NOT touch FlowMeterDashboard (Streamlit, on 8501).

Step 4 — Compare side-by-side

Both read from the same database and show the same data in real time.

If you want to switch over permanently

When you're confident v2 is better:

  1. Update the desktop shortcut to point at http://localhost:8502
  2. Optionally stop the old service to free up resources:
    nssm stop FlowMeterDashboard
    
  3. If you want to remove the old Streamlit dashboard entirely (not recommended until you've run v2 for at least a week):
    nssm stop FlowMeterDashboard
    nssm remove FlowMeterDashboard confirm
    

Rollback

If anything goes wrong with v2 at any stage:

nssm stop FlowMeterDashboardV2
nssm remove FlowMeterDashboardV2 confirm

The v1 Streamlit dashboard on 8501 keeps running the entire time. Your data is never at risk — the fetcher, database, config, and original app.py are all unchanged.

Logs

  • logs\dashboard_v2_stdout.log — uvicorn access log + app prints
  • logs\dashboard_v2_stderr.log — errors
  • logs\fetcher_stdout.log — unchanged (shared with v1)

What changed vs v1

Backend:

  • Reuses existing db.py, alerts.py, config_loader.py unchanged
  • Thin FastAPI wrapper exposing the same queries as JSON endpoints
  • Alert evaluation runs the same rule engine

Frontend:

  • Vanilla HTML/CSS/JS — no Streamlit, no reruns
  • Chart.js for charts (vendored locally, no CDN dependency)
  • Distinct polling cadences: live data 2s, charts 15s, alerts 5s
  • Proper browser-native audio looping (no iframe hack)
  • Full CSS control — no more fighting Streamlit's widget styling
  • Works in any modern browser; tested in headless Chromium

Same features:

  • Two meter cards with Flow/Temperature/Daily Usage tabs
  • Return Flow card with live chart
  • Occupancy manual entry with upsert semantics
  • Consumption vs Occupancy correlation with alignment toggle
  • Alert banner stack with per-alert ACK buttons
  • Sound enable/disable toggle

Known limitations

  • Per-meter CSV export from the old meter card's "Data Table" tab is not yet in v2. If you need it, say so and I'll add it — the API endpoint for it already exists (/api/meter/{id}/export), just needs the UI.
  • Device settings / Reset Totalizer isn't in the UI yet. Same note as above — the API endpoint exists (/api/settings/reset), UI is pending.

These are quick additions if needed; they didn't make the one-afternoon cut.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors