This page is the operational entrypoint for working on Democr.ai modules.
The application is a multi-runtime system:
- the desktop client talks to the backend through IPC
- the web client talks to the backend through WebSocket
- modules must stay behind the SDK boundary, regardless of transport
If you remember only one rule, remember this one: inside modules/*, engines/*, and extractors/*, import public APIs from democrai.sdk.*, not democrai.core.*.
1. Create the Environment¶
From the application root:
bash setup_venv.sh
source .venv/bin/activateIf you install dependencies manually, always keep constraints enabled:
source .venv/bin/activate
pip install -r requirements.txt -c constraints.txt
pip check2. Understand Setup Mode¶
The runtime looks for config.yaml in the application data directory.
- if
config.yamlis missing, the application starts in setup mode - in setup mode, bootstrap uses minimal local providers
- once setup is completed and
config.yamlexists, the full runtime boots normally
Useful config examples in the repository:
config.example.yamlconfig.distributed.example.yaml
Validate a config file before using it:
source .venv/bin/activate
python main.py validate-config --path ./config.example.yaml3. Run the Application¶
Default launch¶
source .venv/bin/activate
python main.pyWith no explicit --mode, the runtime starts in desktop mode.
Desktop mode¶
python main.py --mode desktopIn desktop mode:
- the core runtime uses IPC as the primary transport
- the default client is
qtdesktop - the desktop client communicates with the backend through IPC
- if you do not pass
--http, the embedded server is limited to the desktop/media-proxy flow
The default Qt client lives under clients/qtdesktop.
Desktop mode with HTTP enabled¶
python main.py --mode desktop --httpThis is still desktop mode, but it also exposes the HTTP/WebSocket server.
Use this when you need:
- the desktop application
- plus HTTP/WebSocket access for browser tools, hybrid flows, or external debugging
You can also combine desktop mode with a web client:
python main.py --mode desktop --http --client webclientServer mode¶
python main.py --mode serverIn server mode:
- no client is started by default
- the backend exposes the WebSocket/HTTP transport
- browser clients talk to this runtime over WebSocket
To start a browser client from the runner:
python main.py --mode server --client webclientThe runner executes yarn dev in the selected client root:
clients/webclient
If your shell is already inside a client directory, call the runner through the relative application path:
python ../../main.py --mode server --client webclientOptional worker scaling:
python main.py --mode server --workers 4Dev mode¶
python main.py --mode desktop --dev 1
python main.py --mode server --dev 1--dev enables development-oriented runtime behavior. Keep the value explicit because it is parsed as an integer flag.
Runtime extension paths¶
The runner sets these environment variables when they are missing:
DEMOCRAI_MODULES_PATH
DEMOCRAI_ENGINES_PATH
DEMOCRAI_EXTRACTORS_PATHBy default they point to the application root directories:
modulesenginesextractors
Override them before launching when you want the runtime to discover extensions from another location.
4. Run Migrations¶
Democr.ai manages more than one migration target.
Main commands:
python main.py migrate all
python main.py migration-status allTargeted migrations are also supported:
python main.py migrate db
python main.py migrate data
python main.py migrate kg
python main.py migrate vector
python main.py migrate observabilityCreate a new migration:
python main.py create-migration db -m "add users index"
python main.py create-migration data -m "add module table" --autogenerate
python main.py create-migration data -m "add module table" --autogenerate --module ticketsWhen --module <name> is used with the data target, autogenerate imports the module models from the runtime module path and writes the migration inside that module, for example modules/tickets/migrations/versions.
Rollback:
python main.py rollback db --steps 1
python main.py rollback data --to <revision>What these targets mean:
db: main application databasedata: module-owned relational storagekg: knowledge storagevector: vector storageobservability: observability storage
5. Check Runtime State¶
Useful CLI commands during development:
python main.py module-status --json
python main.py knowledge-rebuild --all --dry-run
python main.py reset-installreset-install removes the active installation config and returns the app to setup mode.
6. SDK Boundary Rule¶
Inside modules/*, import from SDK domains only.
Good:
from democrai.sdk.decorators import action
from democrai.sdk.auth import permission_required
from democrai.sdk.client import active_sdk as sdkBad:
from democrai.core.application.routing.router import Router
from democrai.core.infrastructure.database.models import UserIf a module, engine, or extractor capability is missing, extend the SDK first and then consume it from the extension code.
7. Choose the Right SDK Domain¶
Use the domain that matches the responsibility:
sdk.effects: action return effects and incremental UI updatessdk.models: CRUD for core-managed entitiessdk.database: persistence for module-owned tablessdk.media: uploads, downloads, persisted files, media referencessdk.ai: tools, agents, pipelines, provider-backed AI callssdk.tasks: background work and progresssdk.i18n: translations and language helpers
The module author should not care whether storage is local or distributed. That is exactly why media and persistence must go through the SDK.