How newcat/baklavajs works
Project Type and Purpose
• BaklavaJS is a modular, plugin-based graph/node editor ecosystem for the browser, written in TypeScript and published as multiple npm packages (monorepo managed with Yarn, Lerna, and Nx).
• Core functionality lives in @baklavajs/core, with optional plugins (engine, events, interface-types, renderer-vue, themes) that extend or render the editor.
File Structure
• Top-level:
• Configuration & CI: .github/workflows/*, lerna.json, nx.json, package.json, tsconfig.json, typedoc.json
• Documentation: docs/ (VitePress site with guides, API docs, examples)
• Packages: packages/ – each subfolder is an npm package:
– core – graph API, nodes, events, editor model
– engine – execution engines (dependency, forward)
– events – event system & hooks
– interface-types – type-safe node interface definitions & converters
– renderer-vue – Vue components to display and interact with the graph editor
– themes – Sass/CSS theme bundles
– full – bundle combining core + all plugins
• Build/Test configurations per package: tsconfig.json, jest.config.js, build scripts.
README Insights
• Describes high-level architecture: core + plug-and-play plugins.
• Emphasizes extensibility and type safety.
• Lists available plugins and their roles.
Main Components
a. Monorepo Management Layer
• Yarn Workspaces / Lerna / Nx – orchestrates builds, versioning, publishing.
b. Core Package (@baklavajs/core)
• Graph model, node definitions, connection logic, event hooks API.
c. Plugin Packages
• Engine Plugin (@baklavajs/engine) – computation strategies, topological sort.
• Event System (@baklavajs/events) – subscribable hooks, proxies.
• Interface Types (@baklavajs/interface-types) – typed interfaces, converters.
• Vue Renderer (@baklavajs/renderer-vue) – UI layer (components, commands, context menus).
• Themes (@baklavajs/themes) – styling engine for renderer.
• Full Bundle (baklavajs / packages/full) – pre-bundled core + all plugins.
d. Documentation Site (VitePress)
• Pulls TS doc comments, Markdown guides.
e. CI/CD Pipelines
• Build, test, bundle and npm publish workflows.
Relationships and Interactions
• Core is the foundation: every plugin imports and extends core APIs.
• Engine plugin consumes core’s graph & node definitions to execute computations.
• Events plugin provides hook system used by core and engine for lifecycle events.
• Interface-types plugin attaches metadata to core’s node interfaces and integrates with engine’s converters.
• Renderer-vue plugin renders core’s graph model in the browser; depends on core, events, interface-types, and themes.
• Themes plugin supplies CSS/SCSS styling imported by renderer-vue.
• Full bundle re-exports core and all plugins in one package for easy installation.
• Documentation site is a separate consumer of the packages for examples and API docs.
• CI/CD orchestrates builds and publishing for all packages.
Architectural Patterns & Principles
• Monorepo with isolated, versioned packages (Lerna + Yarn Workspaces + Nx).
• Plugin architecture: core defines interfaces; plugins add cross-cutting concerns (engine, types, UI, styles).
• Separation of concerns: model (core), execution (engine), typing (interface-types), UI (renderer-vue), styling (themes), docs.
• Dependency inversion: core defines abstractions, plugins implement or extend them.
• Type safety enforced via TypeScript across all layers.