NEXT STEPS PLAN
Comprehensive guidelines for AI-assisted development within the Editor platform
Universal Visual Compositor - Next Steps Plan 🎯
✅ What We Just Fixed
Resize Slide Bug - FIXED ✅
- Problem: Resize handles were triggering drag behavior
- Solution: Operation mutual exclusion with signal-based state tracking
- Result: Precise, professional-grade resize/rotate/drag controls
- Files Modified:
visual-element.component.ts(addedisResizingActive,isRotatingActivesignals)
Current Status: Foundation is Solid 🏗️
- ✅ All 6 demo shapes have control points for connections
- ✅ Event-driven architecture (no setTimeout violations)
- ✅ Proper signal usage throughout
- ✅ Professional interaction patterns
- ✅ Zero linter errors
- ✅ Canvas and framer are production-ready
🎯 Vision: Imagination to Life
We're building a JSON-based universal prototyping system where:
- AI can generate anything through JSON definitions
- Everything persists - shapes, connections, behaviors, interactions
- Full interactivity - attach functionality to any shape
- Animation-ready - integrates with
@scroll-triggerfor advanced animations - Reusable & Extensible - templates, components, libraries
Key Principle: Before animations, the canvas and builder must be perfect.
📋 Immediate Action Plan
Phase A: JSON-First Architecture (CRITICAL) 🔴
Objective: Make EVERYTHING JSON-definable and serializable
1. Complete Composition Type ✅ (Extend existing)
File: libs/universal-visual-compositor/src/lib/models/visual-element.types.ts
Add:
export interface Composition {
version: string;
name: string;
description?: string;
metadata: {
created: string;
modified: string;
author?: string;
tags?: string[];
};
canvas: {
width: number;
height: number;
background?: string;
viewBox?: string;
};
elements: VisualElement[];
connections: Connection[];
interactions?: InteractionDefinition[];
animations?: AnimationDefinition[];
styles?: Record<string, any>;
}
export interface InteractionDefinition {
id: string;
elementId: string;
event: 'click' | 'hover' | 'drag' | 'resize' | 'custom';
actions: Action[];
conditions?: Condition[];
}
export interface Action {
type: 'navigate' | 'emit' | 'animate' | 'transform' | 'setState' | 'script';
params: Record<string, any>;
}
export interface AnimationDefinition {
id: string;
elementIds: string[];
trigger: 'load' | 'click' | 'scroll' | 'custom';
timeline: Keyframe[];
}
export interface Keyframe {
time: number; // 0-1 or milliseconds
properties: Record<string, any>;
easing?: string;
}
Files to Create:
libs/universal-visual-compositor/src/lib/models/composition.types.ts(new)libs/universal-visual-compositor/src/lib/models/interaction.types.ts(new)libs/universal-visual-compositor/src/lib/models/animation.types.ts(new)
Why: Without JSON-first, we can't persist, replicate, or AI-generate complex compositions
2. Composition Service (NEW)
File: libs/universal-visual-compositor/src/lib/services/composition.service.ts
@Injectable({ providedIn: 'root' })
export class CompositionService {
// Serialize to JSON
exportComposition(
elements: VisualElement[],
connections: Connection[],
metadata: Partial<Composition['metadata']>
): Composition
// Deserialize from JSON
importComposition(json: string | Composition): {
elements: VisualElement[];
connections: Connection[];
metadata: Composition['metadata'];
}
// Validate composition
validateComposition(composition: Composition): ValidationResult
// Save to file
downloadComposition(composition: Composition, filename: string): void
// Load from file
loadCompositionFile(file: File): Promise<Composition>
// Templates
getTemplate(name: string): Composition
saveTemplate(composition: Composition, name: string): void
listTemplates(): string[]
}
Why: Central service for all serialization, persistence, and template management
3. Update Demo Component with Export/Import
File: apps/gograb-space/src/app/demos/universal-compositor-demo/universal-compositor-demo.component.ts
Add methods:
onExportJSON(): void {
const composition = this.compositionService.exportComposition(
this.elements(),
this.connections(),
{ author: 'Demo User', tags: ['demo', 'test'] }
);
this.compositionService.downloadComposition(composition, 'my-composition.json');
}
onImportJSON(event: Event): void {
const file = (event.target as HTMLInputElement).files?.[0];
if (!file) return;
this.compositionService.loadCompositionFile(file).then(composition => {
const imported = this.compositionService.importComposition(composition);
this.elements.set(imported.elements);
this.connections.set(imported.connections);
});
}
onSaveTemplate(): void {
const composition = this.compositionService.exportComposition(
this.elements(),
this.connections(),
{ name: 'My Template' }
);
this.compositionService.saveTemplate(composition, 'custom-template');
}
onLoadTemplate(name: string): void {
const template = this.compositionService.getTemplate(name);
const imported = this.compositionService.importComposition(template);
this.elements.set(imported.elements);
this.connections.set(imported.connections);
}
Why: Users can save/load/share compositions, demonstrating real-world usage
Phase B: Builder API (EASE OF USE) 🟡
Objective: Make programmatic creation EASY and AI-friendly
4. Composition Builder (NEW)
File: libs/universal-visual-compositor/src/lib/builders/composition.builder.ts
export class CompositionBuilder {
private elements: VisualElement[] = [];
private connections: Connection[] = [];
static create(name: string): CompositionBuilder {
return new CompositionBuilder(name);
}
// Shape builders
addCircle(id: string, x: number, y: number, radius: number, style?: ShapeStyle): this
addRectangle(id: string, x: number, y: number, width: number, height: number, style?: ShapeStyle): this
addText(id: string, x: number, y: number, text: string, style?: TextStyle): this
addPath(id: string, pathData: string, style?: ShapeStyle): this
addCustom(element: VisualElement): this
// Connection builder
connect(fromId: string, toId: string, style?: ConnectionStyle): this
// Layout helpers
arrangeGrid(elementIds: string[], columns: number, gap: number): this
arrangeFlow(elementIds: string[], direction: 'horizontal' | 'vertical', gap: number): this
arrangeCircle(elementIds: string[], centerX: number, centerY: number, radius: number): this
// Groups
group(elementIds: string[], groupId: string): this
ungroup(groupId: string): this
// Styles
applyStyle(elementIds: string[], style: Partial<ShapeStyle>): this
applyClass(elementIds: string[], className: string): this
// Interactions
onClick(elementId: string, action: Action): this
onHover(elementId: string, action: Action): this
// Build
build(): Composition
buildElements(): VisualElement[]
buildWithCanvas(width: number, height: number): Composition
}
Usage Example:
const composition = CompositionBuilder
.create('flowchart')
.addRectangle('start', 100, 100, 200, 100, { fill: '#4CAF50' })
.addRectangle('process', 100, 250, 200, 100, { fill: '#2196F3' })
.addRectangle('end', 100, 400, 200, 100, { fill: '#F44336' })
.connect('start', 'process', { pathType: 'straight', endMarker: 'arrow' })
.connect('process', 'end', { pathType: 'straight', endMarker: 'arrow' })
.onClick('start', { type: 'navigate', params: { url: '/home' } })
.build();
Why: AI can generate this code easily, developers love fluent APIs
5. Shape Factories Extension
File: libs/universal-visual-compositor/src/lib/utils/shape-factories.ts (extend existing)
Add:
// Composite shapes
export const CompositeShapes = {
button: (text: string, style: ButtonStyle) => VisualElement
input: (placeholder: string, style: InputStyle) => VisualElement
card: (title: string, content: string, style: CardStyle) => VisualElement
icon: (iconName: string, size: number) => VisualElement
arrow: (start: Point, end: Point, style: ArrowStyle) => VisualElement
}
// Layout primitives
export const LayoutPrimitives = {
flex: (children: VisualElement[], direction: FlexDirection) => VisualElement[]
grid: (children: VisualElement[], columns: number, gap: number) => VisualElement[]
stack: (children: VisualElement[], gap: number) => VisualElement[]
}
// Common patterns
export const PatternTemplates = {
flowchart: (nodes: FlowchartNode[]) => Composition
wireframe: (sections: WireframeSection[]) => Composition
diagram: (items: DiagramItem[]) => Composition
mindMap: (root: MindMapNode) => Composition
}
Why: Pre-built primitives make AI generation much easier and more consistent
Phase C: Functionality System (INTERACTIVITY) 🟠
Objective: Attach behaviors, interactions, and logic to shapes
6. Interaction Engine (NEW)
File: libs/universal-visual-compositor/src/lib/services/interaction.engine.ts
@Injectable({ providedIn: 'root' })
export class InteractionEngine {
private interactions = new Map<string, InteractionDefinition[]>();
// Register interactions from JSON
registerInteractions(interactions: InteractionDefinition[]): void
// Handle events
handleElementClick(elementId: string, event: MouseEvent): void
handleElementHover(elementId: string, event: MouseEvent): void
handleElementCustom(elementId: string, eventName: string, data: any): void
// Execute actions
private executeAction(action: Action, context: any): void
// Action handlers
private navigateAction(params: any): void
private emitAction(params: any): void
private animateAction(params: any): void
private transformAction(params: any): void
private setStateAction(params: any): void
private scriptAction(params: any): void // Sandboxed execution
}
Integration:
// In compositor-canvas.component.ts
onElementClick(element: VisualElement, event: MouseEvent): void {
this.interactionEngine.handleElementClick(element.id, event);
this.elementSelected.emit({ id: element.id, event });
}
Why: Without interactions, it's just static shapes - we need dynamic behaviors
7. Demo: Interactive Prototype
File: Add to universal-compositor-demo.component.ts
createInteractiveDemo(): void {
const button = ShapePrimitives.createRectangle({
id: 'btn-1',
position: { x: 100, y: 100 },
bounds: { width: 200, height: 60 },
style: { fill: '#2196F3', rx: 8, ry: 8 }
});
const interaction: InteractionDefinition = {
id: 'btn-1-click',
elementId: 'btn-1',
event: 'click',
actions: [
{
type: 'animate',
params: {
property: 'scale',
from: 1,
to: 1.1,
duration: 200,
easing: 'ease-out'
}
},
{
type: 'emit',
params: { event: 'button-clicked', data: { buttonId: 'btn-1' } }
}
]
};
this.elements.update(els => [...els, button]);
this.interactionEngine.registerInteractions([interaction]);
}
Why: Demonstrates real prototyping capability - clickable, animated, interactive
Phase D: Enhanced AI Generator (INTELLIGENCE) 🟢
Objective: AI generates better, data-driven compositions
8. JSON Template Library
Directory: libs/universal-visual-compositor/src/assets/templates/
Create JSON files:
flowchart-basic.json- 3-step process flowwireframe-landing.json- Hero, features, CTAdiagram-architecture.json- System componentsmindmap-ideas.json- Central idea with branchesprototype-app.json- Full interactive app layout
Why: AI loads and modifies templates instead of hardcoding shapes
9. Enhance AI Service
File: libs/universal-visual-compositor/src/lib/services/ai-generation.service.ts (update)
Add:
generateFromPrompt(prompt: string): Composition {
const intent = this.detectIntent(prompt);
const template = this.loadTemplate(intent.type);
const customized = this.customizeTemplate(template, prompt, intent);
return customized;
}
private loadTemplate(type: string): Composition {
// Load from JSON files
return this.compositionService.getTemplate(type);
}
private customizeTemplate(template: Composition, prompt: string, intent: Intent): Composition {
// Modify template based on prompt
// Extract colors, sizes, labels, etc. from prompt
// Update element properties
return modifiedComposition;
}
private extractParameters(prompt: string): Record<string, any> {
// "Create a blue button labeled 'Submit'"
// → { color: 'blue', label: 'Submit', type: 'button' }
}
Why: More flexible, maintainable, and powerful than hardcoded generation
Phase E: Demo Polish (USER EXPERIENCE) 🔵
Objective: Make demo app showcase all capabilities
10. Properties Panel (NEW COMPONENT)
File: apps/gograb-space/src/app/demos/components/properties-panel.component.ts
@Component({
selector: 'app-properties-panel',
template: `
@if (selectedElement()) {
<div class="properties-panel">
<h3>Properties</h3>
<!-- Position -->
<div class="property-group">
<label>Position</label>
<input type="number" [(ngModel)]="x" (change)="updatePosition()">
<input type="number" [(ngModel)]="y" (change)="updatePosition()">
</div>
<!-- Size -->
<div class="property-group">
<label>Size</label>
<input type="number" [(ngModel)]="width" (change)="updateSize()">
<input type="number" [(ngModel)]="height" (change)="updateSize()">
</div>
<!-- Style -->
<div class="property-group">
<label>Fill</label>
<input type="color" [(ngModel)]="fill" (change)="updateStyle()">
</div>
<!-- Rotation -->
<div class="property-group">
<label>Rotation</label>
<input type="range" min="0" max="360" [(ngModel)]="rotation" (change)="updateRotation()">
</div>
</div>
}
`
})
export class PropertiesPanelComponent {
selectedElement = input<VisualElement | null>(null);
elementChange = output<VisualElement>();
// Property bindings and update methods
}
Why: Users need precise control and visual feedback
11. Template Gallery (NEW COMPONENT)
File: apps/gograb-space/src/app/demos/components/template-gallery.component.ts
Shows:
- Thumbnail previews of templates
- Load template button
- Save current as template button
- Template metadata (name, description, tags)
Why: Discoverability and reusability
12. Export/Import UI
Add to demo toolbar:
<!-- Export/Import Section -->
<div class="toolbar-section">
<button (click)="onExportJSON()" class="toolbar-btn">
Export JSON
</button>
<button (click)="fileInput.click()" class="toolbar-btn">
Import JSON
</button>
<input #fileInput type="file" accept=".json" (change)="onImportJSON($event)" hidden>
<button (click)="onExportSVG()" class="toolbar-btn">
Export SVG
</button>
</div>
Why: Essential for real-world usage
Phase F: Real Use Cases (VALIDATION) 🟣
Objective: Prove the system works for actual projects
13. Create 10+ Example Compositions
Files: apps/gograb-space/src/app/demos/examples/
- flowchart-approval.json - Approval workflow with decision points
- wireframe-dashboard.json - Analytics dashboard layout
- diagram-microservices.json - Architecture diagram
- prototype-mobile-app.json - Mobile app screens with navigation
- mindmap-project.json - Project planning mind map
- infographic-timeline.json - Historical timeline
- ui-design-system.json - Component library showcase
- game-level-design.json - 2D game level layout
- org-chart.json - Organizational hierarchy
- network-topology.json - Network infrastructure diagram
Each includes:
- Complete JSON definition
- Interactive elements
- Connections
- Styling
- Documentation
Why: Demonstrates versatility and production-readiness
📊 Success Metrics
Phase A: JSON-First Architecture
- ✅ All types defined and exported
- ✅ CompositionService fully functional
- ✅ Round-trip (export → import) works perfectly
- ✅ Validation catches errors
Phase B: Builder API
- ✅ Fluent API feels natural
- ✅ 50%+ less code than manual creation
- ✅ AI can generate valid builder code
- ✅ Documentation with examples
Phase C: Functionality System
- ✅ Click interactions work
- ✅ Hover interactions work
- ✅ Custom actions execute
- ✅ Animations trigger properly
Phase D: Enhanced AI
- ✅ 10+ templates loaded from JSON
- ✅ AI customizes templates based on prompts
- ✅ Generated compositions are valid
- ✅ 80%+ accuracy on common requests
Phase E: Demo Polish
- ✅ Properties panel shows all editable fields
- ✅ Template gallery is browsable
- ✅ Export/import works seamlessly
- ✅ UI is beautiful and intuitive
Phase F: Real Use Cases
- ✅ 10+ complete examples
- ✅ Each example demonstrates unique capability
- ✅ All examples are interactive
- ✅ Documentation explains each
🚀 Implementation Order
Week 1: Foundation (Phases A & B)
Days 1-2: JSON types and composition service Days 3-4: Builder API and factories Days 5-7: Testing, refinement, documentation
Week 2: Functionality (Phases C & D)
Days 1-3: Interaction engine and action handlers Days 4-5: Template system and AI improvements Days 6-7: Integration and testing
Week 3: Polish (Phases E & F)
Days 1-3: Properties panel, template gallery, export/import UI Days 4-7: Create all 10 example compositions
✨ Final Vision
After these phases, we will have:
✅ JSON-First: Everything is JSON, AI-generatable, persistable ✅ Builder API: Easy to code, easy to generate ✅ Interactive: Full behavior attachment and execution ✅ AI-Powered: Smart templates, customization, suggestions ✅ Polished Demo: Professional showcase of capabilities ✅ Proven: 10+ real-world use cases
This is imagination to life. This is building anything, connecting anything, animating anything. 🎨✨
🎯 Next Immediate Action
Start with Phase A.1: Create composition.types.ts with complete type definitions.
Ready to implement?