Skip to content

Auto-generate Mermaid sequence diagrams in PR reviews #15

@haasonsaas

Description

@haasonsaas

Problem

Greptile and CodeRabbit auto-generate Mermaid sequence diagrams showing call flow for changed functions. These are highly shared by engineering teams and function as organic marketing. DiffScope has the smart_review_diagram config option and the symbol graph to construct these, but:

  1. It's off by default
  2. It's not wired into the GitHub PR comment flow
  3. The symbol graph data isn't used to generate accurate call-flow diagrams

Proposed Solution

  1. Enable diagram generation by default in smart review mode
  2. Use symbol graph data to generate accurate sequence/flow diagrams:
    • Call flow: API Handler → Service → Repository → Database
    • Data flow: How data transforms through the changed code path
    • Dependency graph: What modules are affected by this change
  3. Embed Mermaid diagrams in PR comments — GitHub natively renders Mermaid in markdown
  4. Collapsible by default in the summary comment (use <details> tags)
  5. Generate diagrams only when meaningful — skip for trivial changes (typos, config, etc.)

Example Output

sequenceDiagram
    participant Client
    participant AuthMiddleware
    participant UserController
    participant UserService
    participant PostgreSQL
    
    Client->>AuthMiddleware: POST /api/users (changed)
    AuthMiddleware->>UserController: validateToken() 
    UserController->>UserService: createUser(dto) (changed)
    UserService->>PostgreSQL: INSERT users (changed)
    PostgreSQL-->>UserService: User record
    UserService-->>UserController: UserResponse
Loading

Priority

Tier 2 — Differentiator and marketing asset. These diagrams are highly shareable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions