Python Design OS - 100% custom Tailwind-driven UI library and Live Preview engine
Project description
DesignGUI โ The Autonomous AI-Native UI Framework
DesignGUI is a headless, strictly-typed Python UI framework explicitly engineered for Autonomous AI Agents and LLM-assisted development.
It provides AI coding assistants (Cursor, Windsurf, GitHub Copilot, or custom SWE-agents) with a highly constrained, predictable, and composable Tailwind CSS component vocabulary. By forcing AI agents to use pre-built, secure layout wrappers instead of hallucinating raw HTML or complex frontend logic, DesignGUI guarantees beautiful, enterprise-grade user interfaces on the first prompt.
โก The Core Philosophy
AI agents are incredible at writing Python logic, but they are notoriously inconsistent at producing responsive, well-structured frontend CSS.
DesignGUI bridges this gap by acting as a translation layer. It provides a declarative Python API that completely abstracts the frontend. Agents just stack Python objects (AuthForm, StatGrid, Sheet, Table), and DesignGUI compiles them into a gorgeous, hot-reloading Tailwind frontend in real-time.
Key Features
- ๐ค Agent-First Vocabulary โ Ships with an injected
.designgui/INSTRUCTIONS.mdthat teaches your IDE's AI exactly how to use the framework before generating a single line of code. - ๐ Live Watchdog Engine โ Save a
.pyfile and watch the browser instantly hot-reload. A singletonwatchdogobserver detects changes within ~100ms and re-executes the view module cleanly viaimportlib. - ๐ก๏ธ XSS Protected โ All user inputs and component labels are sanitised with
html.escapeby default throughout every component in the library. - ๐ฆ Edge-Ready Export โ Run
designgui exportto compile your prototype into a lightweight, headless NiceGUI web server ready for Docker or Raspberry Pi deployments. - ๐ RTL & i18n Ready โ Automatic RTL orientation mapping (
dir="rtl") for Arabic, Farsi, and Urdu locales. - ๐ Secure by Default โ Persistent
storage_secretauto-generated and saved inconfig.jsonon first run; never a hardcoded key in production.
๐ Quickstart
1. Install:
pip install designgui
2. Initialise a new project:
designgui init
This prompts for your preferred AI IDE (Cursor, Windsurf, Copilot, etc.) and port, then wires up the entire .designgui/ workspace and injects the strict agent rules into your IDE config file.
3. Start the Live Preview:
designgui start
# or run headless in the background:
designgui daemon
Open http://localhost:8080.
4. Prompt your AI:
Open .designgui/product/views/dashboard.py and tell your agent:
"Build me a SaaS dashboard using a Sidebar, a Header, and a StatGrid."
The agent reads INSTRUCTIONS.md, writes the view file, and you watch the browser update live.
5. Export to production:
designgui export --host 0.0.0.0 --port 8080
Generates production_app/main.py โ a headless NiceGUI router with reload=False, show=False, ready to deploy.
๐๏ธ The Component Ecosystem
Over 35 composable, Tailwind-native Python components organised in six layers:
| Layer | Components |
|---|---|
| Primitives | Box, Flex, Stack, Container, Text, Divider |
| Inputs | Button, Input, ToggleSwitch, Slider, RadioGroup, Select, Checkbox, Textarea |
| Display | Image, Icon, Avatar, DropdownMenu, Table, Tabs, TabPanel, Accordion, Card, Badge, Modal |
| Layout | Sidebar, Header, Sheet |
| Feedback | Skeleton, Spinner, Toast |
| Composites | AuthForm, StatGrid, EmptyState, Stepper, TopNav, DataFeed |
All components extend TailwindElement, which wraps NiceGUI's raw Element class directly โ not a Quasar Vue component. Tailwind utility classes apply cleanly with no CSS specificity conflicts.
from designgui.ui_lib.primitives import Stack, Container, Text
from designgui.ui_lib.inputs import Button
from designgui.ui_lib.composites import StatGrid
def render_view():
with Container(base_classes=['p-8']):
Text('Dashboard', base_classes=['text-3xl', 'font-bold', 'mb-6'])
StatGrid(stats=[
{'label': 'Users', 'value': '12,400', 'trend': '+8%', 'positive': True},
{'label': 'Revenue', 'value': '$94,200', 'trend': '+12%', 'positive': True},
{'label': 'Churn', 'value': '2.1%', 'trend': '-0.3%', 'positive': False},
])
Button('Export Report', variant='primary', on_click=lambda: print('Exporting...'))
๐ The 5-Loop Workflow
DesignGUI enforces a structured pipeline that every AI agent reads from INSTRUCTIONS.md before writing code:
| Phase | Location | Action |
|---|---|---|
| 1 โ Vision | .designgui/product/models.py |
Define data shapes with Pydantic models |
| 2 โ Shell | .designgui/product/shell.py |
Build global layout using Container, Sidebar, Header |
| 3 โ Section | .designgui/product/views/{name}.py |
Write render_view() using component library + mock data |
| 4 โ Screen | Modify the view | Wire on_click=, on_change= callbacks and state |
| 5 โ Export | production_app/ |
Run designgui export to produce the headless build |
The golden rule: agents only import from designgui.ui_lib. No raw NiceGUI. No custom CSS.
โ๏ธ How It Works โ End to End
Installation & Setup
pip install designgui
This registers the designgui CLI entry point and ships four things: the component library (designgui.ui_lib), the CLI (designgui.cli), the live preview server (designgui.server), and locale strings (designgui/locale/en.json).
The .designgui/ Workspace
designgui init creates a hidden project workspace:
.designgui/
โโโ config.json # Port, locale, font, secret, path settings
โโโ INSTRUCTIONS.md # Full component API cheat sheet for AI agents
โโโ product/
โ โโโ models.py # (Phase 1) Pydantic models
โ โโโ shell.py # (Phase 2) Layout wrapper
โ โโโ views/
โ โโโ dashboard.py # Placeholder view
โโโ commands/
โโโ vision.md # Phase 1 prompt intercept
โโโ shell.md # Phase 2 prompt intercept
โโโ section.md # Phase 3 component cheat sheet
โโโ screen.md # Phase 4 wiring guide
The .designgui/ directory is appended to .gitignore automatically โ it is a per-developer workspace, never committed.
The Live Preview Engine
designgui start
โ
โโ Singleton watchdog Observer โ watches views/
โ on .py change โ app.storage.general['last_modified'] = time.time()
โ
โโ @ui.page('/')
โ โโ Inject Tailwind CDN + font into <head>
โ โโ Set RTL/LTR on <html> and <body>
โ โโ Render preview chrome (title + view selector dropdown)
โ โโ ui.timer(0.5s) โ poll storage โ re-import + render on change
โ
โโ ui.run(port, reload=False)
Hot-reload mechanism: On each detected file change, the module is purged from sys.modules, reloaded fresh via importlib.util.spec_from_file_location, and render_view() is called inside the preview pane. Any exception is caught and displayed as a styled error block โ the server never crashes.
The Daemon Mode
designgui daemon spawns a fully detached background process (DETACHED_PROCESS on Windows, start_new_session=True on Unix), so autonomous agents can write and preview views without a human at the keyboard.
๐ฌ Deep Dive โ NiceGUI Dependency
This is a non-optional, structural dependency. DesignGUI is not a library that uses NiceGUI as a convenience โ it is built on top of NiceGUI's core runtime at every layer.
Layer 1 โ The Element System
from nicegui.element import Element
class TailwindElement(Element):
...
nicegui.element.Element is the base class for every single component. It provides:
- The Python-side DOM tree โ
with self:in composites works becauseElementimplements__enter__/__exit__to manage a context stack that routes children to the correct parent. - The
_propsdictionary โself._props['innerHTML'] = ...is NiceGUI's mechanism for syncing Python-side property changes to the browser over WebSocket.self.update()flushes the change. self.classes(add=, remove=)โ Used byapply_variant, all open/close toggles, andTabsstyle switching..on(event, handler, args=[])โ The entire event system. EveryButtonclick, everyInputchange, everyToggleSwitchtoggle routes through this.
Layer 2 โ The Preview Server
| NiceGUI API | Role in DesignGUI |
|---|---|
ui.page('/') |
Registers the preview route with the Starlette/uvicorn router |
ui.run(port=, reload=, show=) |
Starts the ASGI server and WebSocket endpoint |
ui.add_head_html() |
Injects Tailwind CDN and font CSS into <head> |
ui.query('html').props(...) |
Sets RTL direction on the root element |
ui.timer(0.5, fn) |
Drives the per-client hot-reload polling loop |
ui.notify(...) |
Shows reload success/error toasts |
app.storage.general |
Cross-client shared state for watchdog timestamps |
Layer 3 โ Toast
Toast.show() calls ui.notify() directly โ the one place where Quasar's QNotify surfaces into the public API.
What Removing NiceGUI Would Cost
NiceGUI is as fundamental to DesignGUI as Flask is to a Flask application. Removing it would require: a new DOM-in-Python abstraction, a new WebSocket communication layer, a new ASGI server, a replacement for ui.timer() async integration, and a replacement for ui.notify().
Version note:
pyproject.tomlpinsnicegui>=1.4.0,<3.0.0. If NiceGUI ever makes a breaking change toElement,_props, or.on(), every component breaks simultaneously โ the ceiling bound protects against silent breakage on fresh installs.
๐ Acknowledgements
DesignGUI was not built in a vacuum. It represents a synthesis of two brilliant open-source philosophies:
NiceGUI โ by Zauberzeug
The entire live preview and backend WebSocket routing engine of DesignGUI is powered by NiceGUI. Zauberzeug has built one of the most elegant, developer-friendly Python UI frameworks in existence. DesignGUI utilises NiceGUI's underlying Quasar/Vue.js bridge and enforces a strict Tailwind-only abstraction layer on top of it. We highly recommend checking out NiceGUI for general-purpose Python web development.
Design-OS โ by Builder Methods
The structural philosophy, the ShapeโShell methodology, and the concept of an AI-enforced component vocabulary were heavily inspired by Design-OS. Builder Methods proved that drastically constraining an AI's vocabulary makes its architectural output remarkably reliable. DesignGUI is an attempt to bring that exact philosophy into the Python ecosystem.
๐ License
DesignGUI is open-source software licensed under the MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file designgui-0.1.0.tar.gz.
File metadata
- Download URL: designgui-0.1.0.tar.gz
- Upload date:
- Size: 36.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
684dc5d0202c3c471420ccff83ff9c20fcdb8deaade31e6eb13c0e1b44af73bd
|
|
| MD5 |
079467a9312feb47b2a327a0f99a676e
|
|
| BLAKE2b-256 |
28f2bf13933563ac73a7845455ca94de76a07343623ca8c91411a4df2e6ca60a
|
File details
Details for the file designgui-0.1.0-py3-none-any.whl.
File metadata
- Download URL: designgui-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9a168e5fa72d3f08104e1ca98ebd3c6c93dcf65a57dd353014947caeed68f3f
|
|
| MD5 |
ea73d6e6d50b6fd477372d103b8394ee
|
|
| BLAKE2b-256 |
632cfd18faf8200d8f7c7748d031c89f5039d73f46bf5a339bd88e2e9d6b78d5
|