Diagram
← How to make diagrams with AI

How to make an architecture diagram of your codebase with AI

An AI coding tool can read your repo and draw its architecture: Cursor, Claude Code, Codex and GitHub Copilot all do it. Open the repo, ask for one level of the system at a time, check the result against the code, and share it. Connect Diagram first and each diagram is saved at a link that stays current, so you are not pasting Mermaid text into another app to see it.

1. Open the repo in a tool that can read it

You need an AI tool that works inside the repo, not a chat you paste files into. Pick yours for the one-minute setup:

2. Ask for one level at a time

“Draw the architecture” gets you a crowded picture. Say which level you want. These four cover most needs, and each is one request:

The whole system

One page for someone new: the apps, the databases, the outside services, and what talks to what.

  • “Make an architecture diagram of this repo: the services, the data stores, and the outside services it calls. Give me a link I can share.”
  • “Before drawing, list the files you read to work it out, and say what you left out.”

One flow

What happens, in order, when one thing is done. The most useful diagram to start with, and the easiest to get right.

  • “Draw what happens when a user signs up, from the form to the database, as a sequence diagram.”
  • “Diagram the checkout flow, including what happens when the payment fails.”

The data

The tables or collections and how they relate, read from the schema or the models.

  • “Show the data model as an entity diagram, from the schema in this repo.”
  • “Draw which services read and write each table.”

One part, up close

The modules inside one service and what depends on what. Useful before a refactor.

  • “Diagram the modules in the billing package and what depends on what.”
  • “Before you change it, draw how this module works today so we agree on it.”

3. Check it against the code

The AI draws what it read, and it does not read everything. Three habits catch most mistakes:

4. Share the link and keep it current

An architecture diagram is out of date the week after it is drawn, which is why most teams stop trusting theirs. Put the link in the README or the pull request, and when the code changes, ask for the change: “update the architecture diagram, we added a queue and a worker”. The link stays the same and every earlier version is kept, so you can see how the system looked before.

In a repo, the AI can also add a short file that lists the repo’s diagrams, so the next session, or a teammate’s tool, updates the existing diagram instead of drawing a new one.

The kind of thing you can ask for:

Architecture · Dracula

How our app works

Explain your system to anyone.

cloud browser api postgres queue worker httpsread/writeenqueue cloud browser api postgres queue

Questions

Can Cursor create architecture diagrams?
Yes. Cursor’s agent can read your repo and draw its architecture from the code. On its own it gives you Mermaid text or a file in the repo; connected to Diagram, it saves the diagram at a link you can open and share.
Can Claude Code or Codex generate an architecture diagram?
Yes. Both read the repo from the terminal and can draw the services, data stores and flows in it. Ask in plain words and say how much to cover. With Diagram connected they save the result at a link.
Does the diagram have to be Mermaid?
No. Mermaid is fine for a quick flowchart, but it lays the diagram out for you and gets hard to read as it grows. With Diagram the AI draws a web page, so it can group parts, label arrows and use your product’s colors. It can still use Mermaid if you ask.
How accurate is it?
As accurate as what it read. Ask it to list the files it used and what it left out, and correct it in plain words. Diagrams of one flow are more reliable than one diagram of everything.
My repo is large. Will it work?
Yes, if you split it. Ask for the whole system at a high level first, then one diagram per flow or per service. One diagram that tries to show everything is hard to read however it is made.
Is my code uploaded?
No. Your AI tool reads the code where it already runs. Only the finished diagram is saved to Diagram, as a draft only you can see until you publish it. A diagram that contains a credential is refused.
How do I keep it up to date?
Ask the AI to update it when the code changes: “update the architecture diagram, we added a queue”. The change is saved at the same link, so the copy in your README or pull request is never stale.