Skip to content

Commit f4ceb18

Browse files
committed
feat: add Mermaid visual context protocol and flowchart guide
1 parent 1e7bfaa commit f4ceb18

4 files changed

Lines changed: 89 additions & 3 deletions

File tree

AI_MAIN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Main function for AI workflow. Sequential logic. Strict execution. No fluff.
1313

1414
## 🚦 EXECUTION_FLOW (main)
1515

16-
1. [x] **LOAD_CONTEXT**: Read core protocol (APCP, Decision Log, Caveman, Context Optimization).
16+
1. [x] **LOAD_CONTEXT**: Read core protocol (APCP, Decision Log, Caveman, Context Optimization, Mermaid).
1717
2. [x] **TASK_ANALYSIS**: Create AI_MAIN.md framework.
1818
3. [x] **MODEL_DISPATCH**: Roles assigned (Flash for setup).
1919
4. [x] **IMPLEMENTATION**: Created AI_MAIN, TASK_PROGRESS, scripts/ (checkpoint.ps1, validate-repo.py, apcp-gather.py).
@@ -47,6 +47,7 @@ Main function for AI workflow. Sequential logic. Strict execution. No fluff.
4747
- [x] Task 4: Verify Caveman compliance.
4848
- [x] Task 7: Synchronize `AI_MAIN.md` with current repository state.
4949
- [x] Task 8: Implement Second Brain Sync Scenario (Scenario 0).
50+
- [x] Task 9: Implement Mermaid Visual Context Flowchart Protocol.
5051

5152
---
5253

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Paste the generated `PROMPT_READY.txt` into your AI assistant, or start with the
7979
| [`DOMAIN_SPECIFIC_GITIGNORE_PROTOCOLS.md`](./DOMAIN_SPECIFIC_GITIGNORE_PROTOCOLS.md) | Safe publishing patterns for different technical domains. |
8080
| [`SETUP_GUIDE.md`](./SETUP_GUIDE.md) | Step-by-step setup instructions. |
8181
| [`scripts/apcp-gather.py`](./scripts/apcp-gather.py) | Context packer that generates `PROMPT_READY.txt`. |
82+
| [`VISUAL_CONTEXT_MERMAID.md`](./VISUAL_CONTEXT_MERMAID.md) | Standardized Mermaid.js flowchart protocol for architecture and logic visualization. |
8283
| [`AGENTS.md`](./AGENTS.md) | Repository instructions for AI coding assistants and automation agents. |
8384
| [`examples/`](./examples/README.md) | Sanitized starter kits for web apps, backend APIs, and AI/RAG systems. |
8485

TASK_PROGRESS.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,16 @@ tasks:
7373
assignee: "Antigravity (AI)"
7474
description: "Create Scenario 0 in prompt templates for NotebookLM/Obsidian Knowledge Base export."
7575

76+
- id: TASK-009
77+
title: "Implement Mermaid Visual Context Flowchart Protocol"
78+
status: COMPLETED
79+
priority: MEDIUM
80+
effort: 1
81+
assignee: "Antigravity (AI)"
82+
description: "Create VISUAL_CONTEXT_MERMAID.md and integrate it into the repository core docs."
83+
7684
metrics:
77-
tasks_completed: 8
78-
total_tasks: 8
85+
tasks_completed: 9
86+
total_tasks: 9
7987
velocity: 1.0
8088
quality_score: 100%

VISUAL_CONTEXT_MERMAID.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# 📊 Visual Context Protocol: Mermaid Flowcharts
2+
3+
## 🎯 Purpose
4+
Provide developers and AI agents with a standardized way to visualize project architecture, workflows, and state transitions using [Mermaid.js](https://mermaid-js.github.io/mermaid/). Visual diagrams reduce cognitive load and help AI assistants understand complex relationships faster.
5+
6+
## ⚙️ Why use Mermaid?
7+
- **Text-Based**: Diagrams are stored as code (Markdown), making them version-controllable and token-efficient.
8+
- **AI-Friendly**: LLMs are excellent at generating and parsing Mermaid syntax.
9+
- **IDE Support**: Most modern IDEs (Cursor, VS Code, Obsidian) and GitHub/GitLab render Mermaid natively.
10+
11+
---
12+
13+
## 🏗️ Core Diagram Types
14+
15+
### 1. Architecture Map (High-Level)
16+
Use flowcharts to map directory structures, service boundaries, and data flow.
17+
18+
```mermaid
19+
graph TD
20+
A[User/Client] --> B[API Gateway]
21+
B --> C[Auth Service]
22+
B --> D[Product Service]
23+
D --> E[(PostgreSQL)]
24+
C --> F[(Redis)]
25+
```
26+
27+
### 2. Workflow / Logic Flow
28+
Visualize complex business logic or AI execution paths.
29+
30+
```mermaid
31+
graph LR
32+
Start --> CheckContext{Context Loaded?}
33+
CheckContext -- No --> Load[Load APCP]
34+
CheckContext -- Yes --> Task[Execute Task]
35+
Load --> Task
36+
Task --> Verify{Verify Quality}
37+
Verify -- Fail --> Task
38+
Verify -- Pass --> End
39+
```
40+
41+
### 3. State Machine
42+
Track the lifecycle of a task, order, or system state.
43+
44+
```mermaid
45+
stateDiagram-v2
46+
[*] --> Idle
47+
Idle --> Processing: New Task
48+
Processing --> Validating: Code Written
49+
Validating --> Done: Tests Pass
50+
Validating --> Processing: Fix Needed
51+
Done --> [*]
52+
```
53+
54+
---
55+
56+
## 🤖 Instructions for AI Agents
57+
58+
When an AI agent is asked to "visualize" or "explain the architecture," it should:
59+
1. **Identify Entities**: Determine the key components, files, or services.
60+
2. **Define Relationships**: Map how data or control flows between them.
61+
3. **Generate Mermaid**: Output a valid `mermaid` code block.
62+
4. **Prefer Flowcharts**: Use `graph TD` (Top-Down) or `graph LR` (Left-Right) for most scenarios.
63+
64+
**Prompt Snippet for Humans:**
65+
> "Generate a Mermaid flowchart explaining how the [Module Name] interacts with the database and external APIs."
66+
67+
---
68+
69+
## 🛠️ Integration with Nexus-APCP
70+
71+
- **Location**: Store complex diagrams in `docs/diagrams/` or embed them directly in `AI_PROJECT_CONTEXT_PROTOCOL.md`.
72+
- **Decision Logs**: Use Mermaid in `DECISION_LOG_PROTOCOL.md` to show "Before" vs "After" architecture during major refactors.
73+
- **Task Progress**: Use state diagrams to visualize long-running multi-stage tasks.
74+
75+
---
76+
*Nexus-APCP: Visualizing logic for faster engineering.* 📈🚀

0 commit comments

Comments
 (0)