Demo Mode¶
Demo mode is a runtime behavior of the web application. It is distinct from the existence of demo data in DynamoDB and S3.
There are two separate concepts:
DEMO_MODEcontrols whether the webapp is running in demo mode.DEMO_COURSE_IDidentifies which course contains the demo dataset.
The important rule is:
DEMO_COURSE_IDby itself does not enable demo mode.
How Demo Mode Is Enabled¶
PlantTracer runs in demo mode when either of these conditions is true:
the process environment contains
DEMO_MODEthe incoming request host has a hostname label ending in
-demo
Examples:
DEMO_MODE=1in the process environment enables demo modesimsong-demo.planttracer.comenables demo mode because the hostname contains a-demolabelsimsong.planttracer.comis not demo mode unlessDEMO_MODEis set
This allows a deployment such as:
simsong.planttracer.comfor normal modesimsong-demo.planttracer.comfor demo mode
with both names pointing at the same VM.
What DEMO_COURSE_ID Means¶
DEMO_COURSE_ID identifies the course that contains the demo data. In local
development the Makefile seeds demo-course.
Today the runtime switch for demo behavior is DEMO_MODE or the -demo
hostname rule. DEMO_COURSE_ID is still useful because it names the demo
course dataset used by local setup and deployment conventions.
Behavior in Demo Mode¶
When the app is in demo mode:
anonymous users are treated as the demo user
get_user_api_key()returns the fixed demo API keythe UI hides mutating actions such as upload and many editing controls
Flask passes
demo_mode=Trueinto Jinja templatesthe browser receives the global JavaScript constant
demo_mode = true
In other words, demo mode is not just “logged in as the demo user.” It is a separate application mode that changes authentication and UI behavior.
Local Development¶
The local Make targets intentionally separate “demo data exists” from “the app is running in demo mode”:
make make-local-demoSeeds the local database and bucket with the demo course, demo user, and demo movies.make run-local-debugStarts Flask against the local dataset in non-demo mode. It explicitly clearsDEMO_MODEandDEMO_COURSE_IDand prints a login link for the local admin user.make run-local-demo-debugStarts Flask in demo mode. It setsDEMO_MODE=1andDEMO_COURSE_ID=demo-coursebefore starting Flask. No login link is required because demo mode auto-authenticates as the demo user.
Rendering and UI¶
The server exposes demo mode to both Jinja and JavaScript:
Jinja template variable:
demo_modeJavaScript global constant:
demo_mode
Templates can use Jinja conditionals to render a clear demo-mode indicator. Client-side code can use the JavaScript constant to disable or hide controls.
Troubleshooting¶
PlantTracer stores login state in an api_key cookie. If you switch between
normal mode and demo mode in the same browser session, stale cookies can make
local testing confusing. If that happens, clear the browser cookie and reload.