This README is a beginner walkthrough for vibe_code_apps_9/diy-bas-primitive: what files do what, how deploy works, how users are configured, where data lives, and how to keep a Raspberry Pi SD card healthy.
- app root:
diy-bas-primitive - Pi bootstrap script:
diy-bas-primitive/bootstrap_pi.sh - Windows deploy script:
diy-bas-primitive/deploy_to_pi.ps1 - environment template:
diy-bas-primitive/.env.example
- Flask backend serves APIs and the vanilla JS frontend.
- Caddy (in Docker mode) fronts the app on port 80.
diy-bascallsdiy-bacnet-serverfor BACnet reads/writes.- Runtime/trend data is persisted under
/var/lib/diy-bason Pi.
cd C:\Users\ben\Documents\py-bacnet-stacks-playground\vibe_code_apps_9\diy-bas-primitive
copy .env.example .env
docker compose up --buildOpen:
http://127.0.0.1/(through Caddy)http://127.0.0.1:5050/(direct Flask, if exposed)
cd C:\Users\ben\Documents\py-bacnet-stacks-playground\vibe_code_apps_9\diy-bas-primitive
.\deploy_to_pi.ps1 -PiHost <pi-ip> -PiUser <pi-user> -UseDockerStack $trueWhat deploy does:
- stages and zips project files
- uploads with
scp - rotates old release to
.bak - ensures
/var/lib/diy-basexists - runs
bootstrap_pi.shin setup mode - starts services and checks
/api/health
Useful options:
-RunBootstrap $falseupload only-StartApp $falsestage + bootstrap only-UseDockerStack $falserun in venv mode-RemoteDir /home/<user>/diy-bas-RemoteBacnetDir /home/<user>/diy-bacnet-server
bootstrap_pi.sh ensures these exist in .env:
DIY_BAS_ADMIN_USERNAME=integratorDIY_BAS_ADMIN_PASSWORD=ChangeMeNow!123DIY_BAS_MAINT_USERNAME=maintenanceDIY_BAS_MAINT_PASSWORD=ChangeMeNow!123
Change all default passwords immediately after first boot.
Important status for this specific diy-bas-primitive codebase:
- The env variables for auth and cookie/session are present in
.env.example. - This primitive app currently does not yet include full login/session enforcement code (
/api/auth/*, Flask-Login guards). - Cookie-related env values are already documented for the auth-enabled build path:
DIY_BAS_SESSION_HOURS=24DIY_BAS_SESSION_COOKIE_SECURE=false(settruebehind HTTPS)DIY_BAS_SESSION_COOKIE_SAMESITE=LaxDIY_BAS_SESSION_REFRESH_EACH_REQUEST=true
When auth-enabled app code is merged in, those settings control session-cookie behavior and default 24-hour lifetime.
- Persistent app data directory on Pi:
/var/lib/diy-bas - Typical data includes discovery files, schedules, latest values, and trends DB files.
- In this primitive version, several runtime artifacts are JSON files plus trend DB storage.
Defaults now favor Pi longevity:
DIY_BAS_TREND_RETENTION_DAYS=30DIY_BAS_AUDIT_RETENTION_DAYS=30DIY_BAS_LOG_RETENTION_DAYS=30DIY_BAS_LATEST_VALUES_FLUSH_SECONDS=300(less frequent writes)DIY_BAS_LOG_TO_FILE=false(prefer stdout/container logs to reduce SD writes)
If you must write file logs, keep retention modest and consider external storage.
- Copy
.env.exampleto.env. - Set strong passwords for integrator and maintenance users.
- Set
DIY_BAS_SECRET_KEYto a long random value. - Keep
DIY_BAS_LOG_TO_FILE=falseunless required. - Run deploy script and confirm
/api/health. - Log in (if auth-enabled build is in use) and verify both roles.
Re-add these files first:
diy-bas-primitive/bootstrap_pi.shdiy-bas-primitive/deploy_to_pi.ps1diy-bas-primitive/.env.example
Then re-run the deploy command in section 4.