Skip to main content

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 pip is blocked by policy, use python -m pip install instead.

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:

  1. Language parsers โ€” Add Tree-sitter grammars for more languages (Ruby, Rust, C#, etc.)
  2. Pattern detection โ€” Expand the set of recognized architectural patterns (CQRS, Saga, etc.)
  3. VS Code extension โ€” TypeScript extension surfacing L2/L3 diagrams inline
  4. GitHub App โ€” Probot/Node.js app for persistent PR bot integration

License

MIT โ€” see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

archilens-0.2.0.tar.gz (86.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

archilens-0.2.0-py3-none-any.whl (71.5 kB view details)

Uploaded Python 3

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

Hashes for archilens-0.2.0.tar.gz
Algorithm Hash digest
SHA256 11f9c6faa210cad80226acd2a33cdde352d01612f1750d3b6c685549843655b5
MD5 faf1cd1c1b5034296d22fc6ddafb4920
BLAKE2b-256 4c97f5ce311d9349366d1551812c29fcf026449cbaa328f1043c5eb471a779f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for archilens-0.2.0.tar.gz:

Publisher: publish.yml on saurabh-oss/archilens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for archilens-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a7bf524bde86d239e66771761089ac6e3802499963b0bf8bf957374a626ed2c
MD5 1e0a96e2bcf2cabaeda5605d73c99f95
BLAKE2b-256 06e57432ced0ccce4ef5de82469777b70276e1f175f847c4c1227de75ab6c25a

See more details on using hashes here.

Provenance

The following attestation bundles were made for archilens-0.2.0-py3-none-any.whl:

Publisher: publish.yml on saurabh-oss/archilens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page