Skip to content

pip-install-python/Dash-Documentation-Boilerplate

Repository files navigation

Dash Documentation Boilerplate

A modern, responsive documentation system for Dash applications built with Dash Mantine Components

Dash DMC Backends Python License: MIT

A comprehensive boilerplate for creating beautiful, interactive documentation for your Dash components, data science workflows, and applications. Features markdown-driven content, live code examples, and automatic theme persistence.

Documentation Preview


✨ Features

πŸ“ Markdown-Driven Documentation

  • Write documentation in Markdown with Python integration
  • Custom directives for interactive examples, code highlighting, and component props
  • Automatic page generation from markdown files with frontmatter metadata
  • Table of contents generation for easy navigation

🎨 Modern UI/UX

  • Built with Dash Mantine Components
  • Responsive design for mobile, tablet, and desktop
  • Dark and light theme support with automatic preference persistence
  • Smooth transitions and professional styling
  • Customizable color schemes and theming

πŸ” Developer Experience

  • Hot reload during development
  • Searchable component navigation
  • Syntax highlighting for multiple languages
  • Interactive code examples with live callbacks
  • Component props documentation auto-generation

πŸ€– AI/LLM & SEO Integration

  • LLMS_DOC pattern β€” write a module-level prose string per page; served verbatim at /<page>/llms.txt
  • Multi-backend β€” add_llms_routes(app) auto-detects Flask, FastAPI, or Quart and dispatches to the matching adapter
  • MCP bridge β€” each page's prose registers as a dash.mcp resource on Dash 4.3+ (silent no-op otherwise)
  • SEO β€” sitemap.xml with intelligent priority inference; respects mark_hidden()
  • Bot management β€” training crawlers blocked (configurable), AI search citations allowed, browsers untouched
  • Privacy controls β€” mark_hidden() to exclude pages from sitemap, robots, MCP, and crawler prerender
  • Share with AI β€” paste the app URL into ChatGPT/Claude/etc.; they fetch the prose docs directly
  • Powered by dash-improve-my-llms 2.0

πŸ”Œ Pluggable Backends (Dash 4.x)

  • Run the same app on Flask, FastAPI, or Quart β€” switch with a single DASH_BACKEND environment variable
  • Backend selection centralized in lib/backend.py; a live badge shows which backend is serving the page
  • FastAPI/Quart (ASGI) unlock async callbacks, websocket callbacks, OpenAPI docs, a native JSON API (/api/backend, /api/pages, /healthz), and ASGI middleware
  • Dedicated docs: Pluggable Backends, Backend Deep Dive, and a FastAPI Showcase

πŸ‹ Production Ready

  • Docker and docker-compose support
  • Gunicorn (WSGI) and Uvicorn (ASGI) production servers
  • Optimized for deployment
  • Environment-based configuration

πŸš€ Built With Latest Technologies

  • Dash 4.2.0 - Modern Plotly Dash framework with pluggable backends
  • DMC 2.7.0 - Dash Mantine Components
  • Mantine 8.3.6 - Beautiful React UI library
  • React 18 - Latest React features
  • Python 3.11+ - Modern Python

πŸ“‹ Requirements

System Requirements

  • Python: 3.11 or higher
  • Node.js: 14+ (for npm dependencies)
  • npm: 6+

Python Dependencies

  • dash >= 4.1.0
  • dash-mantine-components >= 2.7.0
  • dash-ag-grid
  • dash-improve-my-llms[flask] >= 2.0.0
  • flask >= 3.0.0 (default backend)
  • plotly >= 5.0.0
  • pandas >= 1.2.3
  • pydantic >= 2.3.0
  • python-frontmatter >= 1.0.0
  • markdown2dash
  • gunicorn >= 21.2.0 (WSGI production server)

Optional backends (install the matching extra to switch off Flask):

pip install "dash[fastapi]"   # FastAPI (ASGI) backend
pip install "dash[quart]"     # Quart (ASGI) backend
# then run with: DASH_BACKEND=fastapi python run.py  (needs uvicorn)

See requirements.txt for the complete list.


πŸš€ Quick Start

1. Clone the Repository

git clone https://github.com/pip-install-python/Dash-Documentation-Boilerplate.git
cd Dash-Documentation-Boilerplate

2. Install Dependencies

Python packages:

pip install -r requirements.txt

Node packages (for DMC frontend components):

npm install

3. Run the Development Server

python run.py

Visit http://localhost:8553 in your browser.

4. Start Documenting!

Create your documentation in the docs folder:

docs/
β”œβ”€β”€ your-component/
β”‚   β”œβ”€β”€ your-component.md     # Markdown documentation
β”‚   └── examples.py           # Python code examples (optional)

πŸ“ Project Structure

dash-documentation-boilerplate/
β”œβ”€β”€ assets/                      # Static assets and CSS
β”‚   β”œβ”€β”€ m2d.css                 # Markdown-to-Dash styling (theme-aware)
β”‚   β”œβ”€β”€ main.css                # Custom styles (theme-aware)
β”‚   └── llms_copy.js            # "Copy for LLM" button handler
β”‚
β”œβ”€β”€ components/                  # Reusable UI components
β”‚   β”œβ”€β”€ appshell.py             # Main app layout with MantineProvider
β”‚   β”œβ”€β”€ header.py               # Header with search and theme toggle
β”‚   β”œβ”€β”€ navbar.py               # Navigation sidebar and drawer
β”‚   └── backend_badge.py        # Badge showing the active backend
β”‚
β”œβ”€β”€ docs/                        # Documentation content
β”‚   β”œβ”€β”€ example/                # Getting Started guide
β”‚   β”œβ”€β”€ directives/             # Custom Directives guide
β”‚   β”œβ”€β”€ interactive-components/ # Callback patterns guide
β”‚   β”œβ”€β”€ data-visualization/     # Theme-aware charts guide
β”‚   β”œβ”€β”€ ai-integration/         # AI/LLM integration (dash-improve-my-llms 2.0)
β”‚   β”œβ”€β”€ backends/               # Pluggable Backends guide
β”‚   β”œβ”€β”€ backend-comparison/     # Flask vs FastAPI vs Quart deep dive
β”‚   └── fastapi-showcase/       # What the FastAPI backend unlocks
β”‚
β”œβ”€β”€ lib/                         # Utility libraries
β”‚   β”œβ”€β”€ constants.py            # App-wide constants (APP_VERSION, colors)
β”‚   β”œβ”€β”€ backend.py              # Backend selection (DASH_BACKEND)
β”‚   β”œβ”€β”€ asgi_middleware.py      # ASGI middleware (FastAPI/Quart)
β”‚   β”œβ”€β”€ asgi_routes.py          # Showcase routes (/healthz, /api/*)
β”‚   β”œβ”€β”€ analytics_tracker.py    # Lightweight visitor analytics
β”‚   └── directives/             # Custom markdown directives
β”‚       β”œβ”€β”€ kwargs.py           # Component props table generator
β”‚       β”œβ”€β”€ source.py           # Source code display directive
β”‚       β”œβ”€β”€ toc.py              # Table of contents directive
β”‚       └── llms_copy.py        # "Copy for LLM" button directive
β”‚
β”œβ”€β”€ pages/                       # Dash multi-page app pages
β”‚   β”œβ”€β”€ home.md                 # Home page content
β”‚   β”œβ”€β”€ home.py                 # Home page layout (exports LLMS_DOC)
β”‚   └── markdown.py             # Dynamic markdown page loader
β”‚
β”œβ”€β”€ templates/
β”‚   └── index.html              # SEO-optimized HTML template
β”‚
β”œβ”€β”€ .gitignore
β”œβ”€β”€ CHANGELOG.md                # Version history and changes
β”œβ”€β”€ Dockerfile                  # Docker container definition
β”œβ”€β”€ docker-compose.yml          # Docker compose configuration
β”œβ”€β”€ package.json                # Node.js dependencies
β”œβ”€β”€ package-lock.json           # Locked npm versions
β”œβ”€β”€ README.md                   # This file
β”œβ”€β”€ requirements.txt            # Python dependencies
└── run.py                      # Application entry point

πŸ“– Usage Guide

Creating Documentation Pages

  1. Create a new folder in the docs/ directory:

    mkdir -p docs/my-component
  2. Create a markdown file with frontmatter:

    ---
    name: My Component
    description: A description of my component
    endpoint: /components/my-component
    icon: mdi:code-tags
    ---
    
    ## My Component
    
    Your documentation content here...
  3. Add interactive examples (optional):

    # docs/my-component/example.py
    import dash_mantine_components as dmc
    
    component = dmc.Button("Click Me!", id="my-button")
  4. Use directives in your markdown:

    .. toc::
    
    .. exec::docs.my-component.example
    
    .. source::docs/my-component/example.py

Custom Markdown Directives

.. toc::

Generates a table of contents from your markdown headings.

.. exec::module.path.to.component

Renders an executable Python component from a module.

.. source::path/to/file.py

Displays source code with syntax highlighting.

.. kwargs::ComponentName

Generates a props documentation table for a component.

.. llms_copy::Page Title

Adds a "Copy for LLM" button that copies the page's /<page>/llms.txt URL to the clipboard for sharing with ChatGPT, Claude, and other AI assistants.

Customizing Themes

Modify lib/constants.py to change the primary color:

PRIMARY_COLOR = "teal"  # Change to any Mantine color

Customize CSS in:

  • assets/main.css - General styling
  • assets/m2d.css - Markdown-specific styling

Theme Persistence

The boilerplate automatically saves user theme preference (light/dark) in localStorage:

  • First visit: Detects browser preference or defaults to light
  • Theme toggle: Saves preference automatically
  • Return visits: Restores saved theme preference

🐳 Docker Deployment

Build the Docker Image

docker build -t dash-docs-boilerplate .

Run with Docker

docker run -p 8550:8550 dash-docs-boilerplate

