How usewaypoint/email-builder-js works
Project type and purpose
• Project type: A monorepo (npm/yarn workspace) containing
– A no-code email template editor (React SPA in packages/editor-sample),
– A core builder library (packages/document-core),
– Individual block packages (packages/block-avatar, block-button, …),
– A reader/renderer library (packages/email-builder).
• Purpose: Let developers embed a drag-and-drop email template builder in their apps, produce a JSON configuration or HTML string, and then send that via email APIs or render in a React page.
File structure
• Top-level config & CI: ESLint, Prettier, GitHub Workflows (ci.yaml, github-pages.yaml).
• packages/block-*: Self-contained React “block” components with their own tests and tsconfigs.
• packages/document-core: Shared code for building block configurations, schemas, and React block wrappers.
• packages/editor-sample: React + Vite SPA demonstrating the builder UI. It imports document-core and block-* packages.
• packages/email-builder: React Reader component and renderToStaticMarkup for server-side or client‐side HTML output.
• Root ensures all packages share common tsconfig and dependency management.
README insights
• It describes the builder’s input/output (JSON or HTML), the playground/demo, and consumption patterns (nodemailer, HTTP email API).
• Highlights that each block is an independent npm package.
• Mentions self-hosting instructions (using editor-sample).
Main components & interactions
a. Components
1. Monorepo Package Manager (Yarn/NPM workspace)
2. Block Packages (block-avatar, block-button, …)
3. Document Core (builders + utils)
4. Editor Sample (React SPA + Inspector UI)
5. Email Builder (Reader component + renderToStaticMarkup)
6. External Email Senders (nodemailer, Waypoint API, etc.)
b. Relationships
– Editor Sample imports Document Core and all Block Packages. User actions in the UI ► produce a configuration JSON.
– Document Core orchestrates block configuration schemas and component builders.
– The configuration JSON can be passed to Email Builder:
• <Reader /> React component (client).
• renderToStaticMarkup() (server or client) ► outputs raw HTML.
– HTML output flows to External Email Senders (nodemailer process or HTTP POST).
c. Architectural patterns/principles
– Monorepo workspace with isolated package per block for independent versioning and tests.
– Plugin-style architecture: blocks are plugins to the core builder.
– Separation of concerns: core building logic vs. UI vs. rendering.
– TypeScript enforced across all packages.
d. Key technologies
– React + Vite (editor UI)
– TypeScript + Zod (schema validation in document-core)
– Jest (unit tests, snapshots)
– renderToStaticMarkup (ReactDOMServer)
– npm/yarn workspaces