Skip to main content

Knowledge Graph Architecture

Platform-Agnostic Knowledge Management System

This document describes the core architectural concepts behind the knowledge graph system.


Core Concept: The Four-Pillar Memory​

The knowledge graph uses four complementary knowledge systems, each optimized for different purposes:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ FOUR-PILLAR MEMORY β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Lessons Learned β”‚ β”‚ ADRs β”‚ β”‚
β”‚ β”‚ (Deep Dive) β”‚ β”‚ (Formal) β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β€’ Problem β”‚ β”‚ β€’ Context β”‚ β”‚
β”‚ β”‚ β€’ Root Cause β”‚ β”‚ β€’ Options β”‚ β”‚
β”‚ β”‚ β€’ Solution β”‚ β”‚ β€’ Decision β”‚ β”‚
β”‚ β”‚ β€’ Replication β”‚ β”‚ β€’ Consequences β”‚ β”‚
β”‚ β”‚ β€’ Lessons β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ 5-10 min read β”‚ β”‚ 3-5 min read β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Knowledge Graph β”‚ β”‚Session Summaries β”‚ β”‚
β”‚ β”‚ (Quick Ref) β”‚ β”‚ (Historical) β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β€’ Patterns β”‚ β”‚ β€’ Overview β”‚ β”‚
β”‚ β”‚ β€’ Concepts β”‚ β”‚ β€’ Built β”‚ β”‚
β”‚ β”‚ β€’ Gotchas β”‚ β”‚ β€’ Decided β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β€’ Learned β”‚ β”‚
β”‚ β”‚ 5-10 sec scan β”‚ β”‚ β€’ Next β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ Links to lessons β”‚ β”‚ 2-3 min scan β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The LEVERAGE Principle​

Knowledge Graph and Lessons Learned work together:

  • KG = Quick Reference (5-10 seconds)

    • Scan while working
    • Quick answer to "what is this?"
    • Links to deeper dive
  • Lessons = Deep Dive (5-10 minutes)

    • Read when needed
    • Full context and rationale
    • Replication steps

Bidirectional relationship:

  • KG links to detailed lessons ("see lesson for full context")
  • Lessons extract to KG entries ("key insights for quick reference")
  • Start with KG, drill into Lessons as needed

Information Flow​

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ WORK β”‚
β”‚ (Problems, β”‚
β”‚ Decisions, β”‚
β”‚ Learning) β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ CAPTURE β”‚
β”‚ β”‚
β”‚ β€’ Lesson Learned β”‚ ← Detailed problem-solving journey
β”‚ β€’ ADR β”‚ ← Formal architectural decision
β”‚ β€’ Session Summary β”‚ ← Work session snapshot
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”‚ (Extract key insights)
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ KNOWLEDGE GRAPH β”‚
β”‚ β”‚
β”‚ β€’ Pattern β”‚ ← Extracted from lesson
β”‚ β€’ Concept β”‚ ← Distilled from ADR
β”‚ β€’ Gotcha β”‚ ← Common pitfall documented
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”‚ (Bidirectional sync)
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ PROJECT MEMORY β”‚
β”‚ β”‚
β”‚ β€’ MEMORY.md β”‚ ← Platform persistent context
β”‚ β€’ Git metadata β”‚ ← Commits, branches, issues
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Capture β†’ Extract β†’ Sync​

  1. Capture: Document problem-solving in Lessons Learned or ADRs
  2. Extract: Pull key insights into Knowledge Graph for quick reference
  3. Sync: Update project memory (MEMORY.md) with new knowledge

Automation: The /kmgraph:sync-all command orchestrates this entire flow.


Directory Structure​

project/
β”œβ”€β”€ docs/
β”‚ β”œβ”€β”€ lessons-learned/ # PILLAR 1: Detailed narratives
β”‚ β”‚ β”œβ”€β”€ architecture/ # System design lessons
β”‚ β”‚ β”œβ”€β”€ debugging/ # Troubleshooting journeys
β”‚ β”‚ β”œβ”€β”€ process/ # Workflow improvements
β”‚ β”‚ └── patterns/ # Design pattern discoveries
β”‚ β”‚
β”‚ β”œβ”€β”€ decisions/ # PILLAR 2: Formal ADRs
β”‚ β”‚ β”œβ”€β”€ ADR-001.md # Numbered decisions
β”‚ β”‚ β”œβ”€β”€ ADR-002.md
β”‚ β”‚ └── ...
β”‚ β”‚
β”‚ β”œβ”€β”€ knowledge/ # PILLAR 3: Quick reference
β”‚ β”‚ β”œβ”€β”€ patterns.md # Design patterns catalog
β”‚ β”‚ β”œβ”€β”€ concepts.md # Core concepts definitions
β”‚ β”‚ └── gotchas.md # Common pitfalls
β”‚ β”‚
β”‚ └── sessions/ # PILLAR 4: Historical snapshots
β”‚ └── 2024-12/
β”‚ β”œβ”€β”€ session-001.md
β”‚ └── session-002.md
β”‚
└── MEMORY.md # Platform persistent context

