YAML-Driven UI Architecture¶
Acumen ERP uses YAML configuration files to dynamically generate user interfaces without writing React components for every page. This revolutionary approach enables rapid development and easy customization.
Overview¶
Instead of hardcoding UI components, Acumen uses a declarative YAML-based system where you define:
- What data to display
- How to display it
- What actions are available
The YamlPageRenderer component reads these configurations and renders the appropriate UI components automatically.
Architecture¶
graph LR
YAML[YAML Config Files] --> Loader[YAML Loader]
Loader --> Parser[Parser]
Parser --> Transform[Transformer]
Transform --> Renderer[YamlPageRenderer]
Renderer --> Table[DataTable]
Renderer --> Form[Form]
Renderer --> Tabs[Tabs]
Renderer --> Custom[Custom Components]
File Structure¶
frontend/public/navigation/
├── erp-navigation.yaml # Main navigation structure
├── erp-domains.yaml # Domain configurations
└── pages/
├── companies.yaml # Company list page
├── company-detail.yaml # Company detail/edit
├── invoices.yaml # Invoice management
└── [entity].yaml # Other entity pages
Navigation Configuration¶
Main Navigation (erp-navigation.yaml)¶
application:
name: "Acumen ERP"
default_route: "/dashboard"
theme: "light"
layout: "sidebar-navigation"
# Global components available on all pages
global_components:
- id: "company_selector"
type: "select-input"
label: "Company"
data_source: "/api/company/company/"
value_key: "CompanyID"
display_key: "CompanyName"
required: true
sidebar:
sections:
# Favorites section (dynamic)
- id: "favorites"
name: "Favorites"
icon: "star"
type: "favorites"
# Finance section
- id: "finance"
name: "Finance"
icon: "dollar-sign"
active: true
items:
- id: "general-ledger"
name: "General Ledger"
route: "/finance/general-ledger"
icon: "book"
page_config: "/navigation/pages/general-ledger.yaml"
- id: "accounts"
name: "Chart of Accounts"
route: "/finance/accounts"
icon: "list"
page_config: "/navigation/pages/accounts.yaml"
- id: "invoices"
name: "Invoices"
route: "/finance/invoices"
icon: "file-invoice"
page_config: "/navigation/pages/invoices.yaml"
# Company section
- id: "company"
name: "Company"
icon: "building"
items:
- id: "companies"
name: "Companies"
route: "/company/companies"
icon: "building"
page_config: "/navigation/pages/companies.yaml"
- id: "organizations"
name: "Organizations"
route: "/company/organizations"
icon: "sitemap"
page_config: "/navigation/pages/organizations.yaml"
Page Configuration¶
Basic Page Structure¶
page:
id: "company-list"
title: "Company Management"
description: "View and manage companies in the system"
toolbar:
breadcrumbs:
- label: "Home"
route: "/"
- label: "Company"
route: "/company"
- label: "Companies"
route: "/company/companies"
actions:
- label: "Add Company"
icon: "plus"
type: "primary"
action: "navigate"
route: "/company/companies/new"
- label: "Export"
icon: "download"
type: "secondary"
action: "export"
format: "csv"
navigation:
back_button: true
back_route: "/company"
components:
- id: "companies-table"
type: "data-table"
config:
# DataTable configuration (see below)
DataTable Component¶
The most common component type for displaying tabular data:
components:
- id: "companies-table"
type: "data-table"
config:
# Data source
data_source:
endpoint: "/api/company/company/"
method: "GET"
params:
skip: 0
limit: 100
# Column definitions
columns:
- key: "CompanyID"
label: "ID"
type: "number"
sortable: true
width: 80
- key: "CompanyCD"
label: "Code"
type: "text"
sortable: true
searchable: true
width: 120
- key: "CompanyName"
label: "Company Name"
type: "text"
sortable: true
searchable: true
width: 300
- key: "BaseCuryID"
label: "Currency"
type: "text"
sortable: true
width: 100
- key: "Active"
label: "Status"
type: "custom"
renderer: "badge"
width: 100
render_config:
true_label: "Active"
true_color: "success"
false_label: "Inactive"
false_color: "error"
- key: "CreatedDate"
label: "Created"
type: "custom"
renderer: "date"
width: 150
format: "YYYY-MM-DD"
# Table features
features:
pagination: true
page_size: 25
page_size_options: [10, 25, 50, 100]
sorting: true
multi_sort: false
filtering: true
selection: true
selection_mode: "multiple" # single | multiple
export: true
export_formats: ["csv", "xlsx", "pdf"]
refresh: true
column_visibility: true
density: "comfortable" # compact | comfortable | spacious
# Row actions
actions:
- label: "Edit"
icon: "edit"
type: "primary"
action: "navigate"
route: "/company/companies/{{CompanyID}}"
permission: "company.update"
- label: "Delete"
icon: "trash"
type: "danger"
action: "delete"
endpoint: "/api/company/company/{{CompanyID}}"
permission: "company.delete"
confirm:
title: "Delete Company?"
message: "Are you sure you want to delete {{CompanyName}}?"
confirm_text: "Delete"
cancel_text: "Cancel"
- label: "View Details"
icon: "eye"
type: "secondary"
action: "navigate"
route: "/company/companies/{{CompanyID}}/view"
# Conditional actions
- label: "Activate"
icon: "check"
type: "success"
action: "api_call"
endpoint: "/api/company/company/{{CompanyID}}/activate"
method: "POST"
condition:
field: "Active"
operator: "equals"
value: false
# Filters
filters:
- id: "search"
label: "Search"
type: "search"
placeholder: "Search companies..."
fields: ["CompanyCD", "CompanyName"]
- id: "currency"
label: "Currency"
type: "select"
options_source: "/api/core/currency/"
value_key: "CuryID"
display_key: "CuryID"
- id: "status"
label: "Status"
type: "select"
options:
- value: true
label: "Active"
- value: false
label: "Inactive"
- id: "created_date"
label: "Created Date"
type: "date_range"
start_field: "CreatedDateFrom"
end_field: "CreatedDateTo"
Form Component¶
Forms for creating and editing records:
components:
- id: "company-form"
type: "form"
config:
# Form submission
submit:
endpoint: "/api/company/company/"
method: "POST" # or PUT for updates
success_message: "Company created successfully"
success_route: "/company/companies"
error_message: "Failed to create company"
# Form layout
layout: "grid" # grid | stack | tabs
columns: 2 # for grid layout
# Form fields
fields:
- id: "CompanyCD"
label: "Company Code"
type: "text"
required: true
validation:
pattern: "^[A-Z0-9]+$"
message: "Only uppercase letters and numbers allowed"
placeholder: "e.g., MAIN"
help_text: "Unique identifier for the company"
- id: "CompanyName"
label: "Company Name"
type: "text"
required: true
max_length: 255
- id: "BaseCuryID"
label: "Base Currency"
type: "select"
required: true
options_source: "/api/core/currency/"
value_key: "CuryID"
display_key: "CuryID"
default_value: "USD"
- id: "Active"
label: "Active"
type: "checkbox"
default_value: true
- id: "Description"
label: "Description"
type: "textarea"
rows: 4
max_length: 1000
grid_span: 2 # Span 2 columns in grid layout
- id: "Email"
label: "Contact Email"
type: "email"
validation:
pattern: "^[\\w.-]+@[\\w.-]+\\.\\w+$"
message: "Invalid email format"
- id: "Phone"
label: "Phone Number"
type: "tel"
placeholder: "+1 (555) 123-4567"
- id: "Website"
label: "Website"
type: "url"
- id: "EstablishedDate"
label: "Established Date"
type: "date"
min: "1900-01-01"
max: "today"
- id: "EmployeeCount"
label: "Number of Employees"
type: "number"
min: 0
step: 1
# Form actions
actions:
- label: "Save"
type: "submit"
variant: "primary"
- label: "Save & Continue"
type: "submit"
variant: "secondary"
continue_editing: true
- label: "Cancel"
type: "button"
variant: "tertiary"
action: "navigate"
route: "/company/companies"
Tabs Component¶
Organize content into tabs:
components:
- id: "company-details-tabs"
type: "tabs"
config:
default_tab: "general"
tabs:
- id: "general"
label: "General Info"
icon: "info"
components:
- type: "form"
config:
# Form configuration
- id: "addresses"
label: "Addresses"
icon: "map-marker"
components:
- type: "data-table"
config:
data_source:
endpoint: "/api/core/address/"
params:
company_id: "{{CompanyID}}"
- id: "contacts"
label: "Contacts"
icon: "user"
lazy_load: true # Load only when tab is clicked
components:
- type: "data-table"
config:
# Table configuration
Custom Renderers¶
Built-in Renderers¶
| Renderer | Purpose | Configuration |
|---|---|---|
badge |
Status badges | true_label, true_color, false_label, false_color |
currency |
Formatted currency | currency_field, decimals |
date |
Formatted dates | format (e.g., "YYYY-MM-DD HH:mm") |
datetime |
Date and time | format |
link |
Clickable links | route_template |
email |
Email links | - |
phone |
Phone links | - |
progress |
Progress bars | min, max, color |
chip |
Material-UI chips | color, variant |
avatar |
User avatars | name_field, image_field |
icon |
Icons | icon_map |
Badge Renderer Example¶
- key: "Status"
label: "Status"
type: "custom"
renderer: "badge"
render_config:
field: "Status"
badges:
pending:
label: "Pending"
color: "warning"
approved:
label: "Approved"
color: "success"
rejected:
label: "Rejected"
color: "error"
Currency Renderer Example¶
- key: "Amount"
label: "Amount"
type: "custom"
renderer: "currency"
render_config:
currency_field: "CuryID" # Field containing currency code
decimals: 2
Link Renderer Example¶
- key: "InvoiceNbr"
label: "Invoice #"
type: "custom"
renderer: "link"
render_config:
route_template: "/finance/invoices/{{InvoiceID}}"
text_field: "InvoiceNbr"
Conditional Logic¶
Conditional Actions¶
Actions can be shown/hidden based on data values:
actions:
# Show "Approve" only if Status is "Pending"
- label: "Approve"
icon: "check"
action: "api_call"
endpoint: "/api/finance/invoice/{{InvoiceID}}/approve"
condition:
field: "Status"
operator: "equals"
value: "Pending"
# Show "Reject" only if Status is "Pending"
- label: "Reject"
icon: "times"
action: "api_call"
endpoint: "/api/finance/invoice/{{InvoiceID}}/reject"
condition:
field: "Status"
operator: "equals"
value: "Pending"
# Show "Re-open" if Status is not "Pending"
- label: "Re-open"
icon: "undo"
action: "api_call"
endpoint: "/api/finance/invoice/{{InvoiceID}}/reopen"
condition:
field: "Status"
operator: "not_equals"
value: "Pending"
Conditional Operators¶
| Operator | Description | Example |
|---|---|---|
equals |
Field equals value | {field: "Status", operator: "equals", value: "Active"} |
not_equals |
Field not equals value | {field: "Active", operator: "not_equals", value: false} |
greater_than |
Field > value | {field: "Amount", operator: "greater_than", value: 1000} |
less_than |
Field < value | {field: "Days", operator: "less_than", value: 30} |
contains |
String contains | {field: "Email", operator: "contains", value: "@company.com"} |
in |
Value in list | {field: "Status", operator: "in", value: ["Pending", "Review"]} |
not_in |
Value not in list | {field: "Type", operator: "not_in", value: ["Deleted"]} |
Variable Interpolation¶
Use {{FieldName}} to insert values from the current row:
# Navigate to detail page with ID
route: "/company/companies/{{CompanyID}}"
# API endpoint with ID
endpoint: "/api/company/company/{{CompanyID}}/activate"
# Confirmation message with name
message: "Delete company {{CompanyName}}?"
# Dynamic link text
text_template: "View invoice {{InvoiceNbr}}"
YamlPageRenderer Component¶
The React component that powers YAML-driven UI:
File : frontend/src/components/shared/YamlPageRenderer.tsx
How It Works¶
export const YamlPageRenderer: React.FC<YamlPageRendererProps> = ({
pagePath
}) => {
const [config, setConfig] = useState<YamlPageConfig | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
// Load YAML configuration
const loadYaml = async () => {
const response = await fetch(`/navigation/pages/${pagePath}.yaml`);
const yamlText = await response.text();
const parsed = yaml.load(yamlText);
setConfig(parsed);
setLoading(false);
};
loadYaml();
}, [pagePath]);
if (loading) return <Loading />;
if (!config) return <Error message="Page not found" />;
return (
<PageContainer>
<Toolbar config={config.toolbar} />
{config.components.map(component => (
<ComponentRenderer
key={component.id}
component={component}
/>
))}
</PageContainer>
);
};
Component Renderer¶
const ComponentRenderer: React.FC<{ component: YamlComponent }> = ({
component
}) => {
switch (component.type) {
case 'data-table':
return <DataTable config={component.config} />;
case 'form':
return <Form config={component.config} />;
case 'tabs':
return <Tabs config={component.config} />;
case 'chart':
return <Chart config={component.config} />;
case 'custom':
return <CustomComponent config={component.config} />;
default:
return <div>Unknown component type: {component.type}</div>;
}
};
Benefits¶
1. Rapid Development¶
Create new pages in minutes by writing YAML instead of React components.
2. Consistency¶
All pages follow the same patterns and UI conventions.
3. No Code Required¶
Business analysts and consultants can create/modify pages.
4. Easy Customization¶
Change layouts, add fields, modify actions without touching code.
5. Version Control¶
YAML files are text-based and git-friendly.
6. Testing¶
Easier to test configuration than complex React components.
7. Documentation¶
YAML serves as self-documenting configuration.
Best Practices¶
1. Use Descriptive IDs¶
# Good
id: "companies-table"
# Bad
id: "table1"
2. Group Related Fields¶
# Good - Logical grouping
fields:
- id: "FirstName"
- id: "LastName"
- id: "Email"
- id: "Phone"
3. Provide Help Text¶
- id: "TaxID"
label: "Tax ID"
help_text: "Your company's federal tax identification number"
4. Use Validation¶
- id: "Email"
type: "email"
required: true
validation:
pattern: "^[\\w.-]+@[\\w.-]+\\.\\w+$"
message: "Invalid email format"
5. Set Appropriate Defaults¶
- id: "Active"
type: "checkbox"
default_value: true
6. Use Consistent Naming¶
- Snake_case for database fields:
CompanyID,CompanyName - Kebab-case for routes:
/company/companies - Camel-case for frontend props:
dataSource,valueKey
Limitations¶
What YAML Can't Do¶
- Complex Business Logic : Use custom React components
- Dynamic Calculations : Implement in backend or custom component
- Real-time Updates : Use WebSockets with custom component
- Complex Layouts : Compose multiple YAML components or use custom
- Animations : Implement in custom components
When to Use Custom Components¶
- Complex interactive workflows
- Real-time data visualization
- Advanced drag-and-drop interfaces
- Custom charting/graphing
- Specialized input controls
Next Steps¶
- YAML Configuration Guide - Learn YAML syntax
- Adding Entities Guide - Create your first YAML page
- Frontend Architecture - Understand React implementation
- API Reference - Connect YAML to APIs