Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions architectures/agentic-architecture/data-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
technology: Agentic Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [ai-agents, orchestration, multi-agent-systems, vibe-coding, best-practices]
ai_role: Senior Software Architect
last_updated: 2026-04-17
---

# Agentic Architecture - Data Flow

## Request and Event Lifecycle

```mermaid
graph TD
User[User Request] --> Orchestrator[Orchestrator Agent]
Orchestrator --> |Decomposes task| Planner[Planner Agent]
Planner -.-> |Plan| Orchestrator
Orchestrator --> |Delegates| Coder[Coder Agent]
Orchestrator --> |Delegates| Reviewer[Reviewer Agent]
Coder -.-> |Code output| Reviewer
Reviewer -.-> |Verification| Orchestrator
Orchestrator --> DB[(Shared Context / Memory)]

%% Added Design Token Styles for Mermaid Diagrams
classDef default fill:#e1f5fe,stroke:#03a9f4,stroke-width:2px,color:#000;
classDef component fill:#e8f5e9,stroke:#4caf50,stroke-width:2px,color:#000;
classDef layout fill:#f3e5f5,stroke:#9c27b0,stroke-width:2px,color:#000;

class User component;
class Orchestrator layout;
class Planner component;
class Coder component;
class Reviewer component;
class DB default;
```
30 changes: 30 additions & 0 deletions architectures/agentic-architecture/folder-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
technology: Agentic Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [ai-agents, orchestration, multi-agent-systems, vibe-coding, best-practices]
ai_role: Senior Software Architect
last_updated: 2026-04-17
---

# Agentic Architecture - Folder Structure

## Layering logic

```mermaid
classDiagram
note for Src "Root source directory"
note for Orchestrator "Main coordinator agent"
note for Workers "Specialized worker agents (Planner, Coder, Reviewer)"
note for Memory "Shared context and validation schemas"

class Src:::component
class Orchestrator:::component
class Workers:::component
class Memory:::component

Src *-- Orchestrator
Src *-- Workers
Src *-- Memory
```
69 changes: 69 additions & 0 deletions architectures/agentic-architecture/implementation-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
technology: Agentic Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [ai-agents, orchestration, multi-agent-systems, vibe-coding, best-practices]
ai_role: Senior Software Architect
last_updated: 2026-04-17
---

# Agentic Architecture - Implementation Guide

## Monolithic Agent State Management

### ❌ Bad Practice

```typescript
class MonolithicAIAgent {
constructor(private readonly llm: LLMClient) {}

async handleRequest(userPrompt: string) {
const fullContext = await this.gatherAllSystemContext();
const prompt = `Plan this out, write the code, and review it.
Here is the entire database context: ${fullContext}
Task: ${userPrompt}`;

const response = await this.llm.generate(prompt);
eval(response.code);
return response;
}
}
```

### ⚠️ Problem

Loading a monolithic agent with unbounded context leads to "Context Explosion", resulting in non-deterministic hallucinations, excessive token costs, and security risks (like arbitrary code execution). A single LLM call attempting multiple distinct personas (Planner, Coder, Reviewer) fundamentally degrades reasoning quality.

### ✅ Best Practice

```typescript
interface AgentTask {
goal: string;
context: unknown;
}

class OrchestratorAgent {
constructor(
private readonly planner: PlannerAgent,
private readonly coder: CoderAgent,
private readonly reviewer: ReviewerAgent
) {}

async processTask(userPrompt: string) {
const executionPlan = await this.planner.plan({ goal: userPrompt, context: {} });
const codePayload = await this.coder.execute({ goal: executionPlan.codingSteps, context: executionPlan.schema });
const isApproved = await this.reviewer.validate({ goal: 'Verify code matches schema', context: codePayload });

if (!isApproved) {
throw new Error("Validation failed in Review phase");
}

return codePayload;
}
}
```

### 🚀 Solution

Implementing an **Orchestrator-Worker pattern** strictly isolates responsibilities. Each specialized agent receives only the exact context required for its task (O(1) relevant context per agent), lowering token overhead and drastically increasing deterministic reliability. Validating structured data at every handoff ensures resilient, secure, and predictable Multi-Agent execution.
97 changes: 5 additions & 92 deletions architectures/agentic-architecture/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,101 +26,14 @@ last_updated: 2026-04-17

This architecture defines the operational boundaries for multi-agent workflows, specifically optimizing for context windows, token efficiency, and deterministic output.

- 🌊 **Data Flow:** Orchestrator-to-Worker execution paths.
- 📁 **Folder Structure:** Modular isolation of Prompts, Skills, and Contexts.
- ⚖️ **Trade-offs:** Latency vs. Reasoning depth.
- 🛠️ **Implementation Guide:** Rules for defining strict agent personas and constraints.

```mermaid
graph TD
User[User Request] --> Orchestrator[Orchestrator Agent]
Orchestrator --> |Decomposes task| Planner[Planner Agent]
Planner -.-> |Plan| Orchestrator
Orchestrator --> |Delegates| Coder[Coder Agent]
Orchestrator --> |Delegates| Reviewer[Reviewer Agent]
Coder -.-> |Code output| Reviewer
Reviewer -.-> |Verification| Orchestrator
Orchestrator --> DB[(Shared Context / Memory)]

%% Added Design Token Styles for Mermaid Diagrams
classDef default fill:#e1f5fe,stroke:#03a9f4,stroke-width:2px,color:#000;
classDef component fill:#e8f5e9,stroke:#4caf50,stroke-width:2px,color:#000;
classDef layout fill:#f3e5f5,stroke:#9c27b0,stroke-width:2px,color:#000;

class User component;
class Orchestrator layout;
class Planner component;
class Coder component;
class Reviewer component;
class DB default;
```
- 🌊 [**Data Flow:** Orchestrator-to-Worker execution paths](./data-flow.md)
- 📁 [**Folder Structure:** Modular isolation of Prompts, Skills, and Contexts](./folder-structure.md)
- ⚖️ [**Trade-offs:** Latency vs. Reasoning depth](./trade-offs.md)
- 🛠️ [**Implementation Guide:** Rules for defining strict agent personas and constraints](./implementation-guide.md)

