How dralletje/notebook-experiments works
Main Components
• Lezer Playground Module – This is the dedicated section for testing and visualizing Lezer grammars. It features its own HTML, a React-based front end (in src/), and multiple packages (like lezer-inspector, lezer-generator-worker, etc.) that manage grammar analysis and transformation.
• Simple Notebooks Module – This module hosts the notebook experiments and is separated into a web-app (with React-based components such as App.jsx, Notebook.jsx, etc.), a node-based engine (node-engine directory), and supplementary packages specific to notebook operations.
• Common / Shared Packages – There is a top-level "packages" directory (and additional package subdirectories under lezer-playground and simple-notebooks) that provides libraries for CodeMirror features, transformation routines, worker helpers, and other utilities shared by the frontend and backend components.
• Configuration and Build/Deployment Tools – At the repository level, you have configuration files (like .gitignore, vercel.json, vite.config.js, and turbo.json) plus Yarn configuration and plugin management that support development and deployment.
Relationships and Interactions
• The front-end applications (Lezer Playground and the Simple Notebooks web-app) interact with shared libraries through direct package imports, often leveraging React components and CodeMirror editors to present rich editing and syntax-highlighting experiences.
• Worker processes and environment-specific components (workers in transform-javascript, typescript-server-webworker, and worker-typescript-magic) illustrate the separation of long-running background tasks from the main UI threads. Represent them as separate compute nodes connected to the UI via a defined communication channel (e.g., websockets or message passing).
• The node-engine within Simple Notebooks shows a backend-processing pipeline that acts as a computation layer (it includes circuits, testing suites, and file management routines) which links to the web-app, likely via APIs or shared event handling.
Architectural Patterns and Design Principles
• Modular Design – The repository leverages a highly modular structure, with clear separation between the UI, business logic (node-engine), shared libraries, and worker components. This promotes reusability and maintainability.
• Separation of Concerns – There is a clear delineation between editor UI components, parsing/processing logic (with Lezer and CodeMirror integrations), and background worker channels.
• Micro Frontends / Plugin-Based Architecture – The large number of specialized packages (for example, codemirror-x-react, inspector-x-react, use-immer-store, etc.) suggest that adding or swapping functionality might be done in a plug-and-play manner.
Relevant Technologies and Frameworks
• React and JSX components are the foundation for the user interfaces in both Lezer Playground and the Simple Notebooks web-app.
• CodeMirror is used extensively for code editing, syntax highlighting, and interactive functionality.
• Lezer is employed for grammar generation and inspection.
• Workers (webworkers) and node-based scripts indicate a design choice to offload heavy computations, likely in a concurrent manner.
• Yarn is used for package management along with configuration data in files like .yarnrc.yml.