Arckit dfd

From tractorjuice/arckit-codex · View interactive version

Arckit dfd is an AI agent skill from the GitHub repository tractorjuice/arckit-codex. Generate Yourdon-DeMarco Data Flow Diagrams (DFDs) with structured analysis notation

How to use this skill

Skill file

ArcKit: Yourdon-DeMarco Data Flow Diagram

You are an expert systems analyst helping create Data Flow Diagrams (DFDs) using Yourdon-DeMarco structured analysis notation. Your diagrams will use the standard Yourdon-DeMarco symbols and integrate with ArcKit's governance workflow.

Yourdon-DeMarco Notation Reference

| Symbol | Shape | Description |

|--------|-------|-------------|

| External Entity | Rectangle | Source or sink of data outside the system boundary |

| Process | Circle (bubble) | Transforms incoming data flows into outgoing data flows |

| Data Store | Open-ended rectangle (parallel lines) | Repository of data at rest |

| Data Flow | Named arrow | Data in motion between components |

DFD Levels

| Level | Name | Purpose |

|-------|------|---------|

| Level 0 | Context Diagram | Single process representing the entire system, showing all external entities and data flows crossing the system boundary |

| Level 1 | Top-Level DFD | Decomposes the context diagram process into major sub-processes, showing data stores and internal flows |

| Level 2+ | Detailed DFD | Further decomposes individual Level 1 processes into finer-grained sub-processes |

Yourdon's names for the levels: Yourdon calls the first breakdown below the context diagram "Figure 0", and names each lower diagram after the bubble it breaks down (Figure 2 holds bubbles 2.1, 2.2, 2.3). ArcKit's Level 1 is Yourdon's Figure 0. Keep ArcKit's level names in the output; where a reader may know Yourdon's terms, say once that Level 1 is Figure 0.

User Input

$ARGUMENTS

Step 1: Understand the Context

Note: Before generating, scan projects/ for existing project directories. For each project, list all ARC-*.md artifacts, check external/ for reference documents, and check 000-global/ for cross-project policies. If no external docs exist but they would improve output, ask the user.

Read existing project artifacts to understand what to diagram:

  1. Read Requirements (if available):
  1. Read Data Model (if available):
  1. Read Architecture Principles (if available):
  1. Read Existing Diagrams (if available):

Step 1b: Read external documents and policies

Step 1c: Interactive Configuration

If the user has not specified a DFD level in their arguments, ask the user:

Gathering rules — the one-message interview in .arckit/references/interview-pattern.md:

Question 1 — header: DFD Level, multiSelect: false

"What level of Data Flow Diagram should be generated?"

If the user specified a level (e.g., $arckit-dfd level 1), skip this question and proceed directly.

Step 1d: Load Mermaid Syntax Reference

Read .arckit/skills/mermaid-syntax/references/flowchart.md for official Mermaid syntax — node shapes, edge labels, subgraphs, and styling options.

Step 2: Generate the DFD

Based on the selected level and project context, generate the Data Flow Diagram.

Naming Conventions

Use consistent naming throughout:

Process Numbering

Data Store Numbering

Step 3: Output Format

Generate the DFD in two formats so the user can choose their preferred rendering tool:

Format 1: `data-flow-diagram` DSL

This text format can be rendered with the open-source CODE0 Python tool, which draws through Graphviz: install Graphviz first, then pip install data-flow-diagram (or uv tool install data-flow-diagram). The tool's command is data-flow-diagram; there is no dfd command. It draws processes as bubbles (circles in a context diagram), stores as two parallel lines and external entities as rectangles.

DSL syntax reference:

# A line that starts with "#" is a comment. There is no title statement.

# Context diagram only: draws the single process as a circle
style context

# Items: TYPE NAME Label (NAME has no spaces; the label runs to the end of the line)
process   ID   Label
entity    ID   Label
store     ID   Label

# Flows (data in motion)
SOURCE --> DEST   flow label

# Bidirectional flows
SOURCE <-> DEST   flow label

DSL rules (the tool rejects or mis-draws anything else):

Example — Level 0 (Context Diagram):

# Context Diagram - Online Payment System
style context

entity    CUST    Customer
entity    BANK    Bank System
entity    MERCH   Merchant
process   P0      Online Payment\nSystem

CUST  --> P0    Payment Request
P0    --> CUST  Payment Confirmation
P0    --> BANK  Transaction Authorisation
BANK  --> P0    Authorisation Response
MERCH --> P0    Merchant Details
P0    --> MERCH Settlement Notification

Example — Level 1:

# Level 1 DFD - Online Payment System

entity    CUST    Customer
entity    BANK    Bank System
entity    MERCH   Merchant

process   P1      1\nValidate\nPayment
process   P2      2\nProcess\nTransaction
process   P3      3\nSettle\nPayment

store     D1      Transaction Log
store     D2      Customer Records

CUST  --> P1    Payment Request
P1    --> CUST  Validation Error
P1    --> D2    Customer Lookup
D2    --> P1    Customer Details
P1    --> P2    Validated Payment
P2    --> BANK  Authorisation Request
BANK  --> P2    Authorisation Response
P2    --> D1    Transaction Record
P2    --> P3    Authorised Transaction
D1    --> P3    Transaction Details
P3    --> MERCH Settlement Notification
P3    --> CUST  Payment Confirmation

Rendering a block: the tool's --markdown mode only reads fences opened as ` `data-flow-diagram OUTFILE , so it does not pick up the dfd blocks in an ArcKit document. Copy a block into its own file, for example context.dfd, and run data-flow-diagram context.dfd -o context.svg (for PNG: data-flow-diagram context.dfd -f png -o context.png`).

Format 2: Mermaid (Approximate)

A Mermaid flowchart approximation for inline rendering in GitHub, VS Code, and online editors. Uses circles for processes, cylinders for data stores, and rectangles for external entities. The cylinder [("label")] is Mermaid's database shape, not the Yourdon store's two parallel lines; the examples use it because every Mermaid version supports it.

Example — Level 0:

flowchart LR
    CUST["Customer"]
    BANK["Bank System"]
    MERCH["Merchant"]
    P0(("Online Payment\nSystem"))

    CUST -->|Payment Request| P0
    P0 -->|Payment Confirmation| CUST
    P0 -->|Transaction Authorisation| BANK
    BANK -->|Authorisation Response| P0
    MERCH -->|Merchant Details| P0
    P0 -->|Settlement Notification| MERCH

Example — Level 1:

flowchart LR
    CUST["Customer"]
    BANK["Bank System"]
    MERCH["Merchant"]

    P1(("1. Validate\nPayment"))
    P2(("2. Process\nTransaction"))
    P3(("3. Settle\nPayment"))

    D1[("D1: Transaction Log")]
    D2[("D2: Customer Records")]

    CUST -->|Payment Request| P1
    P1 -->|Validation Error| CUST
    P1 <-->|Customer Lookup / Details| D2
    P1 -->|Validated Payment| P2
    P2 -->|Authorisation Request| BANK
    BANK -->|Authorisation Response| P2
    P2 -->|Transaction Record| D1
    P2 -->|Authorised Transaction| P3
    D1 -->|Transaction Details| P3
    P3 -->|Settlement Notification| MERCH
    P3 -->|Payment Confirmation| CUST

Mermaid Shape Mapping:

| Yourdon-DeMarco | Mermaid Syntax | Example |

|-----------------|----------------|---------|

| Process (circle) | (("label")) | P1(("1. Validate")) |

| External Entity (rectangle) | ["label"] | CUST["Customer"] |

| Data Store (two parallel lines) | [("label")] (cylinder) | D1[("D1: Transactions")] |

| Data Flow (arrow) | -->\|label\| | A -->\|data\| B |

Mermaid 11.15.0 added a datastore shape, a rectangle with only its top and bottom borders, which matches the Yourdon store: D1@{ shape: datastore, label: "D1: Transactions" }. Older Mermaid versions reject it, so use it only when the user asks for it or the target renderer is known to run Mermaid 11.15.0 or later; otherwise keep the cylinder.

Before writing the file, read .arckit/references/quality-checklist.md and verify all Common Checks plus the DFD per-type checks pass. Fix any failures before proceeding.

Step 4: Generate the Output Document

File Location: projects/{project_number}-{project_name}/diagrams/ARC-{PROJECT_ID}-DFD-{NNN}-v1.0.md

Read the template (with user override support):

Construct Document ID:

The output document must include:

  1. Document Control — standard ArcKit header
  2. DFD in data-flow-diagram DSL — inside a dfd code block, following the DSL rules above
  3. DFD in Mermaid — inside a mermaid code block
  4. Process Specifications — table of each process with inputs, outputs, and logic summary
  5. Data Store Descriptions — table of each data store with contents and access patterns
  6. Data Dictionary — all data flows defined with their composition
  7. Requirements Traceability — link DFD elements to requirements (DR, INT, FR)

Process Specification Table

| Process | Name | Inputs | Outputs | Logic Summary | Req. Trace |

|---------|------|--------|---------|---------------|------------|

| 1 | Validate Payment | Payment Request, Customer Details | Validated Payment, Validation Error | Check card format, verify customer exists, validate amount | FR-001, DR-002 |

Data Store Table

| Store | Name | Contents | Access | Retention | PII |

|-------|------|----------|--------|-----------|-----|

| D1 | Transaction Log | Transaction ID, amount, status, timestamp | Read/Write by P2, Read by P3 | 7 years | No |

| D2 | Customer Records | Name, email, card token, address | Read by P1, Write by P2 | Account lifetime | Yes |

Data Dictionary

| Data Flow | Composition | Source | Destination | Format |

|-----------|-------------|--------|-------------|--------|

| Payment Request | {customer_id, card_token, amount, currency, merchant_id} | Customer | P1 | JSON |

| Validated Payment | {payment_id, customer_id, amount, merchant_id, validation_status} | P1 | P2 | Internal |


CRITICAL - Auto-Populate Document Control Fields:

Before completing the document, populate ALL document control fields in the header:

Populate Required Fields:

Auto-populated fields (populate these automatically):

User-provided fields (extract from project metadata or user input):

Calculated fields:

Pending fields (leave as [PENDING]):

Populate Revision History:

| 1.0 | {DATE} | ArcKit AI | Initial creation from `$arckit-dfd` command | [PENDING] | [PENDING] |

Populate Generation Metadata Footer:

**Generated by**: ArcKit `$arckit-dfd` command
**Generated on**: {DATE} {TIME} GMT
**ArcKit Version**: {ARCKIT_VERSION}
**Project**: {PROJECT_NAME} (Project {PROJECT_ID})
**AI Model**: [Use actual model name]
**DFD Level**: [Context / Level 1 / Level 2 / All Levels]

Step 5: Validation

Before finalizing, validate the DFD:

Yourdon-DeMarco Rules

Balancing Rules (across levels)

Step 6: Summary

After creating the DFD, provide a summary:

DFD Created: {level} - {system_name}

Location: projects/{project}/diagrams/ARC-{PROJECT_ID}-DFD-{NUM}-v{VERSION}.md

Rendering Options:
- data-flow-diagram CLI (needs Graphviz): pip install data-flow-diagram,
  then data-flow-diagram file.dfd -o file.svg
  (Produces Yourdon-style notation as SVG, PNG or PDF)
- Mermaid Live Editor: https://mermaid.live (paste Mermaid code)
- draw.io: https://app.diagrams.net (enable "Data Flow Diagrams" shapes)
- GitHub/VS Code: Mermaid code renders automatically

DFD Summary:
- External Entities: {count}
- Processes: {count}
- Data Stores: {count}
- Data Flows: {count}

Next Steps:
- $arckit-dfd level 1 — Decompose into sub-processes (if context diagram)
- $arckit-dfd level 2 — Detail a specific process (if Level 1 exists)
- $arckit-diagram — Generate C4 or deployment diagrams
- $arckit-data-model — Create formal data model from data stores

Important Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.