⚡ PyDataUI
A Full-Stack Python Framework for Data and AI Applications. Data Engineers • Data Analysts • AI/ML Engineers • Python Developers
Write pure Python → get reactive web applications, automatic REST APIs, and a Rust HTTP backend. Zero JavaScript required.
Quick Start • Why PyDataUI? • Components • Authentication • Port Forwarding • Benchmarks • Documentation
🎯 Built Specifically for Data Roles
Build dashboards, dataset explorers, model evaluation interfaces, and data workflows using Python UI components and server-side logic.
0.2.1 security source update: see the migration guide for protected routes, API permissions, CSRF, and session behavior. This checkout has not been published to PyPI by this change.
PyDataUI solves this:
- 🐍 100% Python Code: Build UI, reactive state, and server logic in clean, typed Python.
- 🦀 Rust-Powered HTTP Core (
pyrustapi): Tokio/Hyper HTTP backend; application performance needs workload-specific measurement. - 🎨 Tailwind CSS + shadcn/ui: Modern, accessible UI design system with built-in dark mode and CSS variables.
- ⚡ Reactive SSR via HTMX: Server re-renders the current page fragment on state mutation — seamless browser updates with no user-authored JavaScript for common interactions.
- 🔌 Automatic REST API: Eligible
Stateclasses expose OpenAPI documentation and CRUD endpoints at/api/{State}. - 🔒 Auth & API Keys: JWT authentication, role-based access control (RBAC), and
pdu_live_...API keys for ETL automation. - 🌐 One-Click Sharing (
share=True): Create public internet tunnels for demos and stakeholders instantly, like Gradio.
⚡ Quick Start
Installation
pip install pydataui
Optional dependencies for data science and port forwarding:
pip install "pydataui[all]" # includes pandas, plotly, pyngrok, pyarrow
1. Minimal Reactive Counter (30 seconds)
from pydataui import App, State
from pydataui.components import Container, Card, Flex, Button, Heading, Divider
class CounterState(State):
count: int = 0
def increment(self): self.count += 1
def decrement(self): self.count -= 1
def reset(self): self.count = 0
app = App(title="PyDataUI Counter")
@app.page("/")
def home():
return Container(
Card(
title="Reactive Counter",
children=[
Flex(
Button("-", on_click=CounterState.decrement, variant="danger"),
Heading(CounterState.count, level=2),
Button("+", on_click=CounterState.increment, variant="success"),
align="center", justify="center", gap="lg",
),
Divider(),
Button("Reset", on_click=CounterState.reset, variant="outline", full_width=True),
]
),
max_width="md",
padding="lg",
)
if __name__ == "__main__":
app.run()
Run it:
python app.py
- 🌐 Web UI:
http://127.0.0.1:8000 - 📖 Swagger UI:
http://127.0.0.1:8000/docs - 📡 REST API Catalog:
http://127.0.0.1:8000/api
🤖 Machine Learning Dashboard Example
PyDataUI includes native components for model evaluation:
from pydataui import App
from pydataui.components import Container, Heading, Grid
from pydataui.components.data_science import ModelMetrics, ConfusionMatrix, FeatureImportance
app = App(title="Fraud Detection Model v3")
@app.page("/")
def dashboard():
return Container(
Heading("Production XGBoost Model Evaluation", level=1, margin_bottom="lg"),
ModelMetrics(
metrics={
"Accuracy": 0.9642,
"Precision": 0.9410,
"Recall": 0.9780,
"ROC-AUC": 0.9891
}
),
Grid(
ConfusionMatrix(
matrix=[[1450, 42], [28, 1380]],
labels=["Legitimate", "Fraud"]
),
FeatureImportance(
features={
"velocity_1h": 0.34,
"avg_amount_ratio": 0.28,
"device_fingerprint_entropy": 0.18,
"geo_distance_anomaly": 0.12,
"is_international": 0.08
},
title="Top Predictive Features"
),
columns=2, gap="lg", margin_top="lg"
),
padding="lg"
)
if __name__ == "__main__":
app.run()
🔒 Authentication, Roles & API Keys
Secure your application for enterprise data workflows:
from pydataui import App
from pydataui.components import Container, Heading, Flex
from pydataui.auth import (
AuthManager, LoginPage, UserMenu, APIKeyManager,
require_auth, require_role, Role, current_user
)
app = App(title="Secure Analytics Portal")
auth = AuthManager() # Configure PYDATAUI_AUTH_SECRET for deployment
# Register users with roles
admin = auth.add_user("lead_eng", "password123", roles=[Role.ADMIN, Role.DATA_ENGINEER])
analyst = auth.add_user("analyst_jane", "password456", roles=[Role.DATA_ANALYST])
# Wire up auth routes (/api/auth/login, /api/auth/me, /api/auth/keys)
app.setup_auth(auth)
@app.page("/login")
def login_route():
return LoginPage(title="Analytics Portal", subtitle="Sign in with your corporate credentials")
@app.page("/")
def dashboard():
user = current_user.get()
return Container(
Flex(
Heading("Data Warehouse Control Center", level=1),
UserMenu(user),
justify="space-between", align="center"
),
APIKeyManager(keys=auth.list_api_keys(user.id) if user else []),
padding="lg"
)
# Protected API endpoint with API key requirement
@app.api("/data/export", method="GET")
def export_data(request):
user = auth.require_auth_middleware(request)
if not user:
return {"error": "Unauthorized"}
return {"status": "ok", "records": 100000}
if __name__ == "__main__":
app.run()
Automated API Key Authentication (ETL & Airflow)
Automate ingestion pipelines by passing the generated key:
curl -H "Authorization: Bearer pdu_live_819dd41a93870327fdc57311d0080755" \
http://localhost:8000/data/export
🌐 Port Forwarding (share=True)
Share your application with remote stakeholders, clients, or team members with a single flag:
# In your Python code:
app.run(share=True)
Or via CLI:
pydataui run app.py --share
Output:
PyDataUI v0.2.0
Running on http://127.0.0.1:8000
Public URL: https://abc123.ngrok.app
API docs at http://127.0.0.1:8000/docs
REST API root at http://127.0.0.1:8000/api
📊 Performance
The backend uses pyrustapi. This repository does not yet contain a reproducible benchmark suite establishing throughput, P99 latency, or memory superiority over other frameworks. Evaluate equivalent real applications on the same hardware; HTTP hello-world throughput does not establish data-application performance.
🧩 Comprehensive Component Library (80+ Components)
PyDataUI includes modern Tailwind and shadcn/ui components:
🔬 Data & Machine Learning
DataFrameTable: Interactive table with automatic pandas integrationPlotlyChart: Native Plotly figure embeddingMetricCard: KPI card with delta percentage and trend indicatorsModelMetrics: Evaluation grid (Accuracy, Precision, Recall, AUC, F1)ConfusionMatrix: Heat-mapped confusion matrixFeatureImportance: Horizontal bar chart for predictive featuresPipelineStatus: Step-by-step DAG execution trackerDataTimeline: Run history and audit event timelineSchemaViewer: Inspect table schemas, dtypes, nulls, and uniquesSQLEditor: SQL query editor with inline Run buttonJSONViewer: Pretty-printed, collapsible JSON displayFileDownload: In-browser data export to CSV/JSON
🎨 shadcn/ui Styled Components
ShadButton,ShadCard,ShadBadge,ShadAlert,ShadSeparatorShadProgress,ShadSkeleton,ShadSwitch,ShadTable,ShadSelectShadTextarea,ShadLabel,ShadDialog(Modal),ShadScrollAreaShadTabs,ShadToast,ShadAvatar,ShadHoverCard,ShadAccordion,ShadSheet(Drawer)
📐 Classic Layout & Forms
Container,Flex,Grid,Stack,HStack,VStack,Box,Center,DividerHeading,Text,Paragraph,Link,Code,BlockquoteButton,Input,TextArea,Select,Checkbox,Radio,Switch,Slider,FileUploadTable,DataTable,Badge,Stat,Progress,Spinner,Modal,DrawerBarChart,LineChart,PieChart,DoughnutChart,Sparkline
💼 Commercial SaaS Application Example
Experience an enterprise-grade AI gateway and subscription billing platform built entirely with PyDataUI:
python examples/commercial_saas_app.py
- Executive Observability: Live KPI cards (MRR, Token Volume, P99 Latency), time-window filters (
24h,7d,30d), and pipeline step tracking. - Model Observatory: Multi-model routing matrix (Claude 3.5 Sonnet, GPT-4o, Gemini 1.5 Pro, Llama 3 70B) with pricing and quality benchmarks.
- Tiered Subscription Billing: Interactive plan cards (Starter, Growth, Enterprise Scale) with usage quota progress and automated invoice history.
- API Key Gateway: Provision scoped production tokens (
pdu_live_...) for automated pipelines. - Production Persistence: Backed by SQLite WAL cross-process storage supporting multi-worker execution out of the box.
🛠️ Powerful CLI
Create, run, and containerize PyDataUI projects with zero boilerplate:
# 1. Create a project from starter templates
pydataui new analytics_hub --template dashboard
# Available templates: basic, dashboard, crud, ml-dashboard, data-pipeline, auth
# 2. Run local development with hot reload
pydataui dev app.py --port 8000 --reload
# 3. Run production server with public tunnel
pydataui run app.py --workers 1 --share
# 4. Check syntax and route definitions
pydataui check app.py
# 5. Generate secure API key for scripts
pydataui generate key --name "AirflowSync"
# 6. One-command containerization build
pydataui build app.py --output dist/
# Generates Dockerfile, docker-compose.yml, bundled static assets, and app.py
📚 In-Depth Guides
- 📘 Full Documentation
- 🎨 UI Customization Guide (Tailwind, shadcn & HTML)
- 🛠️ Troubleshooting & Architecture Guide
- 🔒 Authentication & Security Guide
- 📊 Data Science & Engineering Components
- 📖 Complete API Reference
- 🚀 Production & Cloud Deployment
- 🛡️ Production Readiness Assessment
- ⚡ Quick Reference Card
🤝 Contributing
We welcome contributions from the data science, AI/ML, and Python web development communities! Please see our CONTRIBUTING.md for local environment setup, testing, and pull request guidelines.
📄 License
PyDataUI is licensed under the MIT License. Copyright (c) 2024 Boopathi Raj.
Async custom API endpoints
Custom @app.api routes support both synchronous and asynchronous functions:
import asyncio
from pydataui import App
app = App()
@app.api('/async-example', public=True)
async def async_example(request):
await asyncio.sleep(0.01) # Replace with an async API/database client.
return {'message': 'Async endpoint completed'}
if __name__ == '__main__':
app.run()
Authentication, roles, API-key scopes and CSRF checks still apply. Request and current-user context remain active until the coroutine finishes, including exception and cancellation cleanup. Existing synchronous routes keep their session-locked behavior.
Async handlers do not hold the session's threading lock while awaiting I/O. Consequently, custom async handlers must manage synchronization for shared mutable data themselves; do not assume a whole handler is an atomic session transaction. Use database transactions for concurrent writes. CPU-heavy ML training and blocking libraries belong in worker jobs or a suitable executor. This support is for custom API routes, not async pages or automatic State actions.
Metadata
Release files for pydataui 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydataui-0.2.2.tar.gz | 145.9 kB | Without provenance | Details for pydataui-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydataui-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for pydataui-0.2.2-py3-none-any.whl |
Total release size: 275.7 kB
Release files / pydataui-0.2.2.tar.gz
| Download URL | pydataui-0.2.2.tar.gz |
|---|---|
| Size | 145.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e0c8b34602888b40e570214e0b3920ae1711b2fa26df44778af88d511c138c19
|
|
BLAKE2b-256 checksum How to use checksums |
bdb9742ed5f71774561919f6765b5778fe6b889783adde443e189f73a19e376d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Release files / pydataui-0.2.2-py3-none-any.whl
| Download URL | pydataui-0.2.2-py3-none-any.whl |
|---|---|
| Size | 129.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7797268f521db89bf9909f4a5d0300389c24f1d9dc388ea80c01c1a2e196f67f
|
|
BLAKE2b-256 checksum How to use checksums |
4d1ead2fc79b8a3323d9dc64f574f1a5bbd4d688de5cb2a623a8e065271073bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Security for pydataui 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.