Visit http://localhost:8550

Using Docker Compose

docker-compose up

The app will be available at http://localhost:8550

Production Deployment

The Docker container uses Gunicorn for production-ready serving:

  • Multiple workers for better performance
  • Automatic worker restart on failure
  • Suitable for production environments

πŸ› οΈ Development

Setting Up Development Environment

  1. Create virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  2. Install dependencies:

    pip install -r requirements.txt
    npm install
  3. Run in debug mode:

    # Modify run.py
    app.run(debug=True, host='0.0.0.0', port='8553')

Adding New Components

  1. Create your component in a separate module
  2. Add documentation in docs/your-component/
  3. The app automatically discovers and registers pages from markdown files
  4. Restart the server to see your new documentation

Modifying the Layout

Main layout components:

  • Header: components/header.py - Logo, search, theme toggle
  • Navbar: components/navbar.py - Sidebar navigation
  • AppShell: components/appshell.py - Overall layout structure

πŸ”§ Configuration

Environment Variables

Create a .env file (optional):

DASH_DEBUG=False
DASH_HOST=0.0.0.0
DASH_PORT=8553
DASH_BACKEND=flask     # flask | fastapi | quart (requires the matching dash extra)

Customization Points

File Purpose
lib/constants.py App-wide constants (colors, titles)
assets/main.css Custom CSS styles
templates/index.html HTML template (for analytics, meta tags)
components/appshell.py Theme configuration, MantineProvider settings

πŸ“š Documentation

User Documentation

  • Getting Started: This README
  • Changelog: See CHANGELOG.md
  • Examples: Check the /docs/example/ folder

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Test thoroughly: Ensure the app runs without errors
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to the branch: git push origin feature/amazing-feature
  7. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guide for Python code
  • Add docstrings to functions and classes
  • Test your changes before submitting
  • Update documentation if adding new features
  • Keep commits atomic and well-described

πŸ› Known Issues & Troubleshooting

Common Issues

Issue: ModuleNotFoundError: No module named 'dash_html_components'

  • Solution: You're on an old version. Update to 1.0.0+ and import from the main package (from dash import html, dcc); 1.0.0 runs on Dash 4.x.

Issue: DASH_BACKEND=fastapi (or quart) fails to start

  • Solution: Install the matching extra β€” pip install "dash[fastapi]" (or [quart]) β€” and serve with an ASGI server (uvicorn). The app falls back to Flask if the backend is unavailable.

Issue: Theme doesn't persist

  • Solution: Check browser localStorage is enabled and not blocked

Issue: npm install fails

  • Solution: Update Node.js to 14+ and npm to 6+

Issue: Port already in use

  • Solution: Change port in run.py or stop the conflicting process

For more issues, check GitHub Issues


πŸ“Š Version Information

Current Version: 1.0.0

Component Version
Dash 4.2.0
Dash Mantine Components 2.7.0+
Mantine 8.3.6
Python 3.11+
React 18.2.0
Flask / FastAPI / Quart pluggable backends
dash-improve-my-llms 2.0.0+

See CHANGELOG.md for version history.

What's New in 1.0.0

First stable release β€” a major architectural milestone:

  • πŸš€ Dash 4.x (4.2.0) and DMC 2.7.0 β€” modern framework with pluggable backends.
  • πŸ”Œ Pluggable backends: run the same app on Flask, FastAPI, or Quart by setting DASH_BACKEND β€” no code changes. ASGI backends add async/websocket callbacks, OpenAPI docs, a native JSON API, and ASGI middleware. New Pluggable Backends, Backend Deep Dive, and FastAPI Showcase docs.
  • 🎯 dash-improve-my-llms 2.0: the LLMS_DOC pattern (per-page prose served at /<page>/llms.txt), multi-backend AI/LLM surfaces, and an MCP resource bridge on Dash 4.3+.
  • 🧹 Removed the TOON format entirely β€” lib/toon_generator.py, the TOON docs/dashboard, and /llms.toon routes are gone (the package no longer exports TOONConfig, toon_encode, generate_*_toon).
  • ⚠️ Removed mark_important() / mark_component_hidden() (now no-ops) and the /page.json / /architecture.txt routes β€” Dash 4.3 MCP covers structured introspection. Write emphasis directly into a page's LLMS_DOC markdown.

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

Built With

Inspired By

  • dmc-docs - Documentation framework inspiration

Special Thanks

  • @AnnMarieW for suggested improvements
  • The Dash community for continuous support

πŸ“ž Support & Community

Get Help

Discord Invite

Stay Connected

GitHub: @pip-install-python GitHub Followers

YouTube: Pip Install Python YouTube Subscribers


Want to Contribute?

Check out open issues labeled good first issue


⬆ Back to Top

Made with ❀️ by the Dash community

Pip Install Python LLC @ https://plotly.pro

Star this repo if you find it useful! ⭐

About

This project is designed to help developers quickly create well-organized documentation for their Dash components, data science workflows, and entire Dash applications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors