-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVISUAL_ARCHITECTURE.txt
More file actions
348 lines (300 loc) · 23.8 KB
/
VISUAL_ARCHITECTURE.txt
File metadata and controls
348 lines (300 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
═══════════════════════════════════════════════════════════════════════════════
OUTCOME BACKCASTING ENGINE - MCP INTEGRATION ARCHITECTURE
═══════════════════════════════════════════════════════════════════════════════
╔═══════════════════════════════╗
║ BACKCASTING ENGINE CORE ║
║ (backcast_engine.py) ║
╚═══════════════════════════════╝
│
│ Core API
│
┏━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
▼ ▼
┏━━━━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━━━━┓
┃ CLI INTERFACE ┃ ┃ MCP SERVER ┃
┃ ┃ ┃ ┃
┃ Terminal Menu ┃ ┃ 12 Tools via ┃
┃ Colored Output ┃ ┃ JSON-RPC ┃
┃ Human Friendly ┃ ┃ stdin/stdout ┃
┗━━━━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━━━━┛
│ │
│ │
│ │ MCP Protocol
│ │
▼ ▼
┏━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━━━━━━━━┓
┃ HUMAN USERS ┃ ┃ AI ASSISTANTS ┃
┃ ┃ ┃ ┃
┃ • Terminal ┃ ┃ • Claude Code ┃
┃ • Desktop ┃ ┃ • ChatGPT ┃
┃ • Scripts ┃ ┃ • Custom AI Agents ┃
┗━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━━━━━━━━┛
═══════════════════════════════════════════════════════════════════════════════
MCP COMMUNICATION FLOW (DETAILED)
═══════════════════════════════════════════════════════════════════════════════
👤 USER 🤖 AI ASSISTANT
│ │
│ "Create plan for │
│ podcast launch" │
└──────────────────────────────────────────────────► │
│
│ Analyzes Intent
│ Selects MCP Tool
│
│
┌─────────────────────────────────────────┘
│ MCP Request (JSON-RPC)
│ {
│ "method": "tools/call",
│ "params": {
│ "name": "backcast_create_plan",
│ "arguments": {
│ "title": "Launch Podcast",
│ "timeline": "6 months"
│ }
│ }
│ }
│
▼
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ MCP SERVER (mcp_server.py) ┃
┃ ┃
┃ 1. Receive JSON-RPC via stdin ┃
┃ 2. Parse & validate request ┃
┃ 3. Route to handler: _create_plan() ┃
┃ 4. Call core engine: ┃
┃ • Create Outcome object ┃
┃ • Generate steps ┃
┃ • Save to JSON ┃
┃ 5. Format response ┃
┃ 6. Send JSON via stdout ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
│
│ MCP Response
│ {
│ "content": [{
│ "type": "text",
│ "text": "{'status': 'success',
│ 'steps_generated': 21}"
│ }]
│ }
│
└─────────────────────────────────────────┐
│
│
│ Formats Response
│
┌─────────────────────────────────────────────────────┘
│ 🤖 AI ASSISTANT
│ "I've created your podcast plan!
│ 21 steps across 6 months.
│ First action: Define podcast concept..."
│
◄────────────────────────────────────────────────
👤 USER
═══════════════════════════════════════════════════════════════════════════════
12 AVAILABLE MCP TOOLS
═══════════════════════════════════════════════════════════════════════════════
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ PLAN MANAGEMENT ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ ┃
┃ 🆕 backcast_create_plan ┃
┃ → Create new plan from outcome description ┃
┃ ┃
┃ 📂 backcast_load_plan ┃
┃ → Load existing plan by filename ┃
┃ ┃
┃ 📋 backcast_list_plans ┃
┃ → List all saved plans ┃
┃ ┃
┃ 💾 backcast_save_plan ┃
┃ → Save current plan to file ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ VIEW & QUERY ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ ┃
┃ 📊 backcast_get_overview ┃
┃ → Get plan summary, outcome, progress ┃
┃ ┃
┃ 📝 backcast_get_all_steps ┃
┃ → Get complete step list ┃
┃ ┃
┃ ▶️ backcast_get_next_actions ┃
┃ → Get steps ready to work on (most useful!) ┃
┃ ┃
┃ 🎯 backcast_get_critical_path ┃
┃ → Get longest dependency chain (bottlenecks) ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ MODIFY & ANALYZE ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ ┃
┃ ➕ backcast_add_step ┃
┃ → Add new step to plan ┃
┃ ┃
┃ ✏️ backcast_update_step_status ┃
┃ → Mark steps as complete/in-progress/blocked ┃
┃ ┃
┃ 📈 backcast_analyze_plan ┃
┃ → Comprehensive analysis (progress, risks, suggestions) ┃
┃ ┃
┃ 📄 backcast_export_markdown ┃
┃ → Export plan to Markdown format ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
═══════════════════════════════════════════════════════════════════════════════
MULTI-PLATFORM INTEGRATION MAP
═══════════════════════════════════════════════════════════════════════════════
┏━━━━━━━━━━━━━━━━━━━━━┓
┃ BACKCASTING ENGINE ┃
┃ (Core) ┃
┗━━━━━━━━━━━━━━━━━━━━━┛
│
┌───────────────────┼───────────────────┐
│ │ │
▼ ▼ ▼
┏━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━┓
┃ CLI Layer ┃ ┃ MCP Server ┃ ┃ Python Import ┃
┗━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━┛
│ │ │
┌───────┴───────┐ ┌───────┴───────┐ ┌───────┴───────┐
▼ ▼ ▼ ▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
│Terminal │ │Desktop │ │ Claude │ │ ChatGPT │ │ Scripts │
│ Users │ │ Icon │ │ Code │ │ AI │ │ Webhooks│
└─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘
ALL ACCESS SAME DATA:
┏━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ data/*.json files ┃
┃ • Plans ┃
┃ • Steps ┃
┃ • Progress ┃
┃ • Dependencies ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━┛
═══════════════════════════════════════════════════════════════════════════════
EXAMPLE: AI ASSISTANT USING MULTIPLE TOOLS IN SEQUENCE
═══════════════════════════════════════════════════════════════════════════════
USER: "Analyze my SaaS plan and tell me what to do next"
│
▼
AI THINKS: "I need to:
1. Load the plan
2. Get analysis
3. Get next actions
4. Synthesize response"
│
▼
┌────────────────────────────────────────────────────────────┐
│ CALL 1: backcast_load_plan("saas_launch.json") │
│ ────────────────────────────────────────────────────────── │
│ Response: "Plan loaded, 25 steps" │
└────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────┐
│ CALL 2: backcast_analyze_plan() │
│ ────────────────────────────────────────────────────────── │
│ Response: { │
│ "progress": {"percent": 48, "completed": 12}, │
│ "risks": [{"desc": "API rate limits", "impact": "high"}],│
│ "suggestions": ["Parallelize steps 15 & 16"], │
│ "blockers": [] │
│ } │
└────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────┐
│ CALL 3: backcast_get_next_actions() │
│ ────────────────────────────────────────────────────────── │
│ Response: [ │
│ {id: 13, title: "Set up payment system", priority: "critical"},│
│ {id: 14, title: "Design landing page", priority: "high"} │
│ ] │
└────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────┐
│ AI SYNTHESIZES: │
│ │
│ "📊 Your SaaS plan is 48% complete (12/25 steps done). │
│ │
│ ⚠️ Important risk: API rate limits could impact launch. │
│ Consider adding rate limiting middleware. │
│ │
│ 🎯 Your next action: [CRITICAL] Set up payment system │
│ This is blocking 3 other steps, so prioritize this! │
│ │
│ 💡 Tip: Steps 15 & 16 can run in parallel to save time." │
└────────────────────────────────────────────────────────────┘
│
▼
USER sees helpful, contextualized response!
═══════════════════════════════════════════════════════════════════════════════
WHY THIS ARCHITECTURE WINS
═══════════════════════════════════════════════════════════════════════════════
✅ SEPARATION OF CONCERNS
• Core logic independent of interfaces
• Can add new interfaces without touching core
• MCP server is thin adapter layer
✅ MULTIPLE ACCESS METHODS
• CLI for direct human use
• MCP for AI assistants
• Python import for scripts
• REST API potential for web apps
✅ SINGLE SOURCE OF TRUTH
• All interfaces read/write same JSON files
• No sync issues
• No data duplication
✅ AI-NATIVE DESIGN
• Structured tool definitions
• Clear input/output schemas
• Error handling built-in
• Composable operations
✅ EXTENSIBLE
• Easy to add new tools
• Can integrate with more AI platforms
• Can add new data sources
• Can build custom workflows
✅ PORTABLE
• Pure Python, no external dependencies
• JSON storage (human-readable)
• Standard protocols (JSON-RPC, MCP)
• Works anywhere Python runs
═══════════════════════════════════════════════════════════════════════════════
SETUP QUICK START
═══════════════════════════════════════════════════════════════════════════════
STEP 1: Verify MCP Server Works
─────────────────────────────────
$ cd /home/panda/Documents/PythonScripts/OutcomeBackcasting
$ echo '{"method": "tools/list"}' | python3 mcp_server.py
✓ Should return JSON with 12 tools
STEP 2: Add to Claude Code Config
───────────────────────────────────
$ nano ~/.config/claude-code/mcp_settings.json
Add:
{
"mcpServers": {
"backcast": {
"command": "python3",
"args": [
"/home/panda/Documents/PythonScripts/OutcomeBackcasting/mcp_server.py"
]
}
}
}
STEP 3: Restart Claude Code
─────────────────────────────
✓ MCP server auto-loads on startup
STEP 4: Test It!
──────────────────
Ask Claude: "List my backcasting plans"
✓ Should call backcast_list_plans tool
✓ Returns your saved plans
═══════════════════════════════════════════════════════════════════════════════
END OF ARCHITECTURE DIAGRAM - Full docs in ARCHITECTURE_DIAGRAM.md
═══════════════════════════════════════════════════════════════════════════════