A Python framework for building agentic AI applications with server-driven UI, observability, and sandboxed extensibility.
Project description
A Python framework for building agentic AI applications with a server-driven UI, native observability, and an integrated security model — designed for environments with regulatory or operational constraints where reproducibility and auditability matter.
Status: Beta 0.0.1 — public preview, released as-is. The framework is not production-ready and ships without warranty. APIs and behavior may change before the first stable release. Use at your own risk.
Links
- Website: democr.ai
- Documentation: democr.ai/docs/
Overview
Democr.ai is a complete runtime framework for AI applications. It provides:
- Server-driven UI for agentic contexts, implementing and extending Google's A2UI protocol
- Multi-client rendering of the same UI definition (web, desktop, additional clients in development)
- Native multi-tenancy enforced at write time
- OS-level sandboxing for engine and extension processes (currently Linux only)
- Triple-layer audit through SQLAlchemy hooks, with sensitive field redaction
- RBAC with declarative module manifests
- Pluggable AI engine orchestration (local and remote models)
- Knowledge subsystem with vector and graph backends
- A strict modular architecture where everything — including authentication — is a module built against the public SDK
The framework is designed around a clear boundary between core runtime and extensions. The SDK is the only supported way to build on top.
A2UI
Let agents build UI components that render as native application surfaces, not as screenshots or markup fragments. Democr.ai modules describe UI declaratively on the server, then stream structured updates as the agent works.
Who it's for
Democr.ai targets applications where:
- The deployment environment has compliance, regulatory, or operational constraints
- Observability and reproducibility are required from day one, not added later
- Avoiding vendor lock-in is a hard constraint: the framework is fully self-hostable, model-agnostic, and ships no proprietary cloud services
- Auditability across user actions, data mutations, and AI calls is required at the deployment level
- The team prefers an integrated runtime over assembling separate pieces (LLM library + UI framework + observability stack + audit + RBAC + workflow engine)
It is not a thin wrapper, a model router, or a chat UI library. It is a runtime where modules, engines, extractors, and clients compose into a single coherent system.
Core principles
Everything is a module
There are no privileged components. Authentication, system administration, and the demo applications shipped in this repository are all built as modules, using the same SDK that third-party developers use. There are no reserved APIs, no hidden hooks, and no internal-only services.
The modules included in this repository (auth, system, components) are primarily examples of how the framework works and how applications integrate with it. They provide a working baseline, but deployments are not required to use them as-is: teams can replace them, extend them, or build their own domain-specific implementations.
No vendor lock-in
- The runtime is fully self-hostable.
- AI engines are pluggable: local inference (vLLM, llama.cpp) and cloud providers (OpenAI, Anthropic, Google, and others), or custom integrations.
- Storage backends are pluggable for vector (sqlite-vec, pgvector, and others), knowledge graph, and core persistence (SQLite, PostgreSQL).
- No proprietary serialization formats. State is portable across deployments.
Observability and reproducibility as development guides
Observability is not added as later instrumentation — it is part of how the framework expects developers to build. Every action, AI call, and module operation flows through a correlation chain that allows step-by-step reconstruction of any request. Pipelines are observable. The audit subsystem captures mutations at three layers (request, ORM, AI invocation) automatically, with sensitive field redaction.
Reproducibility is achieved through deterministic configuration, structured event logs with stable IDs, and an immutable audit trail.
Security as a primitive, not a feature
The framework provides security as foundational primitives, not as opt-in features. See Threat model for the precise boundary between framework guarantees and deployer responsibilities.
Extending Google's A2UI protocol
The UI layer is an extended implementation of Google's A2UI protocol for server-driven UI in agentic contexts. The same UI definition renders consistently across multiple clients with no client-side framework code required from module authors. New clients can be added without changes to existing modules.
Architecture overview
Democr.ai is composed of distinct subsystems:
- Core runtime — bootstrap, lifecycle, request handling, dependency graph
- Network — WebSocket, IPC, HTTP under a unified protocol layer
- AI engine orchestrator — job-based scheduling, batching, gRPC process isolation, HITL support
- Knowledge — ingestion queue, projection workers, vector + graph retrieval
- Sandbox — OS-level isolation (Landlock + seccomp + iptables + helper process)
- Multi-tenancy — write-time enforcement with materialized scope filters
- RBAC — declarative access policies in module manifests
- Modules — framework extension surface, via SDK
- Engines — pluggable AI inference providers
- Extractors — pluggable knowledge extraction providers
- Clients — independent rendering surfaces (web, desktop, future mobile)
- Platform — agents, skills, tools, MCP, UI builder
Detailed subsystem documentation is available at democr.ai/docs/.
Feature matrix
| Capability | Status | Notes |
|---|---|---|
| Server-driven UI (extended A2UI) | Implemented | websocket and ipc transport |
| Multi-client rendering | Implemented | Web, Qt desktop, Tauri |
| Multi-tenancy | Implemented | Write-time enforcement |
| RBAC | Implemented | Declarative manifests |
| AI engine orchestration | Implemented | Job-based, gRPC isolated |
| Knowledge subsystem (vector + KG) | Implemented | Hybrid retrieval |
| Audit (triple layer) | Implemented | Sensitive field redaction |
| OS sandbox (Landlock + seccomp + iptables) | Implemented | Linux only |
| OS sandbox on macOS | Roadmap | |
| OS sandbox on Windows | Roadmap | |
| Local AI inference | Implemented | vLLM, llama.cpp, and others |
| Cloud AI providers | Implemented | OpenAI, Anthropic, Google, and others |
| Multi-node engine orchestration | Roadmap | Single-node currently |
| mTLS for internal gRPC services | Roadmap | Server-side TLS + service JWT first |
| Tokenizer-aware context budget guard | Roadmap | Basic heuristic guard for oversized prompt messages and tool outputs first |
| Multi-node tuning | Roadmap | |
| Mobile clients | Roadmap | |
| Request observability | Implemented | Correlation chain across layers |
Stress benchmark snapshot
The following numbers are local stress-test snapshots for the authenticated
request path: login, session handling, and server-side rendering of the
server-driven UI route /components/_effects/yaml. They document observed
behavior under concurrent load on one machine; they are not universal
performance claims or comparisons with other frameworks.
Environment:
- CPU: Intel Core i9-14900K
- RAM: 64 GB
- GPU: NVIDIA RTX 3090 Suprim, not used by this benchmark path
- OS: Ubuntu 24
- Python: 3.12.3
- Providers: remote providers
| Instances | Workers / instance | Clients / worker | Duration | Requests | Errors | Throughput | Avg latency | p95 latency |
|---|---|---|---|---|---|---|---|---|
| 4 | 4 | 4 | 303.69s | 468,840 | 0 | 1,543.83 req/s | 33.28ms | 47.05ms |
| 8 | 4 | 4 | 302.39s | 718,050 | 0 | 2,374.55 req/s | 43.30ms | 47.94ms |
Command shape:
PYTHONPATH=. .venv/bin/python scripts/multi_core_benchmark.py \
--instances 4 \
--workers 4 \
--clients 4 \
--duration-seconds 300 \
--profile custom \
--profile-log-summary
For the 4-instance run, aggregate resource usage was:
| Metric | Value |
|---|---|
| Avg total CPU | 1326.9% |
| Peak RSS | 7092.1 MB |
| Peak USS | 5936.8 MB |
| Peak PSS | 5986.8 MB |
RSS can overstate standalone memory use because shared pages are counted more than once.
Threat model
The framework offers security as foundational primitives: OS-level sandboxing (Linux), immutable audit, RBAC, and at-rest encryption of secrets stored in the database. Modules operate within these primitives according to the policies they declare (sandbox allow-lists, RBAC permissions, access scope).
The threat model covered by the framework is accidental supply-chain compromise — a third-party module with a bug or compromised dependency must not be able to harm the system beyond its declared scope.
The threat model not covered is a deliberately malicious module installed consciously by the deployer. The selection of modules to install and the configuration of security policies are deployer responsibilities.
The framework's config.yaml is plaintext and is generated locally by the setup wizard. It is not designed to be deployed. Secrets are encrypted at rest only when stored in the database.
Quick start
Requirements
- Python 3.12+
- Linux is recommended for full security features (OS sandbox is Linux-only at present)
- Optional: NVIDIA GPU with CUDA for local inference
Install
From the repository root:
./setup_venv.sh
Run
Default startup is desktop mode with the Qt client:
python main.py
Equivalent explicit form:
python main.py --mode desktop --client qtdesktop
Server mode (HTTP + WebSocket exposed)
python main.py --mode server --host 127.0.0.1 --port 8000
Desktop with HTTP also exposed
Desktop mode uses IPC by default. Add --http to also expose HTTP/WebSocket:
python main.py --mode desktop --http --client qtdesktop
Web client
Web clients are independent React applications. The runner launches them with yarn dev:
python main.py --mode server --client webclient
Web client in desktop mode with tauri
Web clients are independent React applications. The runner launches them with yarn dev:
python main.py --client tauri
First-time setup
On first run, the framework starts a setup wizard via the connected client. The wizard configures the database, AI providers, and the initial administrator user. The resulting configuration is generated locally and not designed to be deployed.
Commands
| Command | Purpose |
|---|---|
python main.py |
Default desktop mode |
python main.py --mode server |
Server mode (HTTP + WebSocket) |
python main.py --mode desktop |
Desktop mode (IPC transport) |
python main.py --http |
Also expose HTTP in desktop mode |
python main.py migrate all |
Run all pending database migrations |
python main.py migration-status all |
Show migration status |
python main.py create-migration db -m "desc" --autogenerate |
Create a new core DB migration |
python main.py create-migration data --module <name> -m "desc" --autogenerate |
Create a new module data migration |
python main.py rollback data --steps 1 |
Roll back one data migration step |
python main.py validate-config |
Validate current configuration |
python main.py reset-install |
Reset the installation state |
python main.py module-status |
Show module discovery and load status |
python main.py knowledge-rebuild --all --dry-run |
Rebuild knowledge projections (dry run) |
Runtime extension paths
The runner sets default extension path variables if they are not already configured:
DEMOCRAI_MODULES_PATH=/path/to/modules
DEMOCRAI_ENGINES_PATH=/path/to/engines
DEMOCRAI_EXTRACTORS_PATH=/path/to/extractors
Each variable can contain one or more existing directories. Multiple directories
use the platform path separator (: on Linux/macOS, ; on Windows).
At startup, the core runtime discovers and registers extension packages from these paths. Modules, engines, and extractors are all extension types: modules add application behavior, engines add AI provider/runtime integrations, and extractors add document or media ingestion capabilities.
Tested components
The components listed below have been validated through development and integration testing. The list will be expanded as additional engines, extractors, and models are formally certified for the first stable release.
Note: a complete and versioned list of tested models, engines, and extractors will accompany the first stable release. Provider implementations may exist in the repository before they are certified. Components not listed here should be treated as implemented but not yet validated through the current integration pass.
AI engines
| Engine | CPU/GPU | Status |
|---|---|---|
onnx |
CPU | Basic implementation |
llamacpp |
CPU/GPU | Basic implementation |
vllm |
GPU | Basic implementation |
parler |
GPU | Basic implementation |
qwen_tts |
GPU | Basic implementation |
whisper |
GPU | Basic implementation |
espeak |
CPU | Basic implementation |
rebel |
GPU | Basic implementation |
gliner+glirel |
GPU | Basic implementation |
ollama |
GPU (local) | Basic implementation |
openai compatible |
- | Basic implementation |
openai |
- | Basic implementation |
gemini |
- | Basic implementation |
anthropic |
- | Basic implementation |
openai whisper |
- | Basic implementation |
openai tts |
- | Basic implementation |
edge tts |
- | Basic implementation |
Knowledge extractors
| Extractor | Tested with | Status |
|---|---|---|
docling |
Tesseract/RapidOCR | Basic implementation |
ai_audio |
Whisper (faster whisper) | Basic implementation |
ai_image |
Gemma 4 26B A3B | Basic implementation |
Storage backends
- SQLite (default, recommended for development)
- PostgreSQL (recommended for production multi-tenant deployments)
- sqlite-vec (vector, default)
- pgvector (vector, when PostgreSQL is in use)
Implemented, not yet certified
- Pinecone
- ClickHouse
Clients
qtdesktop— PyQt6-based desktop clientwebclient— React web clienttauri— Tauri-based desktop client
Repository layout
main.py— runner for local development and packaged launcher flowspyproject.toml— build metadata for thedemocraiPython packagedemocrai/core/— internal runtime: bootstrap, storage, network, sandbox, orchestration, registriesdemocrai/sdk/— public SDK boundary for extensions (the only supported import surface for modules)democrai/third_party/— bundled runtime assets (e.g.,libmagic)modules/— bundled demo modules (auth,system,components)engines/— AI engine implementations and manifestsextractors/— knowledge and media extractor implementationsclients/qtdesktop/— Qt desktop clientclients/webclient/— React web clientclients/tauri/— Tauri-based desktop clientdocs_site/— MkDocs documentation pipelinetests/— Python test suites
Modules may import only from democrai.sdk. Imports from democrai.core are not part of the supported boundary and locked by module runtime.
Documentation
Full documentation is built with MkDocs:
source .venv/bin/activate
.venv/bin/mkdocs build -f docs_site/mkdocs.yml --strict
Generated output is in docs_site/docs_html/.
Node tooling for documentation post-processing is managed inside docs_site/:
cd docs_site
npm install
Roadmap
The items below are planned for upcoming releases, in approximate order:
- Multi-node engine orchestration — distributed routing of AI inference requests across nodes with capability-aware placement and load awareness
- Multi-node tuning — distributed fine-tuning workflows
- OS sandbox on macOS — port of the Linux sandbox kernel to macOS primitives
- OS sandbox on Windows — port of the Linux sandbox kernel to Windows primitives
- Additional clients — mobile clients and expanded web framework variants, alongside the existing
webclient,qtdesktop, and Tauri-based desktop - Knowledge subsystem improvements — additional projection backends, refined retrieval, expanded extractor coverage
- And many more — see the issue tracker for the full backlog and active proposals
Tests
Run the framework test suite:
source .venv/bin/activate
pytest -c tests/pytest.ini tests/runtime
With coverage:
pytest -c tests/pytest.ini --cov-config=tests/.coveragerc --cov=democrai tests/runtime
coverage html --rcfile=tests/.coveragerc
Some tests depend on external engines or services. Verify the local environment before running broader suites.
License
Democr.ai uses a split licensing model:
democrai/core/is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). Modifications to the core that are made available over a network must be released under the same license.democrai/sdk/,engines/,extractors/,modules/, andclients/are licensed under the Apache License 2.0. You can build, ship, integrate, and commercialize extensions, engines, extractors, modules, and clients freely, subject to attribution.
If your use case requires a commercial license for the core (for example, proprietary modifications without source disclosure), contact license@democr.ai.
The repository root LICENSE file describes the split and lists the directory-specific licenses. Full license texts are in the corresponding directories (democrai/core/LICENSE for AGPL-3.0, democrai/sdk/LICENSE for Apache-2.0).
Acknowledgments
The A2UI protocol is a Google open specification for agentic UI. Democr.ai extends it to make the whole application server-driven and potentially controllable by agents.
This project builds on the work of the open-source Python ecosystem, including SQLAlchemy, FastAPI, Alembic, Pydantic, gRPC, Qt, and many others.
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 democrai-0.0.1b1.tar.gz.
File metadata
- Download URL: democrai-0.0.1b1.tar.gz
- Upload date:
- Size: 774.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebaa28cf473dde89f2f700dabbc62747c010c4ccf3fcef91b0bef78131eaf5ae
|
|
| MD5 |
4b9ea9c9702ad109abd1d55c860fbc13
|
|
| BLAKE2b-256 |
ab5d996b5e601a73ee8773137b68a197e7d74ea3c260a8165576dd032d21a045
|
File details
Details for the file democrai-0.0.1b1-py3-none-any.whl.
File metadata
- Download URL: democrai-0.0.1b1-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
354bded2f63031a1d59153c270d53bd08b43d70ebec7bad54cd516a02169bf97
|
|
| MD5 |
d9781eeeb4d2860abcc74a5d6fa16607
|
|
| BLAKE2b-256 |
e38f34e70fadbabc7f1bfd0916eafa830bed7ea2c95e5a578eb76e23064c739b
|