Introduction: Why Automate in Archi?
Archi is a popular open-source modeling tool that supports the ArchiMate language and is widely used by enterprise architects across the world. As architecture repositories grow, maintaining consistency, enforcing standards, and keeping the model up-to-date become time-consuming and error-prone.
This is where jArchi , Archi’s JavaScript-based scripting engine, becomes a game changer. It allows architects to automate repetitive tasks, validate model structure, generate reports, and build smart modeling workflows directly within the tool.
What is jArchi?
jArchi is a scripting plugin for Archi based on GraalVM JavaScript (formerly Nashorn). It provides programmatic access to the Archi model using a familiar, readable syntax. With jArchi, you can:
- Search, filter, and group elements
- Create new model content programmatically
- Modify existing elements and diagrams
- Perform quality checks or validations
- Export model data for reporting and dashboards
Getting Started with jArchi
Installation
- Download the latest jArchi plugin from Archi plugin repository
-
Place the plugin JAR file in the
/plugins
folder of your Archi installation - Restart Archi — you will now see a “Scripts” tab
Creating Your First Script
Click the “Scripts” tab, then “New Script”. Paste the following to list all Application Components:
model.find("element").filter(e => e.type == "ApplicationComponent").forEach(e => {
console.log(e.name);
});
This shows how easy it is to interact with your ArchiMate model using just a few lines of JavaScript.
Common Automation Use Cases in jArchi
1. Mass-Update Tagged Values
Update all Data Objects to include a standard sensitivity tag:
model.find("element").filter(e => e.type == "DataObject").forEach(e => {
e.set("Sensitivity", "Medium");
});
2. Enforce Naming Conventions
Check for inconsistent naming patterns across Business Roles:
model.find("element").filter(e => e.type == "BusinessRole").forEach(e => {
if (!e.name.match(/^ROLE_/)) {
console.log("Naming violation: " + e.name);
}
});
3. Create Diagrams Automatically
Generate a view showing all services offered by applications:
var view = model.createView("application", "Auto-App-Services");
var apps = model.find("element").filter(e => e.type == "ApplicationComponent");
apps.forEach(function(app, index) {
var service = app.children().find(s => s.type == "ApplicationService");
if (service) {
view.add(app).bounds(100, index * 100, 160, 60);
view.add(service).bounds(300, index * 100, 160, 60);
view.connect(app, service, "Assignment");
}
});
4. Trace Relationships Programmatically
Follow all flows from a single actor:
var actor = model.find("element").find(e => e.name == "Customer");
actor.outRels("Flow").forEach(rel => {
console.log(actor.name + " → " + rel.target.name);
});
Advanced Scripting Patterns
Batch Processing
Use a script to clean up deprecated elements across your model:
model.find("element").filter(e => e.get("Status") == "Deprecated").forEach(e => {
e.delete();
});
Model Validation
Build a script to detect unassigned business processes:
model.find("element").filter(e => e.type == "BusinessProcess").forEach(p => {
if (!p.inRels("Assignment").length) {
console.log("Unassigned process: " + p.name);
}
});
Diagram Styling
Color elements by lifecycle status:
var view = model.activeView;
view.children().forEach(obj => {
var status = obj.concept.get("Lifecycle");
if (status == "Retired") obj.style("fillColor", "red");
else if (status == "Active") obj.style("fillColor", "green");
else obj.style("fillColor", "gray");
});
Working with Git-Backed Repositories
Archi models can be stored in Git repositories. You can:
- Use scripts to export change logs
- Track element history
- Run validation scripts as part of commit workflows
Creating Reports from jArchi
Export to CSV
var file = new java.io.FileWriter("/tmp/data_export.csv");
file.write("Name,Type,Sensitivity\n");
model.find("element").forEach(e => {
file.write(e.name + "," + e.type + "," + e.get("Sensitivity") + "\n");
});
file.close();
Export JSON for Dashboards
var result = model.find("element").map(e => {
return {name: e.name, type: e.type, status: e.get("Lifecycle")};
});
console.log(JSON.stringify(result, null, 2));
Governance with jArchi
- Quality Gates: Run a validation script before each release
- Reusable Standards: Keep a library of reusable script snippets
- Tagged Metadata Audits: Check completeness for reporting compliance
Tips for Writing Maintainable jArchi Scripts
- Use functions and modular structures
- Document your scripts with comments
- Validate element types before accessing properties
- Use try/catch for error handling in larger scripts
- Organize scripts in folders (e.g., "validation", "layout", "reporting")
Community Resources and Repositories
- jArchi GitHub Plugin
- jArchi Scripts Gist Search
- Community Slack and LinkedIn groups for sharing scripts
Conclusion: Empowering Architecture through Automation
jArchi unlocks a new dimension of modeling in Archi. From validating data quality and accelerating diagramming, to exporting structured reports and automating repository tasks — scripting enables leaner, smarter architecture management.
Once you've mastered jArchi, you'll spend less time on clicks and more time on strategy.
Keywords/Tags
- jArchi scripting tutorial
- automate ArchiMate with jArchi
- Archi modeling automation
- Archi scripts for model validation
- Archi export CSV and JSON
- batch update Archi model
- Archi diagram styling automation
- Archi Git integration automation
- enterprise architecture scripting
- jArchi examples and best practices