How apps in this repo are built. Read this before adding or editing a template.
Each top-level folder is one self-contained Dash app that Plotly Cloud deploys on its own. An app folder must never import from another folder or from the repo root.
<app-folder>/
├── app.py # Dash app; must expose `server = app.server`
├── why_plotly.py # Copy of shared_components/why_plotly.py (do not edit here)
├── requirements.txt # Pinned runtime deps (dash, plotly, gunicorn, ...)
├── requirements-dev.txt# Optional: deps only needed by scripts/ (e.g. rdkit)
├── Procfile # web: gunicorn app:server --workers 2 --timeout 120 --preload
├── .python-version # 3.13
├── .gitignore # __pycache__/, .venv/, .DS_Store
├── plotly-cloud.toml # name / app_id / app_url, written by Plotly Cloud on first publish
├── README.md # What the app shows, where the data comes from, screenshot
├── assets/ # style.css, screenshot.png, logo/svg, clientside JS
├── data/ # Pre-built data files the app reads (if any)
└── scripts/ # Optional: build_data.py etc. that generate data/
Other modules (theme.py, figures.py, data.py, domain logic) sit next to app.py when app.py gets long.
- Stack: Dash (currently
dash==4.4.1), Plotly, Dash Mantine Components +dash-iconifyfor UI,dash-ag-gridfor tables. Pin exact versions inrequirements.txt. - Serving:
server = app.serverinapp.py, and aProcfilerunninggunicorn app:server. Keepif __name__ == "__main__": app.run(debug=True, port=...)for local runs. - Data: the deployed app only reads files in
data/(or fetches from a public URL). Heavy dependencies used to generate data go inrequirements-dev.txtandscripts/, never inrequirements.txt. Synthetic data is fine; say so in the README. - Styling: put CSS in
assets/style.css. Keep chart colours in Python in sync with the CSS (atheme.pyor a constants block at the top ofapp.py). - README: plain description of the question the app answers, what's on screen, how the data was made, what it's built with, and
. - Add the app to the list in the root
README.md.
Every app shows two buttons:
- View source: links to the app's folder on GitHub,
https://github.com/plotly/plotly-cloud-templates/tree/main/<app-folder>. - Why Plotly: opens a drawer with the Dash Enterprise pitch (security, deployment, licensing, comparison table).
Both come from why_plotly.py. It is self-contained: plain dash.html components, one clientside callback (ids prefixed wp-), and CSS scoped under .wp-* that it injects into the page itself. It works with any component library, layout function or multi-page app.
The buttons float bottom-left. Call add_why_plotly once, after app.layout is set:
from why_plotly import add_why_plotly
app.layout = ...
add_why_plotly(app, "<app-folder>")
Use this when the app has its own header bar. Render header_buttons in the header, passing the app's own header-link class so they match its other links, and turn off the floating pair:
from why_plotly import add_why_plotly, header_buttons
header = dmc.AppShellHeader(
dmc.Group([
...,
html.Div(header_buttons("<app-folder>", className="header-btn"), className="header-actions"),
])
)
app.layout = ...
add_why_plotly(app, "<app-folder>", floating=False)
Examples: compound-triage, self-driving.
The second argument must be the app's exact folder name, or the GitHub link will 404.
shared_components/why_plotly.py is the single source of truth. The pitch text (TITLE, QA, COMPARE, ...) is at the top of that file. Never edit an app's copy; edit the shared file, then from the repo root:
python shared_components/sync.py # copy it into every app folder
python shared_components/sync.py --check # list stale copies, exit 1 if any
sync.py writes why_plotly.py into every folder that has an app.py and warns if that app.py doesn't call add_why_plotly().
- Create
<app-folder>/with the layout above. - Run
python shared_components/sync.pyto drop inwhy_plotly.py. - Call
add_why_plotly(app, "<app-folder>")(or the header variant). - Run locally:
pip install -r requirements.txt && python app.py. - Add
assets/screenshot.pngand the README, and list the app in the rootREADME.md. - Publish by uploading the folder at cloud.plotly.com.