# skarnati20/apprentice architecture

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

- Interactive diagram: https://gitdiagram.com/skarnati20/apprentice
- Repository: https://github.com/skarnati20/apprentice

## Overview

Apprentice is a configurable Common Lisp coding harness. A user starts a chat turn; the selected loop orchestrates model output and tool requests, while enabled anchors preprocess repository context. The README also documents model and loop selection, conversation-history controls, subagents, and file/embedding-related anchor capabilities. Paths below follow the file tree and README feature names; source excerpts were not provided, so links are limited to relationships the README states explicitly.

Main entry points: [`apprentice.lisp`](https://github.com/skarnati20/apprentice/blob/main/apprentice.lisp) (Chat Interface), [`loop.lisp`](https://github.com/skarnati20/apprentice/blob/main/loop.lisp) (Coding Loops), [`anchor.lisp`](https://github.com/skarnati20/apprentice/blob/main/anchor.lisp) (Anchor Abstractions), [`model.lisp`](https://github.com/skarnati20/apprentice/blob/main/model.lisp) (Model Abstractions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Chat and State"]
  node_chat["Chat Interface<br/>[apprentice.lisp]"]
  node_history[("Conversation History<br/>[conversations.lisp]")]
  node_state["Harness State<br/>[state.lisp]"]
  node_prompts["Prompt Construction<br/>[prompts.lisp]"]
end

subgraph group_orchestration["Harness Orchestration"]
  node_loops["Coding Loops<br/>[loop.lisp]"]
  node_subagent["Subagents<br/>[subagent.lisp]"]
  node_helpers["Harness Helpers<br/>[helpers.lisp]"]
end

subgraph group_context["Repository Context"]
  node_anchors["Anchor Abstractions<br/>[anchor.lisp]"]
  node_files["Repository Files<br/>[file.lisp]"]
  node_embeddings["Vector Embeddings<br/>[embedding.lisp]"]
  node_chunks["Text Chunks<br/>[chunk.lisp]"]
end

subgraph group_configuration["Model and Tools"]
  node_model["Model Abstractions<br/>[model.lisp]"]
  node_tools["Tool Abstractions<br/>[tool.lisp]"]
end

node_user(("User"))
node_provider{{"LLM Provider"}}

node_user -->|"starts turn"| node_chat
node_chat -->|"runs turn"| node_loops
node_loops -->|"requests response"| node_model
node_model -->|"sends request"| node_provider
node_loops -->|"handles requests"| node_tools
node_anchors -->|"processes files"| node_files
node_chat -->|"manages turns"| node_history
node_chat -->|"sets harness options"| node_state
node_anchors -.-> node_embeddings
node_anchors -.-> node_chunks
node_loops -.-> node_prompts
node_subagent -.-> node_model
node_chat -.-> node_helpers

click node_chat "https://github.com/skarnati20/apprentice/blob/main/apprentice.lisp"
click node_history "https://github.com/skarnati20/apprentice/blob/main/conversations.lisp"
click node_state "https://github.com/skarnati20/apprentice/blob/main/state.lisp"
click node_prompts "https://github.com/skarnati20/apprentice/blob/main/prompts.lisp"
click node_loops "https://github.com/skarnati20/apprentice/blob/main/loop.lisp"
click node_subagent "https://github.com/skarnati20/apprentice/blob/main/subagent.lisp"
click node_model "https://github.com/skarnati20/apprentice/blob/main/model.lisp"
click node_tools "https://github.com/skarnati20/apprentice/blob/main/tool.lisp"
click node_anchors "https://github.com/skarnati20/apprentice/blob/main/anchor.lisp"
click node_files "https://github.com/skarnati20/apprentice/blob/main/file.lisp"
click node_embeddings "https://github.com/skarnati20/apprentice/blob/main/embedding.lisp"
click node_chunks "https://github.com/skarnati20/apprentice/blob/main/chunk.lisp"
click node_helpers "https://github.com/skarnati20/apprentice/blob/main/helpers.lisp"

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_chat,node_history,node_state,node_prompts,node_user toneBlue
class node_loops,node_subagent,node_helpers toneAmber
class node_anchors,node_files,node_embeddings,node_chunks toneMint
class node_model,node_tools toneRose
class node_provider toneIndigo
```

## Components

### Chat and State

- [Chat Interface](https://github.com/skarnati20/apprentice/blob/main/apprentice.lisp): `apprentice.lisp`
- [Conversation History](https://github.com/skarnati20/apprentice/blob/main/conversations.lisp): `conversations.lisp`
- [Harness State](https://github.com/skarnati20/apprentice/blob/main/state.lisp): `state.lisp`
- [Prompt Construction](https://github.com/skarnati20/apprentice/blob/main/prompts.lisp): `prompts.lisp`

### Harness Orchestration

- [Coding Loops](https://github.com/skarnati20/apprentice/blob/main/loop.lisp): `loop.lisp`
- [Subagents](https://github.com/skarnati20/apprentice/blob/main/subagent.lisp): `subagent.lisp`
- [Harness Helpers](https://github.com/skarnati20/apprentice/blob/main/helpers.lisp): `helpers.lisp`

### Repository Context

- [Anchor Abstractions](https://github.com/skarnati20/apprentice/blob/main/anchor.lisp): `anchor.lisp`
- [Repository Files](https://github.com/skarnati20/apprentice/blob/main/file.lisp): `file.lisp`
- [Vector Embeddings](https://github.com/skarnati20/apprentice/blob/main/embedding.lisp): `embedding.lisp`
- [Text Chunks](https://github.com/skarnati20/apprentice/blob/main/chunk.lisp): `chunk.lisp`

### Model and Tools

- [Model Abstractions](https://github.com/skarnati20/apprentice/blob/main/model.lisp): `model.lisp`
- [Tool Abstractions](https://github.com/skarnati20/apprentice/blob/main/tool.lisp): `tool.lisp`

### Other components

- **User**
- **LLM Provider**

## Connections

- User → Chat Interface: starts turn (evidence: `README.md`)
- Chat Interface → Coding Loops: runs turn (evidence: `README.md`)
- Coding Loops → Model Abstractions: requests response (evidence: `README.md`)
- Model Abstractions → LLM Provider: sends request (evidence: `README.md`)
- Coding Loops → Tool Abstractions: handles requests (evidence: `README.md`)
- Anchor Abstractions → Repository Files: processes files (evidence: `README.md`)
- Chat Interface → Conversation History: manages turns (evidence: `README.md`)
- Chat Interface → Harness State: sets harness options (evidence: `README.md`)
- Anchor Abstractions → Vector Embeddings
- Anchor Abstractions → Text Chunks
- Coding Loops → Prompt Construction
- Subagents → Model Abstractions
- Chat Interface → Harness Helpers
