LogicPup: Visual Python IDE & AST Engine
LogicPup is an educational technology platform designed to lower the barrier to entry for learning programming. It allows users to build executable Python programs by connecting visual nodes (flowcharts) rather than typing syntax.
The Custom AST Compiler
The most complex engineering challenge of LogicPup was building the translation layer that converts a 2D visual graph into valid, executable Python code.
1. Graph Traversal (React Flow)
The frontend utilizes React Flow to render the drag-and-drop node interface. When a user connects a "For Loop" node to a "Print" node, the system generates a directed acyclic graph (DAG) representing the logical flow.
2. The Abstract Syntax Tree (AST) Generation
Instead of naive string concatenation (which is error-prone and insecure), the custom engine parses the React Flow JSON into an intermediate Abstract Syntax Tree (AST).
- It validates variable scopes.
- It ensures loops and conditional branches are properly nested.
- It detects infinite loops or unreachable nodes.
3. Code Generation & Execution
The validated AST is then transpiled into clean, idiomatic Python code. To execute the code safely, the backend routes the execution to an isolated, ephemeral Docker container (or a WebAssembly Python runtime like Pyodide directly in the browser). This guarantees that malicious or broken code cannot affect the host server.
Gamification & State Persistence
LogicPup incorporates an 8-level gamified curriculum. User progress, unlocked nodes, and saved flowcharts are stored in a highly normalized PostgreSQL database. Authentication is handled securely via standard OAuth providers, ensuring a frictionless onboarding experience for students and educators alike.