Skip to main content

Svarupa

स्वरूप — "its own true form."

Svarupa reads a codebase and produces a verified map of it: a queryable knowledge graph plus six types of architecture diagram (architecture, module dependencies, data flow, request flow, deploy topology, ERD), delivered as one interactive HTML artifact. A type the evidence cannot produce is named as absent, never fabricated.

The defining constraint: every node and every edge in every diagram carries file:line evidence, or it does not render. Not a heuristic guess, not a model's plausible story. A claim you can click through to the source line that proves it.

The name states the thesis. Svarupa is a thing's actual form, not its intended one. Architecture documents describe what someone meant to build. Svarupa renders what exists.

Status: alpha. The evidence contract is stable; flags and output formats may still change between minor versions.


Quickstart

uv tool install svarupa     # or: pipx install svarupa / pip install svarupa
svarupa .                   # scans the repo, writes .svarupa/
open .svarupa/index.html

That is the whole setup — no configuration file, no daemon, no account. The first run of a typical repository takes seconds.

python -m svarupa is the same command; --out ./map writes the artifact somewhere other than <repo>/.svarupa/. The artifact holds:

  • index.html: every diagram type as a tab. Click a box for its passport (kind, connections, reach, cited source lines); double-click a drillable box, or click its chevron, to open it in place down to component and code level.
  • graph.json: the knowledge graph. svarupa query <dir> get_node <label>, get_neighbors, shortest_path, affected, god_nodes, graph_stats, get_health, get_design_rules, query_graph; svarupa mcp <dir> serves the same over MCP.
  • REPORT.md: the resolution scorecard and every finding, with its code.
  • Health: nine maintainability checks with published thresholds (complexity, length, parameters, nesting, file and class size, duplication, import cycles, hub modules), graded with the SQALE model, in the CLI, REPORT.md, a Health tab, graph.json and get_health. See docs/health.md.
  • Declared environments (production, staging, qa, development) are extracted with file:line evidence and surface in the CLI summary, a REPORT.md section, graph.json nodes, and a cited strip on the deploy topology.
  • --lock writes the committed architecture lockfile; --diff prints the architecture delta against a base lockfile; add --fail-on-change to exit 3 when that delta is not empty. svarupa setup ci_github (or ci_gitlab) installs the per-pull-request workflow. The architecture delta is informational by default (add --fail-on-change to gate it); the health step fails the job on new problems (new violations or a worse grade), and the file describes the one-line change that makes it report-only.
  • svarupa setup ide teaches your AI coding tools (Claude Code, Cursor, GitHub Copilot, Windsurf, and AGENTS.md readers such as Codex) the Svarupa workflow and this repository's rules. It adds Svarupa's MCP server to the project configs of Claude Code, Cursor and Copilot, and prints it as a snippet to add for Windsurf and Codex (their configs are global). It only edits text between <!-- svarupa:begin --> and <!-- svarupa:end -->; refresh with --update, preview with --dry-run. Windsurf gets a shorter version, because Windsurf limits rule files to 6,000 characters each (12,000 in total).
  • Code facts come from language packs: Python, TypeScript, JavaScript, Go and Java today. Other detected languages are listed as detected but not analyzed (SVA-X-012), never guessed.

The architecture tab of the demo repository

The deploy topology tab, with the declared-environments strip on top

Declared environments — production, staging, qa, development — are extracted with file:line evidence and shown as a cited strip above the topology.


Why

Every tool in this space sits on one side of a divide and cannot cross it.

Tool Analyzes code Draws formal diagrams
Graphify Deeply, 25+ languages No — force-directed node-link graphs only
Understand-Anything Yes, AST + LLM No — force layouts only
Archify No — reads nothing Yes, five types, excellent quality
Cocoon-AI No — prompt-to-diagram Yes, architecture only

Nobody closes the loop code → AST → derived formal diagram. The analyzers produce blobs; the drawers produce unverifiable pictures.

The larger thesis: continuous architecture governance

Graphify and Understand-Anything are onboarding tools. You run one when you join a project, look at the graph, and never open it again.

Because Svarupa's output is deterministic and evidence-backed, it runs in CI on every pull request: diff the architecture, comment the impact, fail the build on policy violations. Cross-language architecture linting is a category nobody occupies.

Architecture impact of #482

  + 2 components    billing.refunds, billing.webhooks
  + 1 datastore     redis (compose.yml:31)
  ! NEW DEPENDENCY  billing -> auth.internal
                    via billing/refunds.py:44
  + 4 endpoints     POST /refunds, GET /refunds/{id}, ...

Design principles

Fail-closed on evidence. An element without a source location is not emitted. When Python's dynamic dispatch means a call target cannot be pinned, no edge is written and the gap is counted in the report, rather than papered over with a plausible one.

Three-bin honesty. The resolution scorecard reports resolved, known-external, and unresolved-unknown. Counting every failure as "external" would launder resolver bugs into a number that looks like honesty.

Deterministic by contract. Same commit, same bytes, on any machine. Canonical ordering, ==-pinned grammars, NFC-normalized paths, no timestamps, no locale-dependent formatting. Verified in CI across Linux and macOS on Python 3.10 through 3.13 with PYTHONHASHSEED varied.

Identity comes from structure, not from clustering. Lockfile modules are directories, packages, and workspace members. Community detection is chaotically sensitive to input perturbation — measured: one added import flips 25-38% of community assignments — so it is used for visual grouping only and never reaches anything committed.

Measured, not assumed. Function-level sequence diagrams were cut after measurement showed call resolution at ~20% on service code with median chain depth 0-1. Replaying this repository's own real history (15 commits of actual development: license swaps, viewer work, layout fixes) produced a median of 0 lockfile lines per commit — the diff moves only when the architecture moves, not when code churns. See docs/reviews/ for the numbers and the reasoning.

Benchmarked. Every pull request is scored on 11 pinned public repositories (Python, TypeScript, JavaScript, Go, Java) against facts checked by reading their source; a change that loses a found fact fails CI. A language pack is labelled stable only when two of its repositories reach 90% recall with no false fact. Recall covers what Svarupa claims to extract (modules, dependencies, compose services, calls, and routes for FastAPI, Flask, Express and NestJS), not features it does not extract yet. See benchmark/.


Development

uv sync
uv run pytest
uv run ruff check svarupa
uv run pyright svarupa

Design and review history:

  • docs/superpowers/specs/ — the design, with a decision log carrying the reasoning behind each choice
  • docs/reviews/ — adversarial reviews, raw and triaged. Every finding is marked Accepted, Rejected, or Deferred with a recorded why, because a rejected finding needs its reasoning kept just as much as an accepted one

Releasing

Versions are calendar based, YYYY.M.N (see docs/adr/0001-calendar-versioning.md). A release is two commands, with a reviewed pull request in between:

git switch main && git pull --ff-only
scripts/release.sh prepare        # next version, bump, draft notes, checks, release PR
# edit docs/releases/vX.md in the PR, resolve every TODO:, merge
git switch main && git pull --ff-only
scripts/release.sh publish        # tag, PyPI via trusted publishing, GitHub Release, install check

publish pushes the tag and the release workflow uploads to PyPI with no token. It then creates the GitHub Release from the notes file and opens a small PR that moves the dogfood workflow pin to the new version. If the workflow had to be re-run by hand, finish with scripts/release.sh publish-finish.


License

MIT. See LICENSE.

Metadata

Release files for svarupa 2026.10.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for svarupa 2026.10.2
File Size Uploaded Provenance Actions
svarupa-2026.10.2.tar.gz 1.4 MB With provenance Details for svarupa-2026.10.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for svarupa 2026.10.2
File Interpreter ABI Platform Actions
svarupa-2026.10.2-py3-none-any.whl Python 3 none any Details for svarupa-2026.10.2-py3-none-any.whl

Total release size: 1.8 MB

Release files / svarupa-2026.10.2.tar.gz

Download URL svarupa-2026.10.2.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
be4acd9df82c1626e989fcce2f382198e59317654f5c4c8c66b09a9b5cd4d5de
BLAKE2b-256 checksum
How to use checksums
7b84f186a24ac1005c701e303914c0f02e1f6da587a053949270743acfb52f76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / svarupa-2026.10.2-py3-none-any.whl

Download URL svarupa-2026.10.2-py3-none-any.whl
Size 400.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb0f849c5c9040b71d55cbe9cab491c41ddccb394232987710e52d45777e306c
BLAKE2b-256 checksum
How to use checksums
4c989ab6e79ac742339f76053d4bd8a0d3681d31a516d26f3fee8cbe7149ce8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for svarupa 2026.10.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for svarupa-2026.10.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page