Architecture Overview¶
This page complements the Integrating Django with Electron by highlighting how the moving pieces fit together. Use it as a quick reference while adapting DJDesk patterns to your own project.
Process model¶
electron/main.js boots Django either via the bundled python-build-standalone interpreter or the system interpreter. Startup flow:
Discover an open port with
get-port.Spawn
run_django.py(when bundled) ormanage.py runserver(when relying on system Python) withDJANGO_SETTINGS_MODULEpointing atdjdesk.settings.local.Poll
/until Django responds, then load the renderer window.Stream Django stdout/stderr to the terminal for quick debugging.
preload.cjs now exposes window.djdeskNative so drag/drop paths, desktop notifications, and shell.openExternal deep links are mediated through a single bridge. The preload layer dispatches djdesk:workspace-drop events with sanitized file paths, stages the wizard hint under djdesk.wizard.projectPath, and proxies notification/deep-link requests back to electron/main.js via IPC.
Renderer data flow¶
The dashboard is server-rendered;
DashboardViewpopulatesworkspace,doc_links,task_presets, and other context so the first paint always has meaningful data.inspector/static/inspector/app.jspolls/api/workspaces/<slug>/status/to keep the scan queue, insights, schema graph, and log stream updated. Submitting the assistant form returns the same payload so the UI can refresh immediately.django-tasksexecutes commands synchronously viaImmediateBackend. Swapping in Celery/Redis later will not change the REST payload or UI contract because theTaskPreset+WorkspaceTaskRunmodels stay stable.
Native hooks¶
Drag/drop wizard priming – the preload script fires
djdesk:workspace-dropevents whenever a region tagged withdata-dropzonereceives a file drop and stores the normalized path underdjdesk.wizard.projectPath.app.jslistens for the event to update the sidebar dropzone, while the wizard form reads/clears the staged path on load.Notifications –
app.jscallswindow.djdeskNative.notifywhen task runs finish so Electron’s main process can raise an OS notification. Browsers fall back to the Web Notifications API when the bridge is absent.Doc deep links – links annotated with
data-doc-linkstill open the in-app drawer, but they also callwindow.djdeskNative.openExternalso the system browser mirrors the same Read the Docs location.Offline indicator – templates expose
data-offline-indicatorsonavigator.onLineupdates the status bar.
Frontend assets¶
No JS bundler is required for the reference build—inspector/static/inspector/app.css and app.js are served as-is. This keeps contribution friction low and mirrors how many Django teams work today. You can always migrate to Vite or another bundler after validating the Electron integration.