Automating Knowledge Graph Updates with Archi CLI
The Automation Challenge
Manually exporting Archi models and updating knowledge graphs doesn't scale. As models evolve, keeping the semantic layer synchronized requires automation. Architecture teams need their ArchiMate models to flow automatically into knowledge graphs, triggering updates to dashboards, compliance reports, and cross-tool queries.
Archi Command Line Interface
Archi provides a powerful CLI that runs without launching the GUI, enabling headless automation of model operations. This makes it ideal for CI/CD pipelines, scheduled jobs, and event-driven workflows.
Command Line Interface
Archi provides a powerful CLI for headless automation, enabling integration into CI/CD pipelines and scheduled workflows. See Archi CLI documentation
Key CLI capabilities:
- Load and create models programmatically
- Export to multiple formats without GUI
- Run jArchi scripts for transformations
- Generate reports automatically
- Clone and sync collaboration repositories
Learn more: Archi CLI documentation
Basic CLI Format
Windows:
Archi -application com.archimatetool.commandline.app -consoleLog -nosplash [options]
Linux:
./Archi -application com.archimatetool.commandline.app -consoleLog -nosplash [options]
Mac:
Archi.app/Contents/MacOS/Archi -application com.archimatetool.commandline.app -consoleLog -nosplash [options]
Available Operations
The CLI supports operations critical for knowledge graph integration:
- Load/Create Models - Load existing models or create from templates
- Import/Export - ArchiMate Exchange Format (XML), CSV, Open Exchange
- Run Scripts - Execute jArchi scripts for custom transformations
- Generate Reports - HTML reports, Jasper Reports
- Collaboration - Clone and load from coArchi repositories
Execution Priorities
CLI providers execute in priority order, allowing chained operations:
- Load/Create (Priority 10) - Load or create model first
- Import (Priority 20) - Import additional data
- Run Script (Priority 30) - Execute transformations
- Export/Report (Priority 40) - Generate outputs
- Save (Priority 50) - Persist changes
This means you can chain operations without worrying about order:
--loadModel model.archimate --script.runScript transform.ajs --xmlexchange.export output.xml
Knowledge Graph Integration Patterns
Full CLI reference: Archi Command Line Interface
Architectural knowledge graphs unify disparate sources using semantic web technologies, enabling cross-tool queries and automated view generation.
Key Characteristics
Multi-Source Integration - Aggregates knowledge from disparate tools: ArchiMate models, ADR repositories, OpenAPI specifications, infrastructure-as-code, project management systems, and code repositories.
Semantic Relationships - Uses RDF triples to represent typed relationships: "System X implements Capability Y", "Decision Z affects Component W", "API A depends on Service B".
Queryable - Enables SPARQL queries spanning multiple sources: "Which systems are affected by GDPR?" or "What decisions led to our microservices boundaries?"
Machine-Readable - Structured data enables automated reasoning, compliance checking, impact analysis, and view generation.
Pattern 1: Scheduled Batch Sync
Export models nightly to keep knowledge graphs current:
#!/bin/bash
# sync-archi-to-kg.sh
ARCHI_CLI="./Archi -application com.archimatetool.commandline.app -consoleLog -nosplash"
MODEL_PATH="/models/enterprise-architecture.archimate"
EXPORT_PATH="/exports/$(date +%Y%m%d)"
# Export to Open Exchange XML format
$ARCHI_CLI \
--loadModel "$MODEL_PATH" \
--xmlexchange.export "$EXPORT_PATH/model.xml"
# Transform XML to RDF
python3 /scripts/archimate-to-rdf.py \
--input "$EXPORT_PATH/model.xml" \
--output "$EXPORT_PATH/model.ttl" \
--ontology "https://meta.linked.archi/core"
# Load into knowledge graph
curl -X POST http://triplestore:7200/repositories/architecture/statements \
-H "Content-Type: text/turtle" \
--data-binary "@$EXPORT_PATH/model.ttl"
# Trigger view regeneration
curl -X POST http://linked-archi/api/regenerate-views
Schedule with cron:
0 2 * * * /scripts/sync-archi-to-kg.sh
Pattern 2: Git-Triggered Updates
Update knowledge graph when models change in version control:
# .github/workflows/sync-archi-model.yml
name: Sync Archi Model to Knowledge Graph
on:
push:
paths:
- 'models/**.archimate'
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Archi CLI
run: |
wget https://www.archimatetool.com/downloads/archi-linux.tgz
tar -xzf archi-linux.tgz
- name: Install dependencies
run: |
sudo apt-get install -y xvfb libgtk-3-0
- name: Export to XML
run: |
xvfb-run ./Archi/Archi \
-application com.archimatetool.commandline.app \
-consoleLog -nosplash \
--loadModel models/enterprise-arch.archimate \
--xmlexchange.export exports/model.xml
- name: Transform to RDF
run: python3 scripts/archimate-to-rdf.py exports/model.xml exports/model.ttl
- name: Update Knowledge Graph
env:
KG_ENDPOINT: $
KG_TOKEN: $
run: |
curl -X POST $KG_ENDPOINT/statements \
-H "Authorization: Bearer $KG_TOKEN" \
-H "Content-Type: text/turtle" \
--data-binary @exports/model.ttl
Pattern 3: Script-Enhanced Export
Use jArchi scripts to enrich exports with metadata before transformation. Semantic integration connects tools by mapping their concepts to a shared metamodel.
How It Works
Extract - Pull data from source tools (Archi models, Git repos, Jira, Confluence)
Transform - Convert tool-specific formats to RDF triples conforming to the metamodel
Align - Map tool-specific concepts to common ontology (e.g., Jira "Epic" → Capability)
Query - Use SPARQL to answer questions spanning multiple sources
// enrich-for-export.ajs
// Add metadata for knowledge graph integration
console.log("Enriching model for knowledge graph export...");
// Add timestamps
$('archimate-model').first().prop('export-timestamp', new Date().toISOString());
// Link elements to external systems
$('application-component').each(function(component) {
var name = component.name.toLowerCase().replace(/\s+/g, '-');
// Link to Git repository
if (component.prop('git-repo')) {
component.prop('kg:git-url', 'https://github.com/org/' + component.prop('git-repo'));
}
// Link to API spec
if (component.prop('api-spec')) {
component.prop('kg:api-url', 'https://api-docs.org/' + component.prop('api-spec'));
}
// Link to deployment
component.prop('kg:deployment-url', 'https://k8s.org/apps/' + name);
});
// Link capabilities to business glossary
$('capability').each(function(cap) {
var slug = cap.name.toLowerCase().replace(/\s+/g, '-');
cap.prop('kg:glossary-url', 'https://glossary.org/terms/' + slug);
});
// Mark elements with quality attributes
$('element').each(function(elem) {
if (elem.documentation.includes('security')) {
elem.prop('kg:quality-attribute', 'security');
}
if (elem.documentation.includes('performance')) {
elem.prop('kg:quality-attribute', 'performance');
}
});
console.log("Enrichment complete");
Execute with CLI:
$ARCHI_CLI \
--loadModel model.archimate \
--script.runScript enrich-for-export.ajs \
--xmlexchange.export output.xml \
--saveModel model-enriched.archimate
Pattern 4: Multi-Model Federation
Combine multiple Archi models into a unified knowledge graph:
#!/bin/bash
# federate-models.sh
MODELS=(
"/models/business-arch.archimate"
"/models/application-arch.archimate"
"/models/technology-arch.archimate"
"/models/security-arch.archimate"
)
EXPORT_DIR="/exports/federation/$(date +%Y%m%d)"
mkdir -p "$EXPORT_DIR"
# Export each model
for MODEL in "${MODELS[@]}"; do
BASENAME=$(basename "$MODEL" .archimate)
$ARCHI_CLI \
--loadModel "$MODEL" \
--xmlexchange.export "$EXPORT_DIR/${BASENAME}.xml"
# Transform to RDF with model-specific namespace
python3 /scripts/archimate-to-rdf.py \
--input "$EXPORT_DIR/${BASENAME}.xml" \
--output "$EXPORT_DIR/${BASENAME}.ttl" \
--namespace "https://linked.archi/models/${BASENAME}#"
done
# Merge all RDF files
cat "$EXPORT_DIR"/*.ttl > "$EXPORT_DIR/federated.ttl"
# Load federated graph
curl -X POST http://triplestore:7200/repositories/enterprise/statements \
-H "Content-Type: text/turtle" \
--data-binary "@$EXPORT_DIR/federated.ttl"
Pattern 5: Collaboration Repository Sync
Automatically sync from coArchi repositories:
#!/bin/bash
# sync-coarchi.sh
REPO_URL="https://github.com/org/architecture-models.git"
REPO_PATH="/tmp/coarchi-repo"
IDENTITY_FILE="/keys/coarchi-ssh-key"
PASS_FILE="/keys/coarchi-pass"
$ARCHI_CLI \
--modelrepository.cloneModel "$REPO_URL" \
--modelrepository.loadModel "$REPO_PATH" \
--modelrepository.identityFile "$IDENTITY_FILE" \
--modelrepository.passFile "$PASS_FILE" \
--xmlexchange.export "/exports/coarchi-model.xml"
# Continue with RDF transformation and knowledge graph update
Headless Execution on Linux
For CI/CD and server environments, run Archi CLI headless. See Archi CLI documentation for details:
# Install dependencies
apt-get install -y libgtk-3-0 xvfb
# Option 1: Manual Xvfb
Xvfb :99 &
export DISPLAY=:99
./Archi -application com.archimatetool.commandline.app -consoleLog -nosplash --options
pkill -f 'Xvfb :99'
# Option 2: xvfb-run (simpler)
xvfb-run ./Archi -application com.archimatetool.commandline.app -consoleLog -nosplash --options
Docker Container for Automation
Package Archi CLI in a container for consistent execution:
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y \
wget \
xvfb \
libgtk-3-0 \
python3 \
python3-pip \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Archi
RUN wget https://www.archimatetool.com/downloads/archi-linux.tgz && \
tar -xzf archi-linux.tgz && \
mv Archi /opt/archi && \
rm archi-linux.tgz
# Install transformation scripts
COPY scripts/ /scripts/
RUN pip3 install -r /scripts/requirements.txt
ENV PATH="/opt/archi:${PATH}"
ENV DISPLAY=:99
ENTRYPOINT ["xvfb-run", "/opt/archi/Archi"]
CMD ["-application", "com.archimatetool.commandline.app", "-consoleLog", "-nosplash", "--help"]
Use in pipelines:
docker run --rm \
-v $(pwd)/models:/models \
-v $(pwd)/exports:/exports \
archi-cli:latest \
--loadModel /models/enterprise.archimate \
--xmlexchange.export /exports/model.xml
Integration with Knowledge Graph Workflows
Complete Pipeline Example
#!/bin/bash
# complete-kg-pipeline.sh
set -e
MODEL="$1"
EXPORT_DIR="/tmp/archi-export-$$"
mkdir -p "$EXPORT_DIR"
echo "1. Exporting Archi model..."
xvfb-run /opt/archi/Archi \
-application com.archimatetool.commandline.app \
-consoleLog -nosplash \
--loadModel "$MODEL" \
--script.runScript /scripts/enrich-metadata.ajs \
--xmlexchange.export "$EXPORT_DIR/model.xml" \
--csv.export "$EXPORT_DIR/csv"
echo "2. Transforming to RDF..."
python3 /scripts/archimate-to-rdf.py \
--input "$EXPORT_DIR/model.xml" \
--output "$EXPORT_DIR/model.ttl"
echo "3. Linking to external artifacts..."
python3 /scripts/link-external-artifacts.py \
--rdf "$EXPORT_DIR/model.ttl" \
--git-repos /data/git-repos.json \
--api-catalog /data/api-catalog.json \
--output "$EXPORT_DIR/model-linked.ttl"
echo "4. Validating against metamodel..."
python3 /scripts/validate-metamodel.py \
--rdf "$EXPORT_DIR/model-linked.ttl" \
--shapes https://meta.linked.archi/shapes.ttl
echo "5. Loading into knowledge graph..."
curl -X POST http://triplestore:7200/repositories/architecture/statements \
-H "Content-Type: text/turtle" \
--data-binary "@$EXPORT_DIR/model-linked.ttl"
echo "6. Triggering view regeneration..."
curl -X POST http://linked-archi/api/views/regenerate
echo "7. Notifying stakeholders..."
curl -X POST http://slack-webhook \
-d "{\"text\": \"Architecture model updated: $MODEL\"}"
rm -rf "$EXPORT_DIR"
echo "Pipeline complete!"
Benefits
Continuous Integration - Models automatically flow into knowledge graphs on every commit
Consistency - Automated pipelines eliminate manual export errors
Scalability - Handle multiple models across teams and domains
Traceability - Git history + automation logs = complete audit trail
Real-time Views - Stakeholder dashboards update automatically when models change
Cross-Tool Sync - Archi changes trigger updates to ADRs, APIs, infrastructure docs
Next Steps
- Integrating Archi Tool with Knowledge Graphs - Foundation concepts
- CI/CD for Architecture Models - Complete pipeline patterns
- Metamodel Validation - Ensuring model quality
- Event-Driven Architecture Updates - Real-time synchronization
Archi CLI transforms manual model management into automated knowledge graph workflows, keeping architectural knowledge current and queryable across your entire tool ecosystem.
Linked.Archi Publications