AI-powered layered architecture & process flow visualization for Git repositories
Project description
ArchiLens
AI-powered layered architecture & process flow visualization for Git repositories.
ArchiLens analyses your codebase and generates interactive, hierarchical architecture diagrams โ from system-level context down to runtime process flows. Think of it as Google Maps for codebases: zoom from continents (system architecture) to cities (class-level components).
๐ Website: https://saurabh-oss.github.io/archilens/
๐ฆ Repository: https://github.com/saurabh-oss/archilens
What Makes ArchiLens Different
| Capability | Swark | GitDiagram | CodeBoarding | ArchiLens |
|---|---|---|---|---|
| Hierarchical drill-down (L0โL3) | โ | โ | Partial | โ |
| Process flow / sequence diagrams | โ | โ | โ | โ (AI) |
| GitHub-native (Action + PR comments) | โ | โ | โ | โ |
| Architecture drift detection in CI | โ | โ | โ | โ |
| Business capability mapping | โ | โ | โ | โ |
| Git history evolution view | โ | โ | โ | โ |
| Multi-format output (Mermaid/D2/PlantUML) | โ | โ | โ | โ |
| Multi-language support | โ (LLM) | โ (LLM) | โ | โ (Tree-sitter) |
| Interactive web viewer | โ | โ | โ | โ |
| Works without API keys | โ | โ | โ | โ (static only) |
Diagram Levels
L0: System Context โ Your system as a black box + external actors
L1: Module Architecture โ Major modules/services + dependencies
L2: Component Detail โ Classes, interfaces inside a module
L3: Process Flows โ Runtime request lifecycles (AI-inferred)
Quick Start
Prerequisites
- Python 3.10+
- Git
- (Optional) Anthropic API key for AI features
Installation
# From GitHub
pip install git+https://github.com/saurabh-oss/archilens.git
# From source (development)
git clone https://github.com/saurabh-oss/archilens.git
cd archilens
python -m pip install -e ".[dev]"
Windows note: If
pipis blocked by policy, usepython -m pip installinstead.
Initialize in Your Repository
cd /path/to/your/repo
python -m archilens init
This creates a .archilens.yml config file. Edit it to:
- Map modules to business capabilities
- Define entry points for process flow tracing
- Configure external systems for the L0 context diagram
- Set architecture rules for CI enforcement
Generate Diagrams
# Full analysis with AI (requires ANTHROPIC_API_KEY env var)
python -m archilens analyze --repo .
# Static analysis only (no API key needed)
python -m archilens analyze --repo . --no-ai
# Generate only a specific level
python -m archilens analyze --repo . --level 1
# Choose output format: mermaid (default), d2, or plantuml
python -m archilens analyze --repo . --format d2
# Output as JSON (for programmatic use)
python -m archilens analyze --repo . --json-output > snapshot.json
Interactive Web Viewer
python -m archilens serve --repo . --port 8765
Opens a dark-themed single-page app at http://localhost:8765 with:
- Sidebar navigation across all four diagram levels
- Click any module in the L1 diagram to drill into its L2 component view
- Zoom controls (โ/+/Fit/1:1), mouse-wheel zoom, and click-drag pan
- Search/filter sidebar for large repos
- Live re-analysis without restarting the server
Architecture Drift Detection
# Compare current branch against main
python -m archilens diff --base main --head HEAD
# Write the diff report to a file
python -m archilens diff --base v1.0 --head v2.0 --output drift.md
Evolution Timeline
# Analyse architecture across all semver tags
python -m archilens history --repo . --tags
# Analyse specific refs
python -m archilens history --repo . --refs "v1.0,v1.5,v2.0,HEAD"
Produces a Mermaid timeline diagram and a full markdown evolution report showing module additions, removals, and LOC trends across your git history.
Configuration Reference
The .archilens.yml file controls all analysis behaviour.
Project
project:
name: "My Application"
description: "What this system does"
type: "microservices" # monolith | microservices | modular-monolith | library
Analysis
analysis:
languages: ["python", "typescript"] # Auto-detected if omitted
entry_points:
- pattern: "**/*controller*.py"
type: "http_handler"
- pattern: "**/routes/**/*.ts"
type: "http_handler"
exclude:
- "**/node_modules/**"
- "**/__pycache__/**"
- "**/venv/**"
max_depth: 5
Business Capability Mapping
capabilities:
- name: "Order Management"
description: "Order lifecycle from creation to fulfillment"
modules:
- "src/orders/**"
- "services/order-service/**"
- name: "Payment Processing"
modules:
- "src/payments/**"
External Systems
external_systems:
- name: "PostgreSQL"
type: "database"
description: "Primary data store"
- name: "Stripe API"
type: "external_api"
description: "Payment processing"
Diagram Output
diagrams:
output_dir: ".archilens/diagrams"
format: "mermaid" # mermaid | d2 | plantuml
levels:
- { level: 0, enabled: true }
- { level: 1, enabled: true }
- { level: 2, enabled: true }
- { level: 3, enabled: true }
AI Configuration
ai:
provider: "anthropic" # anthropic | openai | ollama | litellm
model: "claude-sonnet-4-6"
features:
process_flow_inference: true
node_annotations: true
capability_suggestions: true
pattern_detection: true
module_summaries: true
CI Rules
ci:
drift_detection: true
pr_comments: true
rules:
- name: "no-layer-skip"
from: "src/presentation/**"
to: "src/infrastructure/**"
action: "warn"
- name: "max-fan-out"
threshold: 10
action: "fail"
GitHub Actions Integration
Add this workflow to your repository:
# .github/workflows/archilens.yml
name: Architecture Analysis
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
pull-requests: write
jobs:
architecture:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install git+https://github.com/saurabh-oss/archilens.git
- name: Generate Diagrams
if: github.event_name == 'push'
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: python -m archilens analyze --repo . --output .archilens/diagrams
- name: Commit Diagrams
if: github.event_name == 'push'
run: |
git config user.name "ArchiLens Bot"
git config user.email "archilens[bot]@users.noreply.github.com"
git add .archilens/diagrams/
git diff --cached --quiet || git commit -m "docs: update architecture diagrams [skip ci]"
git push
- name: PR Drift Detection
if: github.event_name == 'pull_request'
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: python -m archilens diff --base origin/${{ github.base_ref }} --head HEAD
Architecture of ArchiLens Itself
archilens/
โโโ archilens/ # Core Python package
โ โโโ __init__.py
โ โโโ __main__.py # Enables python -m archilens
โ โโโ cli.py # Click CLI with Rich output
โ โโโ config.py # YAML config loader + defaults
โ โโโ engine.py # Main orchestrator pipeline
โ โโโ models/
โ โ โโโ __init__.py # Pydantic models (ArchSnapshot, nodes, edges, flows)
โ โโโ analyzers/
โ โ โโโ discovery.py # File discovery + language detection
โ โ โโโ dependencies.py # Static analysis (imports, classes, call graph)
โ โ โโโ treesitter.py # Tree-sitter AST extraction (Python/JS/TS/Java/Go)
โ โ โโโ diff.py # Architecture diff engine
โ โ โโโ evolution.py # Git history evolution & timeline
โ โ โโโ git_utils.py # Git ref checkout via blob reading
โ โโโ generators/
โ โ โโโ base.py # DiagramGenerator ABC + factory
โ โ โโโ mermaid.py # Mermaid.js output (L0-L3)
โ โ โโโ d2.py # D2 output (L0-L3)
โ โ โโโ plantuml.py # PlantUML output (L0-L3)
โ โโโ viewer/
โ โ โโโ __init__.py
โ โ โโโ app.py # Flask SPA with zoom/pan, drill-down
โ โโโ ai/
โ โ โโโ __init__.py # LLM integration (Anthropic/OpenAI/Ollama)
โ โโโ utils/
โ โโโ __init__.py
โโโ docs/
โ โโโ index.html # GitHub Pages landing site
โโโ github_action/
โ โโโ action.yml # Composite GitHub Action
โโโ tests/
โ โโโ test_core.py # Core analysis tests
โ โโโ test_new_features.py # Tree-sitter, generators, viewer, diff, evolution
โโโ .archilens.yml # Example configuration
โโโ .github/workflows/
โ โโโ archilens.yml # Example CI workflow
โโโ pyproject.toml # Project metadata + dependencies
โโโ README.md
Pipeline Flow
.archilens.yml Source Code Git History
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ
โ Config โ โ Discovery โ โ Git Utils โ
โ Loader โ โ (Tree-sitter) โ โ (evolution โ
โโโโโโฌโโโโโโ โโโโโโโโโฌโโโโโโโโโโโ โ + diff) โ
โ โ โโโโโโโฌโโโโโโโ
โผ โผ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Analysis Engine โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โ โ Static โ โ AI โ โ Metrics & โ โ
โ โ Analysis โ โ Augmentationโ โ Patterns โ โ
โ โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโโ โโโโโโโโโฌโโโโโโโโ โ
โ โโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโ
โ ArchSnapshot โ (Pydantic: nodes + edges + flows)
โโโโโโโโฌโโโโโโโโ
โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โMermaid โ โ D2 โ โ PlantUML โ
โ (L0-3) โ โ (L0-3) โ โ (L0-3) โ
โโโโโโฌโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
โ Web โ โ Diff โ โ JSON โ
โ Viewer โ โ Report โ โ Export โ
โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ
Development Setup
# Clone the repository
git clone https://github.com/saurabh-oss/archilens.git
cd archilens
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# .venv\Scripts\activate # Windows
# Install with dev dependencies
python -m pip install -e ".[dev]"
# Run tests
pytest tests/ -v --cov=archilens
# Lint
ruff check archilens/
mypy archilens/
Roadmap
- Core static analysis engine (multi-language via Tree-sitter + regex fallback)
- L0-L3 Mermaid diagram generation
- D2 and PlantUML output formats
- AI-powered process flow inference and module summaries
- Architecture drift detection (diff engine with CI rules)
- Git history evolution timeline (
archilens history) - GitHub Action for CI/CD
- Business capability mapping
- CLI with Rich output (
analyze,diff,history,serve,init) - Interactive web viewer with zoom/pan and click-to-drill-down
- GitHub Pages landing site
- VS Code extension
- GitHub App (persistent bot with richer PR integration)
- Monorepo support (multi-service cross-repo analysis)
- OpenTelemetry integration (runtime architecture from traces)
- PyPI release
Contributing
Contributions are welcome! Key areas:
- Language parsers โ Add Tree-sitter grammars for more languages (Ruby, Rust, C#, etc.)
- Pattern detection โ Expand the set of recognized architectural patterns (CQRS, Saga, etc.)
- VS Code extension โ TypeScript extension surfacing L2/L3 diagrams inline
- GitHub App โ Probot/Node.js app for persistent PR bot integration
License
MIT โ see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file archilens-0.2.0.tar.gz.
File metadata
- Download URL: archilens-0.2.0.tar.gz
- Upload date:
- Size: 86.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11f9c6faa210cad80226acd2a33cdde352d01612f1750d3b6c685549843655b5
|
|
| MD5 |
faf1cd1c1b5034296d22fc6ddafb4920
|
|
| BLAKE2b-256 |
4c97f5ce311d9349366d1551812c29fcf026449cbaa328f1043c5eb471a779f1
|
Provenance
The following attestation bundles were made for archilens-0.2.0.tar.gz:
Publisher:
publish.yml on saurabh-oss/archilens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
archilens-0.2.0.tar.gz -
Subject digest:
11f9c6faa210cad80226acd2a33cdde352d01612f1750d3b6c685549843655b5 - Sigstore transparency entry: 1779368063
- Sigstore integration time:
-
Permalink:
saurabh-oss/archilens@6cf1e274f1464a9783572af29f416faaf8ab1a21 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/saurabh-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6cf1e274f1464a9783572af29f416faaf8ab1a21 -
Trigger Event:
push
-
Statement type:
File details
Details for the file archilens-0.2.0-py3-none-any.whl.
File metadata
- Download URL: archilens-0.2.0-py3-none-any.whl
- Upload date:
- Size: 71.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a7bf524bde86d239e66771761089ac6e3802499963b0bf8bf957374a626ed2c
|
|
| MD5 |
1e0a96e2bcf2cabaeda5605d73c99f95
|
|
| BLAKE2b-256 |
06e57432ced0ccce4ef5de82469777b70276e1f175f847c4c1227de75ab6c25a
|
Provenance
The following attestation bundles were made for archilens-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on saurabh-oss/archilens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
archilens-0.2.0-py3-none-any.whl -
Subject digest:
8a7bf524bde86d239e66771761089ac6e3802499963b0bf8bf957374a626ed2c - Sigstore transparency entry: 1779368137
- Sigstore integration time:
-
Permalink:
saurabh-oss/archilens@6cf1e274f1464a9783572af29f416faaf8ab1a21 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/saurabh-oss
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6cf1e274f1464a9783572af29f416faaf8ab1a21 -
Trigger Event:
push
-
Statement type: