Current file: app/src/lib/tools/architecture-diagram.ts
Current model: deepseek-r1-0528
Current approach: Single prompt asking for Mermaid diagram. No Mermaid syntax validation, no rendering check, no iterative correction.
Problems with current approach:
- Generated Mermaid code frequently has syntax errors (unquoted labels with special characters, invalid arrow types, broken subgraph nesting).
- No verification that the diagram actually renders.
- Single-pass cannot self-correct syntax issues.
- Complex systems produce overly flat diagrams without meaningful grouping.
Upgrade plan:
| Step |
Agent |
Action |
| 1 |
System Decomposer |
Analyze the system description. Identify components, services, databases, external systems, and their relationships. Output a structured component graph. |
| 2 |
Diagram Generator |
Convert the component graph into Mermaid syntax. Apply grouping (subgraphs), proper arrow types, and descriptive labels. |
| 3 |
Syntax Validator |
Programmatic: Parse the Mermaid code using a Mermaid parser or CLI (mmdc from @mermaid-js/mermaid-cli). Catch syntax errors before returning to user. |
| 4 |
Repair Agent |
If syntax validation fails, feed the specific errors back and regenerate only the broken sections. Max 3 retries. |
- You are free to enhance the agents stacks in the above plan layout, the above one is just for reference. You can enhance more if needed.
Model suggestions to start with:
- Step 1: Try
deepseek-r1-0528 for system analysis (reasoning task). Also try glm-5 for complex systems architecture.
- Step 2: Try
qwen-3-coder-30b or kimi-k2.6 for Mermaid code generation (structured code output).
- Step 4: Try
deepseek-v3.2 for quick syntax repair (lightweight).
Model Selection Guidance
- You are free to pick any model from the Oxlo catalog based on your own testing and evaluation.
- The Models suggestions above, not mandates. Try them first, and if they do not meet the accuracy target, experiment with alternatives.
Compare against: GPT 5.3 Thinking and Claude Sonnet 4.6 Thinking.
Acceptance criteria:
- Generated Mermaid code must pass syntax validation in 95%+ of cases (after repair loop).
- Diagrams must render correctly when processed by Mermaid CLI.
- Complex systems (5+ components) use subgraph grouping.
- Overall quality matches or exceeds GPT 5.3 Thinking & Claude Sonnet 4.6 on test cases.
- Overall accuracy at 80%+.
Current file:
app/src/lib/tools/architecture-diagram.tsCurrent model:
deepseek-r1-0528Current approach: Single prompt asking for Mermaid diagram. No Mermaid syntax validation, no rendering check, no iterative correction.
Problems with current approach:
Upgrade plan:
mmdcfrom@mermaid-js/mermaid-cli). Catch syntax errors before returning to user.Model suggestions to start with:
deepseek-r1-0528for system analysis (reasoning task). Also tryglm-5for complex systems architecture.qwen-3-coder-30borkimi-k2.6for Mermaid code generation (structured code output).deepseek-v3.2for quick syntax repair (lightweight).Model Selection Guidance
Compare against: GPT 5.3 Thinking and Claude Sonnet 4.6 Thinking.
Acceptance criteria: