Data Lineage Architecture Lens
Cognitive Mode: Data-Centric
Primary Question: "Where is the data?"
Focus: Information Flow, Transformations, Storage Locations, Format Conversions
When to Use
- Need to understand how data flows through the system
- Documenting data transformations and conversions
- Identifying storage destinations and access patterns
- User invokes
/arch-lens-data-lineage or /make-arch-diag data
Critical Constraints
NEVER:
- Modify any source code files
- Focus on runtime behavior (that's process flow lens)
- Show static structure without data context
ALWAYS:
- Trace data from INPUT to STORAGE
- Show transformation stages and format changes
- Identify the single source of truth
- Distinguish read vs write operations
- BEFORE creating any diagram, LOAD the
/mermaid skill using the Skill tool - this is MANDATORY
Analysis Workflow
Step 1: Launch Parallel Exploration Subagents
Spawn Explore subagents to investigate:
Data Origins (Inputs)
- Find user input handling
- Identify external data sources
- Look for: CLI args, API requests, file reads, imports, user input, data ingestion
Transformation Stages
- Find data conversion/transformation code
- Identify adapters and converters
- Look for: Adapter, Converter, transform, parse, serialize, from_*, to_*, mapping, conversion
Format Changes
- Find schema definitions and conversions
- Identify format boundaries (JSON, XML, protobuf, etc.)
- Look for: schema models, type definitions, serialization, deserialization, format conversion
Storage Destinations
- Find database operations
- Identify file outputs
- Look for: database operations, persistence, .save(), .create(), .write(), storage
Access Patterns
- Find data retrieval code
- Identify query patterns
- Look for: .get(), .query(), .find(), .load(), read operations, data access layer
Step 2: Map Data Flow
Document the journey of key data entities:
- Origin: Where does it come from?
- Transformations: What changes happen?
- Storage: Where is it persisted?
- Retrieval: How is it accessed later?
CRITICAL - Analyze Read/Write Direction:
For EVERY storage location and data flow:
- Read sources (inputs): Components that READ from this location
- Write destinations (outputs): Components that WRITE to this location
- Read-write (primary storage): Both read and written by the system
- Write-only (artifacts): Written but NEVER read back by the system
Clearly distinguish:
- Primary storage (source of truth) - system reads AND writes
- Write-only artifacts (debugging, logging) - system writes but never reads back
- External inputs - system reads only
Use different arrow styles:
- Solid arrows for read/write primary storage
- Dashed arrows for write-only artifacts
Step 3: Identify Conversion Boundaries
Find format changes:
- External format -> Internal format
- Internal format -> Database format
- Database format -> API response
- Note naming convention changes
Step 4: Create the Diagram
Use flowchart with:
Direction: LR (left-to-right) for data flow, or TB for hierarchical
Subgraphs for Stages:
- Input/Origins
- Transformation/Processing
- Storage (primary)
- Artifacts (secondary/write-only)
- External Sync (if applicable)
Node Styling:
cli class: Data origins, user input
handler class: Transformation, adapters
stateNode class: Database tables, primary storage
output class: Write-only artifacts, files
integration class: External sync, APIs
Connection Types:
- Solid arrows for primary data flow
- Dashed arrows for write-only/secondary
- Label with operation names
Database Nodes:
- Use cylinder shape:
[(Label)]
- Show table relationships
Step 5: Write Output
Write the diagram to: temp/arch-lens-data-lineage/arch_diag_data_lineage_{YYYY-MM-DD_HHMMSS}.md
Output Template
# Data Lineage Diagram: {System Name}
**Lens:** Data Lineage (Data-Centric)
**Question:** Where is the data?
**Date:** {YYYY-MM-DD}
**Scope:** {What was analyzed}
## Data Flow Overview
| Stage | Format | Key Transformation |
|-------|--------|-------------------|
| Input | {format} | {description} |
| Processing | {format} | {description} |
| Storage | {format} | {description} |
## Lineage Diagram
```mermaid
%%{init: {'flowchart': {'nodeSpacing': 50, 'rankSpacing': 60, 'curve': 'basis'}}}%%
flowchart LR
%% CLASS DEFINITIONS %%
classDef cli fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;
classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;
classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;
classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;
classDef output fill:#00695c,stroke:#4db6ac,stroke-width:2px,color:#fff;
classDef integration fill:#c62828,stroke:#ef9a9a,stroke-width:2px,color:#fff;
subgraph Input ["Data Origins"]
USER["User Input<br/>━━━━━━━━━━<br/>Source type<br/>Format"]
end
subgraph Transform ["Transformation"]
direction TB
ADAPTER["Adapter<br/>━━━━━━━━━━<br/>Conversion type"]
end
subgraph Storage ["Primary Storage (Source of Truth)"]
direction TB
DB[("Database Table<br/>━━━━━━━━━━<br/>Key fields")]
end
subgraph Artifacts ["Write-Only Artifacts"]
direction TB
FILE["output.json<br/>━━━━━━━━━━<br/>For debugging"]
end
%% FLOWS %%
USER -->|"input"| ADAPTER
ADAPTER -->|"save()"| DB
DB -.->|"write-only"| FILE
%% CLASS ASSIGNMENTS %%
class USER cli;
class ADAPTER handler;
class DB stateNode;
class FILE output;
Color Legend:
| Color |
Category |
Description |
| Dark Blue |
Input |
Data origins (user, external) |
| Orange |
Transform |
Format conversion and adapters |
| Teal |
Storage |
Primary storage (source of truth) |
| Dark Teal |
Artifacts |
Write-only outputs |
| Red |
Sync |
External sync services |
Data Transformation Summary
| Stage |
Format |
Key Conversion |
| {stage} |
{format} |
{conversion} |
Storage Destinations
| Entity |
Primary Storage |
Secondary |
Access Pattern |
| {entity} |
{location} |
{artifact} |
{how accessed} |
Critical Design Principle
Source of Truth: {e.g., "Database is single source of truth. File outputs are write-only."}
---
## Pre-Diagram Checklist
Before creating the diagram, verify:
- [ ] LOADED `/mermaid` skill using the Skill tool
- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)
- [ ] Diagram will include a color legend table
---
## Related Skills
- `/make-arch-diag` - Parent skill for lens selection
- `/mermaid` - MUST BE LOADED before creating diagram
- `/arch-lens-c4-container` - For container-level storage view
1---2name: arch-lens-data-lineage3description: Create Data Lineage architecture diagram showing information flow, transformations, and storage destinations. Data-centric lens answering "Where is the data?"4---56# Data Lineage Architecture Lens78**Cognitive Mode:** Data-Centric9**Primary Question:** "Where is the data?"10**Focus:** Information Flow, Transformations, Storage Locations, Format Conversions1112## When to Use1314- Need to understand how data flows through the system15- Documenting data transformations and conversions16- Identifying storage destinations and access patterns17- User invokes `/arch-lens-data-lineage` or `/make-arch-diag data`1819## Critical Constraints2021**NEVER:**22- Modify any source code files23- Focus on runtime behavior (that's process flow lens)24- Show static structure without data context2526**ALWAYS:**27- Trace data from INPUT to STORAGE28- Show transformation stages and format changes29- Identify the single source of truth30- Distinguish read vs write operations31- BEFORE creating any diagram, LOAD the `/mermaid` skill using the Skill tool - this is MANDATORY3233---3435## Analysis Workflow3637### Step 1: Launch Parallel Exploration Subagents3839Spawn Explore subagents to investigate:4041**Data Origins (Inputs)**42- Find user input handling43- Identify external data sources44- Look for: CLI args, API requests, file reads, imports, user input, data ingestion4546**Transformation Stages**47- Find data conversion/transformation code48- Identify adapters and converters49- Look for: Adapter, Converter, transform, parse, serialize, from_*, to_*, mapping, conversion5051**Format Changes**52- Find schema definitions and conversions53- Identify format boundaries (JSON, XML, protobuf, etc.)54- Look for: schema models, type definitions, serialization, deserialization, format conversion5556**Storage Destinations**57- Find database operations58- Identify file outputs59- Look for: database operations, persistence, .save(), .create(), .write(), storage6061**Access Patterns**62- Find data retrieval code63- Identify query patterns64- Look for: .get(), .query(), .find(), .load(), read operations, data access layer6566### Step 2: Map Data Flow6768Document the journey of key data entities:69- **Origin**: Where does it come from?70- **Transformations**: What changes happen?71- **Storage**: Where is it persisted?72- **Retrieval**: How is it accessed later?7374**CRITICAL - Analyze Read/Write Direction:**75For EVERY storage location and data flow:76- **Read sources (inputs)**: Components that READ from this location77- **Write destinations (outputs)**: Components that WRITE to this location78- **Read-write (primary storage)**: Both read and written by the system79- **Write-only (artifacts)**: Written but NEVER read back by the system8081Clearly distinguish:82- Primary storage (source of truth) - system reads AND writes83- Write-only artifacts (debugging, logging) - system writes but never reads back84- External inputs - system reads only8586Use different arrow styles:87- Solid arrows for read/write primary storage88- Dashed arrows for write-only artifacts8990### Step 3: Identify Conversion Boundaries9192Find format changes:93- External format -> Internal format94- Internal format -> Database format95- Database format -> API response96- Note naming convention changes9798### Step 4: Create the Diagram99100Use flowchart with:101102**Direction:** `LR` (left-to-right) for data flow, or `TB` for hierarchical103104**Subgraphs for Stages:**105- Input/Origins106- Transformation/Processing107- Storage (primary)108- Artifacts (secondary/write-only)109- External Sync (if applicable)110111**Node Styling:**112- `cli` class: Data origins, user input113- `handler` class: Transformation, adapters114- `stateNode` class: Database tables, primary storage115- `output` class: Write-only artifacts, files116- `integration` class: External sync, APIs117118**Connection Types:**119- Solid arrows for primary data flow120- Dashed arrows for write-only/secondary121- Label with operation names122123**Database Nodes:**124- Use cylinder shape: `[(Label)]`125- Show table relationships126127### Step 5: Write Output128129Write the diagram to: `temp/arch-lens-data-lineage/arch_diag_data_lineage_{YYYY-MM-DD_HHMMSS}.md`130131---132133## Output Template134135```markdown136# Data Lineage Diagram: {System Name}137138**Lens:** Data Lineage (Data-Centric)139**Question:** Where is the data?140**Date:** {YYYY-MM-DD}141**Scope:** {What was analyzed}142143## Data Flow Overview144145| Stage | Format | Key Transformation |146|-------|--------|-------------------|147| Input | {format} | {description} |148| Processing | {format} | {description} |149| Storage | {format} | {description} |150151## Lineage Diagram152153```mermaid154%%{init: {'flowchart': {'nodeSpacing': 50, 'rankSpacing': 60, 'curve': 'basis'}}}%%155flowchart LR156 %% CLASS DEFINITIONS %%157 classDef cli fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;158 classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;159 classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;160 classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;161 classDef output fill:#00695c,stroke:#4db6ac,stroke-width:2px,color:#fff;162 classDef integration fill:#c62828,stroke:#ef9a9a,stroke-width:2px,color:#fff;163164 subgraph Input ["Data Origins"]165 USER["User Input<br/>━━━━━━━━━━<br/>Source type<br/>Format"]166 end167168 subgraph Transform ["Transformation"]169 direction TB170 ADAPTER["Adapter<br/>━━━━━━━━━━<br/>Conversion type"]171 end172173 subgraph Storage ["Primary Storage (Source of Truth)"]174 direction TB175 DB[("Database Table<br/>━━━━━━━━━━<br/>Key fields")]176 end177178 subgraph Artifacts ["Write-Only Artifacts"]179 direction TB180 FILE["output.json<br/>━━━━━━━━━━<br/>For debugging"]181 end182183 %% FLOWS %%184 USER -->|"input"| ADAPTER185 ADAPTER -->|"save()"| DB186 DB -.->|"write-only"| FILE187188 %% CLASS ASSIGNMENTS %%189 class USER cli;190 class ADAPTER handler;191 class DB stateNode;192 class FILE output;193```194195**Color Legend:**196| Color | Category | Description |197|-------|----------|-------------|198| Dark Blue | Input | Data origins (user, external) |199| Orange | Transform | Format conversion and adapters |200| Teal | Storage | Primary storage (source of truth) |201| Dark Teal | Artifacts | Write-only outputs |202| Red | Sync | External sync services |203204## Data Transformation Summary205206| Stage | Format | Key Conversion |207|-------|--------|----------------|208| {stage} | {format} | {conversion} |209210## Storage Destinations211212| Entity | Primary Storage | Secondary | Access Pattern |213|--------|-----------------|-----------|----------------|214| {entity} | {location} | {artifact} | {how accessed} |215216## Critical Design Principle217218> **Source of Truth**: {e.g., "Database is single source of truth. File outputs are write-only."}219```220221---222223## Pre-Diagram Checklist224225Before creating the diagram, verify:226227- [ ] LOADED `/mermaid` skill using the Skill tool228- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)229- [ ] Diagram will include a color legend table230231---232233## Related Skills234235- `/make-arch-diag` - Parent skill for lens selection236- `/mermaid` - MUST BE LOADED before creating diagram237- `/arch-lens-c4-container` - For container-level storage view