Generate an ER diagram from a Prisma schema.
A Prisma schema states relationships explicitly, which makes it one of the most reliable sources for an entity diagram that exists.
What it reads
schema.prisma: the models, their fields and types, the relation attributes, and the enums. Unlike a raw SQL schema, relations here are declared as relations rather than implied by a foreign key, so both direction and cardinality are stated rather than derived. That removes essentially all of the guesswork.
How the schema becomes a diagram
Each model is an entity. Relation fields become edges, with cardinality read from whether the field is a list and optionality from whether it is nullable. Implicit many-to-many relations are recognised as such and drawn as a single relationship rather than exposing the join table Prisma manages for you, which keeps the diagram at the level you think in.
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.
Worth keeping in the repository
Because the schema is one file and the diagram is derived from it deterministically, regenerating on change is cheap enough to do routinely. An entity diagram in the README that is actually current is rare, and this is one of the few cases where keeping it current is not a discipline problem.
Your schema 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.
Prisma to ER diagram
| In the schema | In the diagram |
|---|---|
| model | An entity |
| Scalar fields | Attributes with their types |
| @id | The identifying attribute |
| @relation | A relationship with direction |
| List relation field | One-to-many |
| Optional relation field | An optional relationship |
| Implicit many-to-many | Drawn as one relationship, not a join table |
| enum | A constrained attribute |
| @@index and @@unique | Notes on access and constraints |
The prompt
Questions
Related
- Generate a Diagram from a CodebasePoint it at a repository and it surveys the code the way a new engineer would, then draws what it found.
- Generate a Diagram from TerraformTerraform already describes your infrastructure precisely. The diagram is a rendering of something you have written down, not a guess.
- Generate a Diagram from Kubernetes ManifestsKubernetes YAML contains the whole topology and presents it as several hundred lines in which none of it is visible.
- Generate a Diagram from Docker ComposeA Compose file is already a complete description of a small system. It is just written in a format that hides the shape.