Architecture
Overview
A2UI Vue Engine follows a modular architecture with clear separation of concerns:
┌─────────────────────────────────────────────────────────────┐
│ Application Layer │
│ (Your Vue App - Uses A2UIRoot to render JSON schemas) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ A2UIRoot Component │
│ - Receives JSON messages │
│ - Manages state (tree, data) │
│ - Provides context to children │
│ - Emits events (message, formDataChange) │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Message Processor │
│ - Processes JSONL stream │
│ - Handles node/data messages │
│ - Converts flat format to tree │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Renderer │
│ - Renders tree to Vue components │
│ - Handles data binding │
│ - Executes actions │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Component Library │
│ - A2Card, A2Row, A2Column │
│ - A2TextField, A2Input, A2SelectField │
│ - A2Text, A2Icon, A2Button │
└─────────────────────────────────────────────────────────────┘Core Modules
A2UIRoot.vue
The root component is the main entry point. It:
- Accepts JSON input via
processMessage()orstreamUrl - Maintains state:
tree(render tree),data(form values) - Provides form data: via
getFormData()andformDataChangeevent - Exposes methods:
updateTree(node)- Update the render treeupdateData(values)- Update form valuesgetData()- Get current datagetFormData()- Get extracted form structureprocessMessage(msg)- Process A2Message
MessageProcessor
Handles streaming JSON messages:
typescript
interface A2Message {
type: 'node' | 'node_update' | 'data' | 'data_update' | 'action' | 'error' | 'complete'
id: string
// ... specific fields per type
}Renderer
Converts tree nodes to Vue VNodes:
typescript
function renderTree(node: A2Node, context: RenderContext): VNodeData Flow
- Input: JSON schema → A2UIRoot.processMessage()
- Processing: MessageProcessor parses and updates tree
- Rendering: Renderer creates VNodes from tree
- Binding: Props are resolved from data context
- Events: Actions emit messages back to parent
Form Data Extraction
A2UIRoot automatically extracts form fields from the schema:
typescript
interface FormDataResult {
form: Record<string, string>
}Fields are extracted from:
- Tree format:
props.propon form components - Flat format:
value.pathmatching/form/{fieldName}