How paulledemon/pyuibuilder works
Project Type & Purpose
• PyUIBuilder is a web-based, single-page React application that lets users drag-and-drop UI widgets and outputs Python GUI code (Tkinter, CustomTkinter).
• There is no traditional backend service in this repo; all code generation happens in the client.
Top-Level Components
From the file tree, identify these major subsystems:
a. UI Layer (src/components, src/sidebar, src/styles, public/)
b. Canvas & Drag-Drop Engine (src/canvas, FabricJS integration)
c. State Management (src/redux, src/contexts)
d. Code Generation Engine (src/codeEngine + src/frameworks)
e. Framework Plugins (src/frameworks/tkinter, src/frameworks/customtk)
f. Static Assets & Landing Pages (demos/, docs/, landingpages/)
g. Build & Deployment (webpack.config.js, tailwind.config.js, package.json)
Relationships & Data Flows
• User → UI Layer: Users interact via React components (toolbars, sidebars, canvas).
• UI Layer ↔ State Management: React components dispatch actions to Redux and read from Contexts (fileUploadContext, resizeContext, etc.).
• UI Layer → Canvas Engine: Canvas modules (fabric.js) render and manage widget placement.
• Canvas Engine → State: Canvas events (drag, resize) update shared state.
• UI Layer → Code Generation Engine: On “Generate Code,” the current state/tree of widgets is passed to src/codeEngine/utils.js.
• Code Engine → Framework Plugins: The engine invokes code templates in src/frameworks/<framework>/engine and componentCodes.
• Framework Plugins → Code Output: Templates produce Python code strings and a downloadable ZIP or file.
• UI Layer → Download: The generated code is sent back to the browser for user download.
• External Services: Optional analytics script (env var REACT_APP_ANALYTICS_SCRIPT_ID), hosted docs site, GitHub Pages for landing pages.
Architectural Patterns & Principles
• Component-Based UI (React functional components + hooks).
• Modular Plugin Architecture: Each framework implements a uniform interface—constants, engine code, componentCodes, plugins.
• Unidirectional Data Flow: Redux + React Contexts enforce predictable state updates.
• Separation of Concerns:
• UI Rendering vs. Canvas Logic vs. Code Generation.
• Framework-specific code isolated under src/frameworks.
Detailed Component Breakdown
• UI Layer:
• src/components (cards, inputs, modals, video-popup)
• src/sidebar (pluginsContainer, treeview, uploads)
• src/styles (Tailwind CSS, index.css)
• public (index.html, manifest.json)
• Canvas Engine:
• src/canvas/* (canvas, toolbar, widgets, utils, FabricJS integration)
• State Management:
• src/redux/store.js + assetSlice
• src/contexts (fileUploadContext, resizeContext, widgetContext)
• Code Generation:
• src/codeEngine/utils.js
• src/frameworks/*/engine & componentCodes
• Framework Plugins:
• tkinter (engine, plugins, pythonWidgets)
• customtkinter (engine, plugins, sidebarWidgets)
• Deployment & Docs:
• webpack.config.js, postcss.config.js, tailwind.config.js
• docs/ (Jekyll assets, GitHub Pages)
• landingpages/ (marketing landing pages)