jdm-electron-flask
v1.1.0
Published
JDM Electron + Flask plugin for jdm-cli
Readme
jdm-electron-flask
A
jdm-cliplugin for scaffolding and managing full-stack desktop apps built with Electron + Flask + React.
What is this?
jdm-electron-flask is a plugin for jdm-cli that gives you a complete workflow for building, running, and packaging desktop applications where:
- Electron is the desktop shell
- Flask (Python) is the backend API server
- React (Vite) is the frontend UI
The plugin handles everything — scaffolding, dev servers, production builds, and packaging the backend into a standalone .exe — so you never have to wire it up yourself.
Project Structure
When you scaffold a project with create, this is the layout you get:
my-app/
├── backend/ # Python + Flask API server
│ ├── run.py # Dev entry point
│ ├── production_run.py # Production / PyInstaller entry point
│ ├── requirements.txt
│ └── .env
├── frontend/ # React + Vite UI
│ ├── src/
│ ├── package.json
│ └── .env
├── electron/ # Electron shell
│ ├── resources/
│ │ └── backend/ # flask_server.exe lands here after compile
│ ├── package.json
│ └── outputs/ # Versioned build outputs
├── .jdm-config.json # Plugin version config (auto-generated)
└── run.bat # Shortcut wrapper (Windows)Prerequisites
| Tool | Why |
|---|---|
| Node.js >=18 | Electron + frontend build |
| Python >=3.9 | Flask backend |
| Git | Cloning templates during create |
| PyInstaller | Packaging backend to .exe via toexe |
| jdm-cli | The CLI host |
Install PyInstaller once globally:
pip install pyinstallerInstallation
Install the plugin via jdm-cli:
jdm-cli install electron-flaskOr install the package directly:
npm install -g jdm-electron-flaskQuick Start
Tip: If you're using JDM Plugin Manager, you can install, run, and manage this plugin directly from the UI — no terminal needed for most workflows.
# 1. Scaffold a new project
jdm-cli electron-flask create
...Or as a standalone callout at the end of the Installation section:
## Installation
Install the plugin via `jdm-cli`:
```bash
jdm-cli install electron-flask
```
Or install the package directly:
```bash
npm install -g jdm-electron-flask
```
> **Prefer a GUI?** Open **JDM Plugin Manager**, find `electron-flask` in the Available Plugins tab, and hit Install — then run any command from the plugin's runner without touching the terminal.Pick whichever placement feels right. The second (end of Installation) is less intrusive since Quick Start is where people want to move fast.
Commands
create
Scaffolds a new project by cloning the three template repositories.
jdm-cli electron-flask create
# → prompts for a project name (or . to use current folder)
jdm-cli electron-flask create --install
# → also runs npm install / pip install after cloningWhat it does:
- Clones
backend,frontend, andelectrontemplate repos - Strips
.githistory from each (clean slate) - Copies
.env.example→.envin backend and frontend - Generates a
run.batshortcut for Windows - Writes
.jdm-config.jsonto track the plugin version used
install
Installs dependencies for all three sub-projects.
jdm-cli electron-flask installWhat it does:
- Runs
pip install -r requirements.txtinbackend/ - Runs
npm installinfrontend/ - Runs
npm installinelectron/
Run this from the project root (the folder containing
backend/,frontend/,electron/).
dev
Launches both the Flask backend and the Vite frontend in separate terminal windows (or tabs).
jdm-cli electron-flask devWhat it does:
- Opens
backend/runningpython run.pyin a new terminal - Opens
frontend/runningnpm run devin a new terminal - On Windows: prefers Windows Terminal tabs, falls back to new CMD windows
- On macOS/Linux: tries
gnome-terminal,xterm, thenosascript
You can close the original command window once both servers are up.
prod
Launches a production preview — same as dev but uses the production entry points.
jdm-cli electron-flask prodWhat it does:
- Opens
backend/runningpython production_run.py - Opens
frontend/runningnpm run devwithVITE_MODE=production
toexe
Packages the Flask backend into a standalone Windows executable using PyInstaller. No Python installation needed on the target machine.
jdm-cli electron-flask toexeWhat it does:
- Cleans previous
build/,dist/, and.specartifacts frombackend/ - Validates that
backend/production_run.pyexists - Runs PyInstaller with
--onefile --noconsole - Automatically bundles
app/,static/,resources/, and.envif they exist
Output: backend/dist/flask_server.exe
compile
Full production build in one command — frontend, backend EXE, and Electron installer.
jdm-cli electron-flask compileSteps:
- Frontend —
npm run buildwithVITE_MODE=deployed - Backend EXE — runs
toexeinternally - Move EXE — copies
flask_server.exe→electron/resources/backend/ - Electron —
npm run distto build the installer - Version output — moves the build output to
electron/outputs/<version>/
If a versioned output folder already exists, it will ask before overwriting.
Errors at any step are written to compile.log in the project root (auto-deleted on success).
clean
Removes build artifacts.
jdm-cli electron-flask cleanTargets:
backend/build/backend/dist/backend/flask_server.specelectron/dist/
Prints a summary of what was removed, skipped, or failed.
Config & Compatibility
Every project created by this plugin contains a .jdm-config.json file:
{
"plugin": "electron-flask",
"pluginVersion": "1.0.13",
"createdAt": "2025-01-01T00:00:00.000Z"
}This lets the plugin detect when a project was scaffolded with an older (or incompatible) version. If you update the plugin and run a command against an older project, you may see:
✖ Compatibility error for command: compile
Project was created with plugin version 1.0.9,
but "compile" requires >=1.0.10.
Tip: Re-scaffold with jdm-cli electron-flask createTo resolve: re-run create in your project folder, or downgrade the plugin to the version that matches your project.
Shortcut (Windows)
Every scaffolded project includes a run.bat wrapper so you can call commands without the full jdm-cli electron-flask prefix:
run dev
run compile
run cleanLogs
Long-running commands write a log file to the project root on failure:
| Command | Log file |
|---|---|
| create | install.log |
| install | install.log |
| compile | compile.log |
| toexe | toexe.log |
Logs are automatically deleted if the command succeeds.
Template Repositories
| Part | Repository | |---|---| | Backend | jdm-electron-flask-backend | | Frontend | jdm-electron-flask-frontend | | Electron | jdm-electron-flask-electron |
License
MIT © JDM-Github
