A rebuilt dashboard using FastAPI backend + vanilla HTML/CSS/JS frontend. Runs alongside the existing Streamlit dashboard — zero risk to the live system.
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
conda activate flowmeter_env
pip install fastapi uvicorn
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.
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).
- Old: http://localhost:8501 (Streamlit)
- New: http://localhost:8502 (FastAPI)
Both read from the same database and show the same data in real time.
When you're confident v2 is better:
- Update the desktop shortcut to point at
http://localhost:8502 - Optionally stop the old service to free up resources:
nssm stop FlowMeterDashboard - 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
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\dashboard_v2_stdout.log— uvicorn access log + app printslogs\dashboard_v2_stderr.log— errorslogs\fetcher_stdout.log— unchanged (shared with v1)
Backend:
- Reuses existing
db.py,alerts.py,config_loader.pyunchanged - 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
- 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.