Git Diagrammer

2 min read Original article ↗

How to generate a diagram from a git codebase

Step-by-step guide on generating diagrams from a git codebase

  1. Copy the repository URL
    1. Ensure the repository is public on GitHub.
    2. For private repos, sign up for a free Eraser account to enable access.
  2. Select a diagram type
    1. Supported diagrams: Architecture diagrams, Sequence diagrams, Entity-Relationship diagrams, and Flowcharts.
  3. Write a clear prompt
    1. A simple one-liner can work, but detailed prompts usually yield better results.
    2. Follow this framework for an effective prompt:
      1. Specify file or folder paths (e.g., /deployments/dev) for context.
      2. Describe the topic you want to visualize (e.g., signup flow, service architecture, user data model).
      3. Include visualization instructions (e.g., what to include/exclude, grouping preferences).
  4. Generate the diagram using the completed prompt.
  5. Refine the diagram
    1. Use Eraser's diagram-as-code DSL for manual changes.
    2. Adjust the layout manually with GUI controls (requires signing into Eraser).

Tips on generating diagrams from a git codebase

  • Be specific with paths
    • Example: "Draw a cloud architecture diagram from .tf files in /deployments/dev" is clearer than "Draw a cloud architecture diagram from this repo".
    Break down complex diagrams
    • Instead of "Draw an architecture diagram of this repo", try "Draw a service architecture diagram of the payment process".

Examples of effective prompts

  • "Create an architecture diagram showing the API services in /src/api/ and how they interact with database models in /src/models/"
  • "Generate a sequence diagram for the user checkout process from the files in /src/services/checkout/ and /src/controllers/payment/"
  • "Draw an entity relationship diagram of the user, order, and product models from the files in /src/database/schemas/