Skip to main content

chartedcode

Diagrams for Python projects: class, call and control-flow diagrams, drawn as self-contained HTML by a small, deterministic Rust program.

Point it at a file or a directory. It reads the source (it never runs it), works out how the code fits together, and writes the diagrams as HTML. Each file holds its data, the layout engine and the viewer, so it opens in any browser, works offline, and needs no Graphviz or other renderer installed.

$ chartedcode src/ --open         # everything, in one directory, opened at its front page
$ chartedcode classes src/        # class diagram
$ chartedcode calls src/          # call graph
$ chartedcode flow src/           # control-flow graph of each function
wrote src-flow.chartedcode.html
$ chartedcode all src/ -o out/    # the same as the first line, with a chosen directory

chartedcode PATH is short for chartedcode all PATH. (A path named classes, calls, flow, all or help needs a ./ in front.)

Install

$ pip install chartedcode        # or: uvx chartedcode calls src/

The wheel carries the compiled program; there is nothing else to install. Python 3.11 or later.

The diagrams

Every relationship says how it was found, and anything the tool could not follow is counted and listed, not guessed at or silently dropped.

classes

Inheritance, Protocol conformance and field types.

  • inherits: a base class, resolved through imports (including relative imports, re-exports through __init__.py, star imports and TYPE_CHECKING imports).
  • implements: a class has every method name of a Protocol. This compares names only, not signatures, so it is shown as weak evidence.
  • has-a: a field whose annotation names a class of the project (class-body annotations, and self.x assigned from an annotated parameter in __init__).

calls