Why This Structure?​

Separation by purpose:

  • Lessons: "How we solved X" (narrative, chronological)
  • ADRs: "Why we chose Y" (decision rationale, formal)
  • Knowledge Graph: "Quick facts about Z" (reference, timeless)
  • Sessions: "What happened when" (snapshots, historical)

Different longevity:

  • Lessons & ADRs: Permanent (referenced years later)
  • Knowledge Graph: Evolving (updated as understanding improves)
  • Sessions: Historical (snapshot, not updated)

Knowledge Capture Workflow​

Manual (No Automation)​

# 1. Copy template
cp core/templates/lessons-learned/lesson-template.md \
docs/lessons-learned/process/my-lesson.md

# 2. Fill in sections
vim docs/lessons-learned/process/my-lesson.md

# 3. Update category README
vim docs/lessons-learned/process/README.md
# Add link to my-lesson.md

# 4. Extract to knowledge graph (manual)
vim docs/knowledge/patterns.md
# Add pattern extracted from lesson

# 5. Commit
git add docs/
git commit -m "docs: add lesson on my-topic"

Automated (Claude Code)​

# Single command does all steps
/kmgraph:capture-lesson

# Prompts for:
# - Topic
# - Category (auto-detected)
# - Content

# Automatically:
# - Creates from template
# - Adds git metadata
# - Updates category README
# - Commits with standard message
# - (Optional) Updates knowledge graph

Full Pipeline (Sync-All)​

/kmgraph:sync-all

# Orchestrates:
# 1. Capture lesson (if applicable)
# 2. Update knowledge graph
# 3. Update MEMORY.md
# 4. Create session summary
# 5. Commit everything with links

Scalability​

Small Project (1-5 people)​

  • Lessons: 10-50 total
  • ADRs: 5-15 total
  • KG entries: 20-100 across patterns/concepts/gotchas
  • Management: Manual browsing, grep search

Medium Project (6-20 people)​

  • Lessons: 50-200 total
  • ADRs: 15-50 total
  • KG entries: 100-300
  • Management: Category organization, search tools, curator role

Large Project (20+ people)​

  • Lessons: 200+ total
  • ADRs: 50+ total
  • KG entries: 300+
  • Management: Tag system, dedicated search, knowledge subteam

Archival Strategy​

For very large knowledge bases:

docs/
β”œβ”€β”€ lessons-learned/
β”‚ β”œβ”€β”€ 2024/ # Active year
β”‚ └── archive/
β”‚ β”œβ”€β”€ 2023/ # Previous years
β”‚ └── 2022/

Archive lessons older than 2 years (still searchable, just organized).


Privacy & Sanitization Architecture​

Layers of Protection​

  1. Templates: No sensitive data by default
  2. Examples: All generalized, no real data
  3. Pre-commit Hook: Scans for patterns before commit
  4. Sanitization Checklist: Manual review before sharing

What to Sanitize​

  • Personal information (emails, names, phone numbers)
  • Authentication (API keys, passwords, tokens)
  • Infrastructure (internal IPs, URLs, database strings)
  • Company/customer-specific data

See SANITIZATION-CHECKLIST.md for complete guide.


Platform Integration​

Claude Code (Full Automation)​

  • Skills for all workflows
  • SessionStart hooks auto-check
  • Subagents for review
  • MEMORY.md bidirectional sync

Other Platforms (Manual + Core)​

  • Copy core/ to project
  • Use templates manually
  • Follow workflows in core/docs/WORKFLOWS.md
  • Optionally use MCP server

MCP Server (Universal Access)​

Expose knowledge graph as MCP resources:

  • resource://knowledge/patterns
  • resource://knowledge/lessons
  • tool://knowledge/search

Any MCP-compatible platform can access.


Design Rationale​

Why Markdown?​

  • Human-readable
  • Version-controllable (git)
  • Platform-agnostic
  • Rich formatting support
  • Grep-able

Why Git Integration?​

  • Version history of knowledge
  • Branching for experiments
  • PR review of documentation
  • Metadata linking (commit β†’ lesson)

Why Bidirectional Sync?​

  • KG stays current (updated from lessons)
  • Lessons stay connected (linked from KG)
  • Platform memory stays fresh (MEMORY.md)
  • All systems reinforce each other