"use client"; import { DiagramBuilder } from "@/components/DiagramBuilder"; import { createSimpleProcess, templates } from "@/data/diagramTemplates"; import { createFlowDiagram } from "@/utils/asciiBuilder"; export default function ExamplesPage() { return (

Programmatic Diagram Examples

Example 1: Simple Process Flow

Create a simple 3-step process programmatically:

{`import { createSimpleProcess } from '@/data/diagramTemplates';

const diagram = createSimpleProcess(['Start', 'Process', 'End']);`}
          

Example 2: API Flow with Different Box Types

Mix container, inner, and regular boxes:

{`const diagram = createFlowDiagram({
  title: 'API Request Flow',
  width: 65,
  steps: [
    { label: 'Client Request', type: 'regular', shadow: true },
    { label: 'API Gateway', type: 'container', shadow: true },
    { label: 'Process', type: 'inner', shadow: true },
    { label: 'Response', type: 'regular', shadow: true }
  ]
});`}
          

Example 3: Data Pipeline

How to Use Programmatic Diagrams

1. Import the Builder

{`import { DiagramBuilder } from '@/components/DiagramBuilder';`}
              

2. Define Your Steps

{``}
              

3. Box Types

  • regular - Thin box borders (┌─┐)
  • inner - Thick borders (┏━┓)
  • container - Extra thick borders (╔═╗)

Benefits

  • ✅ No manual spacing calculations
  • ✅ Automatic alignment
  • ✅ Easy for non-coders to use
  • ✅ Consistent formatting
  • ✅ Type-safe with TypeScript
); }