Which function calls which, and in what order.

  • calls and constructs (Foo() goes to Foo.__init__, or to an implicit constructor when the class defines none).
  • passes: a function or method handed to another function as a callback (runner.run("train", self._trainer.fit)), which is assumed to be called.
  • dispatches: a call to a Protocol method may run any implementer's method of that name.
  • Call order: each call is numbered within its caller, in evaluation order (a call's arguments before the call). Numbers appear on the arrows, in a panel listing the focused function's calls, and in an execution flow view that chains the calls in order and enters each callee's own calls. Recursion is marked, not drawn, so the execution flow is always acyclic.
  • Acyclic view: functions that call each other in a cycle are collapsed into one node. When there are no cycles the page says it is identical to the call graph.
  • Views at function, class or module granularity; focus on one node with its callers and callees to a chosen depth.

The colour of an edge says how sure the tool is: resolved by name, import, self or super; inferred from a declared type; method names only; external.

flow

The control-flow graph of each function (and of a module's top-level code): basic blocks with their source lines, edges labelled with when they are taken (true, false, next item, loop, break, exception, return, ...), unreachable code marked, and a complexity number (decision points plus one). The calls in each block carry the same step numbers as the call graph, and a call that has a flow of its own can be opened with two clicks.

Approximations, so the diagram can be read correctly: any statement in a try body may raise (one exception edge from the body to each handler), context managers do not branch, and boolean operators, conditional expressions and comprehensions do not split a block.

The front page

$ chartedcode src/ --open
wrote 5 files and manifest.json to src-chartedcode
start at src-chartedcode/index.html

index.html is where to start. A fixed bar offers Summary, Classes, Calls and Flow; each diagram page loads the first time its tab is chosen and stays loaded after that. The summary shows the totals and three lists of ten functions (most complex, most calls made, most calls not traced); choosing one opens it. Two buttons at the top right, always present and enabled once a function is shown, switch between the call graph and the control flow of that function. --open uses $BROWSER if it is set, and otherwise the system's opener (open, xdg-open, start); if it cannot start, the files are still written and the command says so. The front page reads theme=light|dark and view=summary|classes|calls|flow from its URL fragment.

The diagram pages keep working on their own: each can be opened directly, and each is still one file.

Every diagram at once, for CI

$ chartedcode all src/ -o out/
wrote 5 files and manifest.json to out/
start at out/index.html

out/ holds index.html, classes.html, calls.html, flow.html, analysis.json and manifest.json. The names are fixed, so whatever collects them does not need to know the project. The manifest lists each file with its size and SHA-256, the tool and schema versions, and some totals (files analysed, classes, functions, call edges, untraced calls, the highest complexity); it has no timestamps, so the same input gives a byte-identical directory. analysis.json is the complete analysis, including control flow, whatever --min-complexity does to the flow page.

Embedding the pages

Each page is one file with no external requests, no cookies and no browser storage, and when served over HTTP it renders inside <iframe sandbox="allow-scripts">. (The front page needs allow-same-origin as well for the pages beside it, because Chrome will not load a file: page into an opaque-origin frame.) A host chooses how a page opens through the URL fragment (page.html#embed=1&theme=dark). A page reads embed and theme again if the fragment changes after load; the other options are read once, when the page opens. Apart from that, the front page can ask calls.html and flow.html to show a function with postMessage({chartedcode: 1, type: "show", function: id}) from their parent frame, and they answer with {chartedcode: 1, type: "state", function, label}; messages from anywhere else are ignored. There is no other way to drive a page from outside.

Option Pages Effect
embed=1 all hide the header and legend, so the diagram fills the frame (the status line and, in the call graph, the order-of-calls panel stay)
theme=light or theme=dark all use these colours whatever the system setting is
kinds=inherits,implements,composes classes which relationships are shown at first
view=graph|exec|acyclic, gran=function|class|module calls the view and its granularity
focus=<function id>, depth=N calls the function to focus on and how far to follow its calls
ext=1, untraced=1, private=1, mincalls=N, dir=down calls external calls, untraced-call counts, private names, the focus-list filter, the layout direction
function=<function id> flow the function to show
minc=N, private=1, dir=right flow the complexity filter for the function list, private names, the layout direction

Function ids are the id fields of functions in analysis.json, such as pkg/app::Service.run.

What it does not follow

Static analysis of a dynamic language has limits. The tool does not infer return types, so a call on a variable whose type is not declared (model.evaluate() where model is whatever a function returned) is untraced: counted per function, listed in the page, never drawn as an edge. It also does not follow dispatch through subclass overrides (only Protocols dispatch), property access that runs code, decorators, getattr and other dynamic calls, function-local imports or __all__. Branches and loops are flattened in the call numbering: a number means "the order written", not a guaranteed run order.

Options

Option Effect
-o, --output FILE where to write the result; by default <name>-<view>.chartedcode.html in the current directory, or standard output for JSON
--format html|json the page, or the analysis as JSON (schema_version 1; always includes private names)
--include-private start with private names (a single leading underscore) shown; the page hides them by default
--no-gitignore also analyse files matched by .gitignore (by default they and hidden directories are skipped; the global ignore file is never read, so a checkout gives the same result everywhere)
--no-source flow only: leave source text out of the diagram, so blocks show only line numbers
--min-complexity N flow only: only draw functions of at least this complexity

The same input always gives byte-identical output.

A flow page contains the source text of your functions. Use --no-source before sharing one if that matters.

From Python

$ python -m chartedcode calls src/
$ chartedcode-py calls src/            # always inside this process
$ CHARTEDCODE_INPROC=1 python -m chartedcode calls src/

python -m chartedcode starts the executable that came with the package. For environments where the interpreter may run code but no other program may be started, chartedcode-py (or CHARTEDCODE_INPROC=1) runs the same program inside the interpreter, through an extension module; the output is identical. chartedcode._binary.run_binary(["calls", "src/", "--format", "json"], capture=True) runs it from code.

Development

$ uv sync
$ uv run inv build          # build the executable and the extension, and install them
$ uv run inv all            # format, lint, test (Rust and Python), verify licences
  • uv run inv test builds first. Run bare pytest as uv run --no-sync pytest after uv run inv build: a plain uv run re-syncs the project and can put an older cached build over the one just installed. The test session refuses to run against an executable older than the Rust sources.
  • The browser tests drive a headless Chrome and are skipped when none is found (set CHROME to its path).
  • Build wheels from the working tree after staging the extension (uv run inv build does that), with maturin build --profile cli. uv build builds the wheel from the source distribution, which does not contain the compiled extension.

Licence

MIT (see LICENSE). Every page embeds elkjs 0.11.0, unmodified, which is licensed under the Eclipse Public License 2.0; see NOTICE and rust/assets/elkjs-LICENSE.md.

Metadata

Release files for chartedcode 0.2.0

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

Source distribution (sdist)

Source distribution for chartedcode 0.2.0
File Size Uploaded Provenance Actions
chartedcode-0.2.0.tar.gz 574.2 kB With provenance Details for chartedcode-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for chartedcode 0.2.0
File Actions
chartedcode-0.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for chartedcode-0.2.0-py3-none-win_amd64.whl
chartedcode-0.2.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for chartedcode-0.2.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
chartedcode-0.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for chartedcode-0.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
chartedcode-0.2.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for chartedcode-0.2.0-py3-none-macosx_11_0_arm64.whl
chartedcode-0.2.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for chartedcode-0.2.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 21.6 MB

Release files / chartedcode-0.2.0.tar.gz

Download URL chartedcode-0.2.0.tar.gz
Size 574.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7c49abc415956c7f152c8aeea09e8469c504c8385e4352e2ea865385ddc46cbf
BLAKE2b-256 checksum
How to use checksums
436a9f1824b823aee9d968c8dab1c37c2c81c12bfe5ede3bcd71837de2d4d770
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 Nov 7, 2026.

Transparency log

Release files / chartedcode-0.2.0-py3-none-win_amd64.whl

Download URL chartedcode-0.2.0-py3-none-win_amd64.whl
Size 4.2 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
1305e7a33cd0e87ead489a48bfcee8c0b91e77729e97d3ad3f0ff259fc425ae3
BLAKE2b-256 checksum
How to use checksums
f5d65913984c8628c8e86fda68ce95d4cab4523d578b428e3a72c943c48cd851
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 Nov 7, 2026.

Transparency log

Release files / chartedcode-0.2.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL chartedcode-0.2.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 4.3 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
692703ad65dc00f446d4c124e8924f21ff3ea0ab202da8afc81abe159d96271e
BLAKE2b-256 checksum
How to use checksums
44ac6411016b6501b3391a4307ce392c62acc8e40b1cc616ac78a5b8ebce9fa6
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 Nov 7, 2026.

Transparency log

Release files / chartedcode-0.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL chartedcode-0.2.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 4.2 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
62d033bdbb86945441db3ad1c1076ba2158cd143c6ae12345eb32385cf4ea22c
BLAKE2b-256 checksum
How to use checksums
8c9296e25ae33518b85d680b0b1f011520021a5aa6ac4f30c639dcfe8b84336a
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 Nov 7, 2026.

Transparency log

Release files / chartedcode-0.2.0-py3-none-macosx_11_0_arm64.whl

Download URL chartedcode-0.2.0-py3-none-macosx_11_0_arm64.whl
Size 4.1 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8c06da98e7b9d925758f448b208c53d9e4186e66cc5d31191df0b5819d05f827
BLAKE2b-256 checksum
How to use checksums
a3843a7ceafc22a20dbde5b99770c919526aadd8bebf2b9b8a825020140a0ff3
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 Nov 7, 2026.

Transparency log

Release files / chartedcode-0.2.0-py3-none-macosx_10_12_x86_64.whl

Download URL chartedcode-0.2.0-py3-none-macosx_10_12_x86_64.whl
Size 4.2 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
6003f5f0e7518d61edd5b284fe8c1744552c079520572c8faa0fac1d05c8df87
BLAKE2b-256 checksum
How to use checksums
eab30be76c0061f360dec268c3abf0b2a1a1ad346398fd8645d0cffc47f0236e
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 Nov 7, 2026.

Transparency log

Security for chartedcode 0.2.0

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

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for chartedcode-0.2.0.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 Nov 7, 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

6 release files Full provenance

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