Generate from source

Generate an architecture diagram from a Python project.

Python projects hide their structure in decorators and imports, both of which are readable and neither of which is visible from a directory listing.

Download for macOS
v0.1.33 · .dmg · Apple Silicon & Intel
Signed & notarized by Apple · opens without a Gatekeeper warning
sha256 698955a0187bc039f4c74f5d05a9f10fbb27376a45788a0a241d1326b73873c7
Download for Windows instead
$curl -fsSL https://lucidtrain.com/install.sh | sh

What it reads

pyproject.toml or requirements files to establish dependencies and entry points, then the import graph from those entry points. Framework conventions carry a lot of the meaning: FastAPI and Flask route decorators mark the API surface, Django apps and models give both structure and the data model, Celery task decorators identify asynchronous work, and SQLAlchemy or Django ORM definitions identify what writes to which store.

How Python becomes components

Components are drawn at the level of packages and modules that own something, not at the level of every file. A module that defines routes is an API component; one that defines tasks is a worker; one that defines models is the data access boundary. External dependencies from the manifest that represent infrastructure, a database driver, a queue client, an HTTP client for a known service, become external or data tier nodes with edges from whatever imports them.

Why the layout can be trusted

The agent reads the files listed above and emits a semantic graph: components, the tier each belongs to, and the edges between them, with no coordinates anywhere. The ELK layout engine then computes positions and orthogonal edge routing. This is why the output cannot come back with boxes overlapping or arrows crossing through cards, which is the usual failure when a language model is asked to place things on a canvas itself.

Async work is usually the missing half

Most Python service diagrams drawn by hand show the request path and omit the Celery tasks entirely, which is where a surprising amount of the actual behaviour lives. Reading task decorators puts those on the diagram, along with what enqueues them, and that is frequently the part a reviewer has never seen laid out.

Your code stays on your machine

It runs on your machine. With a local Ollama model nothing leaves the laptop at all, and with your own API key the file contents go to the provider you chose and never through us. For a source that is your actual codebase, that distinction is usually the deciding one.

Python to diagram

In the codeIn the diagram
pyproject.toml, requirements.txtDependencies and entry points
FastAPI or Flask route decoratorsAPI surface, application tier
Django appsComponents, with their models
Celery task decoratorsWorker components
SQLAlchemy or Django modelsData tier edges
Import graph from entry pointsEdges between components
Redis, Kafka, boto3 clientsExternal and data tier nodes
tests/, conftest.pyNot drawn

The prompt

shell
$ Survey this Python project and diagram it: the API surface, the background tasks, what they write to, and the external services involved.
FAQ

Questions

Does it run my code?

No. It reads files. Nothing is imported or executed, which matters for a codebase whose imports have side effects.

Does it work with Django specifically?

Well, because Django's conventions are strong: apps, models and URL configuration each say something structural, so there is less inference and more reading.

Will it draw the database schema too?

It can draw an ER diagram from the models as a separate diagram. Combining a service architecture and a full entity model in one picture makes both harder to read.

What about notebooks?

They are read as context but rarely produce useful components, since a notebook is usually a script rather than a piece of architecture.

Related