## 🚀 The Core Philosophy

Agentic Architecture emphasizes the decomposition of monolithic tasks into granular, specialized agent workloads managed by a central Orchestrator. This resolves massive context window pollution and isolates functional logic.

> [!IMPORTANT]
> **AI Constraint:** Agents MUST NOT mutate shared global state directly. They must return deterministic structured data (e.g., JSON schema) to the Orchestrator, which strictly validates the payload before persisting it.

---

## 1. Monolithic Agent State Management

### ❌ Bad Practice
```typescript
class MonolithicAIAgent {
constructor(private readonly llm: LLMClient) {}

async handleRequest(userPrompt: string) {
// Agent attempts to plan, code, and review all at once with unbounded context
const fullContext = await this.gatherAllSystemContext();
const prompt = `Plan this out, write the code, and review it.
Here is the entire database context: ${fullContext}
Task: ${userPrompt}`;

const response = await this.llm.generate(prompt);
// Unsafe execution of non-deterministic output
eval(response.code);
return response;
}
}
```

### ⚠️ Problem
Loading a monolithic agent with unbounded context leads to "Context Explosion", resulting in non-deterministic hallucinations, excessive token costs, and security risks (like arbitrary code execution). A single LLM call attempting multiple distinct personas (Planner, Coder, Reviewer) fundamentally degrades reasoning quality.

### ✅ Best Practice
```typescript
interface AgentTask {
goal: string;
context: unknown;
}

class OrchestratorAgent {
constructor(
private readonly planner: PlannerAgent,
private readonly coder: CoderAgent,
private readonly reviewer: ReviewerAgent
) {}

async processTask(userPrompt: string) {
// 1. Specialized Planner Agent isolates the task roadmap
const executionPlan = await this.planner.plan({ goal: userPrompt, context: {} });

// 2. Specialized Coder Agent executes ONLY the specific sub-tasks
const codePayload = await this.coder.execute({ goal: executionPlan.codingSteps, context: executionPlan.schema });

// 3. Specialized Reviewer Agent deterministically validates the output
const isApproved = await this.reviewer.validate({ goal: 'Verify code matches schema', context: codePayload });

if (!isApproved) {
throw new Error("Validation failed in Review phase");
}

return codePayload;
}
}
```

### 🚀 Solution
Implementing an **Orchestrator-Worker pattern** strictly isolates responsibilities. Each specialized agent receives only the exact context required for its task (O(1) relevant context per agent), lowering token overhead and drastically increasing deterministic reliability. Validating structured data at every handoff ensures resilient, secure, and predictable Multi-Agent execution.
> **AI Constraint:** Agents MUST NOT mutate shared global state directly. They must return deterministic structured data (e.g., JSON schema) to the Orchestrator, which strictly validates the payload before persisting it.
20 changes: 20 additions & 0 deletions architectures/agentic-architecture/trade-offs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
technology: Agentic Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [ai-agents, orchestration, multi-agent-systems, vibe-coding, best-practices]
ai_role: Senior Software Architect
last_updated: 2026-04-17
---

# Agentic Architecture - Trade-offs

## Pros, Cons, and System Constraints

| Aspect | Description | Impact |
| :--- | :--- | :--- |
| Latency | Multi-agent handoffs add latency | Cons |
| Token Efficiency | Specialized agents reduce context size | Pros |
| Determinism | Granular schemas yield deterministic outputs | Pros |
| Complexity | Requires robust orchestration and schemas | Cons |
31 changes: 31 additions & 0 deletions architectures/microkernel-architecture/data-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
technology: Microkernel Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [plugin-architecture, extensibility, solid-principles, core-system, architecture-patterns, best-practices]
ai_role: Senior Software Architect
last_updated: 2026-04-18
---

# Microkernel Architecture - Data Flow

## Core-to-Plugin execution paths

```mermaid
graph TD
Core[Core System / Microkernel] --> Registry[Plugin Registry]
Registry --> PluginA[Payment Plugin]
Registry --> PluginB[Notification Plugin]
Registry --> PluginC[Analytics Plugin]

%% Added Design Token Styles for Mermaid Diagrams
classDef default fill:#e1f5fe,stroke:#03a9f4,stroke-width:2px,color:#000;
classDef component fill:#e8f5e9,stroke:#4caf50,stroke-width:2px,color:#000;

class Core default;
class Registry default;
class PluginA component;
class PluginB component;
class PluginC component;
```
30 changes: 30 additions & 0 deletions architectures/microkernel-architecture/folder-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
technology: Microkernel Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [plugin-architecture, extensibility, solid-principles, core-system, architecture-patterns, best-practices]
ai_role: Senior Software Architect
last_updated: 2026-04-18
---

# Microkernel Architecture - Folder Structure

## Isolation of Core from Plugins

```mermaid
classDiagram
note for Src "Root source directory"
note for Core "Core system orchestrator and registry interfaces"
note for Plugins "Independent modules implementing core interfaces"
note for Shared "Data types and common utilities"

class Src:::component
class Core:::component
class Plugins:::component
class Shared:::component

Src *-- Core
Src *-- Plugins
Src *-- Shared
```
Loading
Loading