This guide explains how to create code generation projects, manage templates, and produce downloadable outputs.
Code generation is project-based.
A project contains:
- project metadata (name, description)
- target metamodel
- one or more templates
Each template contains:
- language (
javaorpython) - template content (Handlebars-style)
- output filename pattern
You can open code generation in two ways:
- from navigation (standalone page)
- from a diagram card (
Generate Code)
When opened from a diagram context, generation prioritizes that diagram/model context where applicable.
At the top of the page:
- Select existing project from project selector.
- Or create a new project.
For new projects provide:
- project name
- target metamodel
- optional description
Projects support multiple templates (tabbed editor inside project dialog).
Template fields:
- template name
- language (Java/Python)
- output filename pattern (example:
{{name}}.java) - template content
Multiple template tabs let you generate multi-file outputs from one run.
The workspace provides:
- Example Templates tab
- preloaded example projects/templates
You can start from an example and adapt it to your metamodel.
Generation flow:
- Select project.
- Click Generate.
- Review generated files in Generated Files tab.
- Download one file or download all as ZIP.
Model selection behavior:
- service resolves models conforming to project target metamodel
- when diagram context exists, it prioritizes that diagram model
- generation can run diagram-based or model-based paths
Templates support Handlebars-style expressions and helpers.
Common helper examples in UI:
capitalizelowercasecamelCasesnakeCase
The editor also includes autocompletion support for template authoring.
Generated Files tab provides:
- file list
- file content preview
- single-file download
- bulk ZIP download
Project-level operations include:
- edit project and templates
- delete project
- share project with other users (if permitted)
Sharing follows role/permission behavior defined for resource sharing.
Cause: project has no valid templates or no compatible models.
Fix: verify target metamodel and template list.
Cause: no model found for selected target metamodel.
Fix: create or select a model conforming to the target metamodel.
Cause: invalid or empty output pattern.
Fix: use a valid Handlebars pattern and include extension.
Cause: variable path does not exist in generation context.
Fix: inspect available context and adjust variable names.
Cause: editing existing project while expecting new copy.
Fix: create a new project when branching template sets.
- Finalize metamodel and model first.
- Create small project with one template.
- Generate and inspect output.
- Add additional templates for multi-file generation.
- Share project once stable.
frontend/src/components/codegeneration/CodeGenerator.tsx: Main code generation workspace UI.frontend/src/services/codegeneration/codegeneration.service.ts: Frontend code generation orchestration service.frontend/src/services/codegeneration/codegen-generation-engine.service.ts: Template execution and output assembly logic.frontend/src/services/codegeneration/templateAutocomplete.service.ts: Template editor completion helpers.backend/src/routes/codegen.routes.ts: Backend API endpoints for projects, templates, and generation operations.