# brijeshsingaravel/shadow-joyboy architecture

> Architecture diagram of the GitHub repository brijeshsingaravel/shadow-joyboy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brijeshsingaravel/shadow-joyboy
- Repository: https://github.com/brijeshsingaravel/shadow-joyboy

## Overview

Shadow is a local-first conversational agent centered on persistent, semantic memory and permission-gated actions. The documented user path is chat input through a checkpointed agent graph, an LLM response, and available tools, with actions audited. Major supporting branches include layered memory and project-scoped history, model routing, configurable tools and MCP, security, evaluation signals, and memory consolidation. Relationships are limited to README claims and SOURCE INDEX references; unsampled implementations are represented only at supported directory paths, and the README notes consolidation is not scheduled here.

Main entry points: [`src/madras/graph/llm_responder.py`](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/graph/llm_responder.py) (LLM responder), [`src/madras/tools/registry.py`](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/tools/registry.py) (Tool registry), [`src/madras/memory`](https://github.com/brijeshsingaravel/shadow-joyboy/tree/main/src/madras/memory) (Layered memory), [`src/madras/graph/orchestration.py`](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/graph/orchestration.py) (Agent graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversation["Conversation runtime"]
  node_cli["Chat CLI<br/>[cli.py]"]
  node_graph["Agent graph<br/>[orchestration.py]"]
  node_responder["LLM responder<br/>[llm_responder.py]"]
end

subgraph group_memory["Memory and history"]
  node_memory_store[("Layered memory")]
  node_vector["Semantic retrieval<br/>[vector.py]"]
  node_project_history[("Project history<br/>[ledger.py]")]
  node_consolidation["Memory consolidation"]
end

subgraph group_governance["Tools and governance"]
  node_tool_registry["Tool registry<br/>[registry.py]"]
  node_builtin_tools["Built-in tools"]
  node_mcp["MCP integration<br/>[client.py]"]
  node_guardrails["Action permissions<br/>[guardrails.py]"]
  node_audit[("Append-only audit")]
end

subgraph group_models["Model and evaluation"]
  node_llm_gateway["LLM gateway<br/>[gateway.py]"]
  node_model_catalog["Model catalog<br/>[model_catalog.py]"]
  node_eval_signals["Action evaluation<br/>[emitter.py]"]
end

subgraph group_support["Agent support"]
  node_config["Agent configuration<br/>[config.py]"]
  node_factory["Agent factory<br/>[spawn.py]"]
  node_cap_catalog["Capability catalog<br/>[catalog.py]"]
  node_persona["Persona anchor<br/>[anchor.py]"]
end

node_user(("User"))

node_user -->|"starts chat"| node_cli
node_cli -.->|"runs agent"| node_graph
node_graph -.->|"routes turn"| node_responder
node_responder -->|"requests completion"| node_llm_gateway
node_responder -->|"checks input"| node_guardrails
node_responder -->|"reads session"| node_project_history
node_responder -->|"builds prompt"| node_persona
node_responder -->|"emits signals"| node_eval_signals
node_graph -.->|"dispatches tools"| node_tool_registry
node_tool_registry -->|"registers tools"| node_builtin_tools
node_tool_registry -->|"gates actions"| node_guardrails
node_tool_registry -->|"records actions"| node_audit
node_builtin_tools -.->|"accesses memory"| node_memory_store
node_tool_registry -.->|"invokes MCP"| node_mcp
node_memory_store -->|"embeds for recall"| node_vector
node_project_history -.->|"keeps project context"| node_memory_store
node_consolidation -.->|"consolidates memories"| node_memory_store
node_factory -->|"loads configuration"| node_config
node_factory -->|"resolves tools"| node_tool_registry
node_cap_catalog -.->|"provides capabilities"| node_factory
node_llm_gateway -.->|"selects models"| node_model_catalog

click node_cli "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/cli.py"
click node_graph "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/graph/orchestration.py"
click node_responder "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/graph/llm_responder.py"
click node_memory_store "https://github.com/brijeshsingaravel/shadow-joyboy/tree/main/src/madras/memory"
click node_vector "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/memory/vector.py"
click node_project_history "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/mindpalace/ledger.py"
click node_consolidation "https://github.com/brijeshsingaravel/shadow-joyboy/tree/main/src/madras/memory_manager"
click node_tool_registry "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/tools/registry.py"
click node_builtin_tools "https://github.com/brijeshsingaravel/shadow-joyboy/tree/main/src/madras/tools/builtin"
click node_mcp "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/mcp/client.py"
click node_guardrails "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/security/guardrails.py"
click node_audit "https://github.com/brijeshsingaravel/shadow-joyboy/tree/main/src/madras/audit"
click node_config "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/config.py"
click node_factory "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/factory/spawn.py"
click node_cap_catalog "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/packages/madras-capabilities/src/madras_capabilities/catalog.py"
click node_llm_gateway "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/llm/gateway.py"
click node_model_catalog "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/llm/model_catalog.py"
click node_eval_signals "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/eval_/emitter.py"
click node_persona "https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/persona/anchor.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_graph,node_responder,node_user toneBlue
class node_memory_store,node_vector,node_project_history,node_consolidation toneAmber
class node_tool_registry,node_builtin_tools,node_mcp,node_guardrails,node_audit toneMint
class node_llm_gateway,node_model_catalog,node_eval_signals toneRose
class node_config,node_factory,node_cap_catalog,node_persona toneIndigo
```

## Components

### Conversation runtime

- [Chat CLI](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/cli.py): `src/madras/cli.py`
- [Agent graph](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/graph/orchestration.py): `src/madras/graph/orchestration.py`
- [LLM responder](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/graph/llm_responder.py): `src/madras/graph/llm_responder.py`

### Memory and history

- [Layered memory](https://github.com/brijeshsingaravel/shadow-joyboy/tree/main/src/madras/memory): `src/madras/memory`
- [Semantic retrieval](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/memory/vector.py): `src/madras/memory/vector.py`
- [Project history](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/mindpalace/ledger.py): `src/madras/mindpalace/ledger.py`
- [Memory consolidation](https://github.com/brijeshsingaravel/shadow-joyboy/tree/main/src/madras/memory_manager): `src/madras/memory_manager`

### Tools and governance

- [Tool registry](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/tools/registry.py): `src/madras/tools/registry.py`
- [Built-in tools](https://github.com/brijeshsingaravel/shadow-joyboy/tree/main/src/madras/tools/builtin): `src/madras/tools/builtin`
- [MCP integration](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/mcp/client.py): `src/madras/mcp/client.py`
- [Action permissions](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/security/guardrails.py): `src/madras/security/guardrails.py`
- [Append-only audit](https://github.com/brijeshsingaravel/shadow-joyboy/tree/main/src/madras/audit): `src/madras/audit`

### Model and evaluation

- [LLM gateway](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/llm/gateway.py): `src/madras/llm/gateway.py`
- [Model catalog](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/llm/model_catalog.py): `src/madras/llm/model_catalog.py`
- [Action evaluation](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/eval_/emitter.py): `src/madras/eval_/emitter.py`

### Agent support

- [Agent configuration](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/config.py): `src/madras/config.py`
- [Agent factory](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/factory/spawn.py): `src/madras/factory/spawn.py`
- [Capability catalog](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/packages/madras-capabilities/src/madras_capabilities/catalog.py): `packages/madras-capabilities/src/madras_capabilities/catalog.py`
- [Persona anchor](https://github.com/brijeshsingaravel/shadow-joyboy/blob/main/src/madras/persona/anchor.py): `src/madras/persona/anchor.py`

### Other components

- **User**

## Connections

- User → Chat CLI: starts chat (evidence: `README.md`)
- Chat CLI → Agent graph: runs agent
- Agent graph → LLM responder: routes turn
- LLM responder → LLM gateway: requests completion (evidence: `src/madras/graph/llm_responder.py`)
- LLM responder → Action permissions: checks input (evidence: `src/madras/graph/llm_responder.py`)
- LLM responder → Project history: reads session (evidence: `src/madras/graph/llm_responder.py`)
- LLM responder → Persona anchor: builds prompt (evidence: `src/madras/graph/llm_responder.py`)
- LLM responder → Action evaluation: emits signals (evidence: `src/madras/graph/llm_responder.py`)
- Agent graph → Tool registry: dispatches tools
- Tool registry → Built-in tools: registers tools (evidence: `README.md`)
- Tool registry → Action permissions: gates actions (evidence: `README.md`)
- Tool registry → Append-only audit: records actions (evidence: `README.md`)
- Built-in tools → Layered memory: accesses memory
- Tool registry → MCP integration: invokes MCP
- Layered memory → Semantic retrieval: embeds for recall (evidence: `src/madras/metacog/analogy_engine.py`)
- Project history → Layered memory: keeps project context
- Memory consolidation → Layered memory: consolidates memories
- Agent factory → Agent configuration: loads configuration (evidence: `src/madras/factory/spawn.py`)
- Agent factory → Tool registry: resolves tools (evidence: `src/madras/factory/spawn.py`)
- Capability catalog → Agent factory: provides capabilities
- LLM gateway → Model catalog: selects models
