Project Overview
The Template Playground is a React-based web application built with Vite and TypeScript. It provides an interactive environment for working with Accord Project templates, combining TemplateMark, Concerto models, and data to generate agreements.Technology Stack
Core Technologies
- React 18: UI framework with hooks and functional components
- TypeScript: Type-safe JavaScript with strict mode enabled
- Vite: Fast build tool and development server
- Zustand: Lightweight state management with middleware support
Accord Project Libraries
- @accordproject/concerto-core: Data modeling and validation
- @accordproject/template-engine: TemplateMark interpretation and execution
- @accordproject/markdown-template: TemplateMark parsing and transformation
- @accordproject/markdown-transform: Converting between markdown formats (HTML, PDF)
UI & Styling
- Ant Design: Component library for UI elements
- Monaco Editor: Code editor for template, model, and data editing
- Styled Components: CSS-in-JS styling
- Tailwind CSS: Utility-first CSS framework
Directory Structure
Core Components
State Management (store/store.ts)
The application uses Zustand for state management with:- Immer middleware: Immutable state updates
- DevTools middleware: Redux DevTools integration
- Persistence: LocalStorage for theme, UI panels, and settings
Key State Properties
Key Actions
setTemplateMarkdown(): Update template and rebuildsetModelCto(): Update model and rebuildsetData(): Update data and rebuildrebuild(): Regenerate agreement from current stateloadSample(): Load a predefined samplegenerateShareableLink(): Create compressed shareable URLloadFromLink(): Load state from compressed URL
Template Processing Pipeline
The rebuild process instore/store.ts follows this flow:
Editor Components
ConcertoEditor.tsx
Monaco editor configured for Concerto modeling language:- Syntax highlighting for
.ctofiles - Real-time validation
- Debounced updates to store
MarkdownEditor.tsx
TemplateMark editor with:- Custom toolbar for TemplateMark syntax
- Command palette integration
- Markdown preview
JSONEditor.tsx
JSON data editor with:- Syntax validation
- Pretty printing
- Error highlighting
AI Assistant (ai-assistant/)
The AI assistant provides intelligent template help:- llmProviders.ts: Integrations for OpenAI, Anthropic, Google, Mistral
- chatRelay.ts: Message routing and streaming responses
- autocompletion.ts: Context-aware code suggestions
- activityTracker.ts: User interaction tracking for better AI context
Sharing & Compression (utils/compression/)
The playground supports sharing templates via URL:lz-string library for efficient compression.
Configuration Files
vite.config.ts
- Node.js polyfills for browser compatibility
- React plugin with Fast Refresh
- Bundle visualization
- Vitest configuration
tsconfig.json
- Strict TypeScript checking enabled
- ESNext module resolution
- React JSX transform
- Vitest globals included
.eslintrc.cjs
- TypeScript ESLint rules
- React hooks linting
- React Refresh plugin
Data Flow
Testing Strategy
Unit Tests (Vitest)
- Component tests using React Testing Library
- Store logic tests
- Utility function tests
- Located in
src/tests/
E2E Tests (Playwright)
- Full user journey tests
- Cross-browser testing
- Configured in
playwright.config.ts
Build Process
The production build:- TypeScript Compilation: Type checking and transpilation
- Vite Build: Bundle optimization and code splitting
- Memory Allocation: Increased heap size for large dependencies
- Output: Static files ready for deployment
Next Steps
Testing Guide
Learn how to write and run tests
Contribution Guidelines
Review our contribution standards