How arjundivecha/mlx-finetune-gui works
Main Components
• Electron Main Process (src/main.ts, debug_electron.py)
• React Frontend (frontend/src with Redux, React Router, WebSocket client)
• FastAPI Backend (backend/main.py)
• MLX Training Subsystem (Training Manager invoking run_finetune.py in MLX venv)
• Adapter Fusion Module (adapter_fusion folder with Python scripts to merge LoRA adapters)
• File System (model directories, dataset JSONL, logs, lora_adapters output)
• External MLX Environment (venv path pointing to local_qwen/.venv)
Relationships & Data Flows
• Electron main starts both the React renderer and the FastAPI server (spawn + IPC)
• React communicates with FastAPI via REST (HTTP) for control operations and via WebSocket for live updates
• FastAPI’s Training Manager invokes MLX fine-tune commands in the external venv, monitors log files, and parses metrics
• Adapter Fusion routines can be triggered via backend endpoints or CLI tests to merge multiple LoRA adapters
• File dialogs and filesystem operations (model discovery, dataset selection, adapter outputs) use Electron IPC to access OS APIs
• Frontend stores session state in Redux and persists to disk via backend file-I/O
Architectural Patterns
• Full-Stack Desktop: Electron shell containing a single-page React frontend and embedded FastAPI backend
• MVC-Like Separation:
• View: React components/pages (Setup, Training, Results, Compare)
• Controller: FastAPI endpoints & WebSocket handlers
• Model: Redux store slices and Python Training Manager state
• Real‐Time WebSocket Pattern for push‐style training updates
• Modular Python utilities (adapter_fusion) decoupled from core backend but integrated via Python imports or CLI
Technologies & Frameworks
• Electron (Node.js + Chromium) for desktop packaging
• React + Redux Toolkit + React Router + Tailwind CSS + Chart.js in the renderer
• FastAPI + WebSockets + uvicorn for backend
• Python MLX framework (LoRA fine-tuning on Apple Silicon)
• Adapter Fusion using safetensors and custom Python scripts
• IPC channels for Electron ↔ backend and Electron ↔ filesystem dialogs