# answerdotai/claudette architecture

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

- Interactive diagram: https://gitdiagram.com/answerdotai/claudette
- Repository: https://github.com/answerdotai/claudette

## Overview

##### Main Components Identification

a) Core Components:
- Chat Class (core.py)
- AsyncChat Class (asink.py)
- Client Interface
- Tool Loop Handler (toolloop.py)

b) External Integrations:
- Anthropic SDK
- AWS Bedrock Integration
- Google Vertex Integration
- Image Processing Support
- Tool Use API Integration

##### Architectural Patterns

- The wrapper pattern around the Anthropic SDK
- Async/sync dual implementation
- Plugin architecture for different model providers
- Caching system integration

**[Client Applications]**
- ↓
**[Claudette Interface Layer]**

- ↓         ↓         ↓
**[Chat]    [AsyncChat]  [Tools]**
- /
- /
- /
- [Claudette Core Handler]
- ↓
**[Model Provider Abstraction Layer]**

- ↓         ↓         ↓
**[Anthropic] [Bedrock] [Vertex]**

##### Key Relationships to Highlight

a) Data Flow:
- Client request flow
- Message handling pipeline
- Tool execution path
- Caching mechanism

b) Integration Points:
- Model provider connections
- Tool integration interface
- Image processing pipeline

##### Implementation Details

- Message handling system
- Prompt caching mechanism
- Tool use automation
- Image processing pipeline
- Provider-specific adaptors

##### Documentation Elements

Callouts for:
- Configuration requirements
- API key handling
- Environment variables
- Tool definition format

##### Additional Notes

- Relationship between sync and async implementations
- Tool use automation system
- Demonstrate the caching mechanism
- Provider abstraction layer

Remember to include a section showing how the literate programming aspect is implemented, as this is a key distinguishing feature of the project.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Applications"]
        App[Client Code]
    end

    subgraph Interface["Interface Layer"]
        Init["Package Interface"]:::interface
        ModIdx["Module Registry"]:::interface
    end

    subgraph Core["Core Components"]
        Chat["Chat Class"]:::core
        AChat["AsyncChat Class"]:::core
        Tools["Tool Loop Handler"]:::core
    end

    subgraph Handler["Core Handler"]
        CoreImpl["Core Implementation"]:::handler
        ToolImpl["Tool Implementation"]:::handler
        AsyncImpl["Async Implementation"]:::handler
    end

    subgraph Providers["Model Provider Layer"]
        Anthropic["Anthropic SDK"]:::provider
        Bedrock["AWS Bedrock"]:::provider
        Vertex["Google Vertex"]:::provider
    end

    subgraph Documentation["Documentation"]
        ApiDocs["API Documentation"]:::docs
        ModelDocs["Model Provider Docs"]:::docs
    end

    subgraph Config["Configuration"]
        Project["Project Config"]:::config
        CI["CI/CD Pipeline"]:::config
    end

    App --> Init
    Init --> ModIdx
    ModIdx --> |Routes| Chat
    ModIdx --> |Routes| AChat
    ModIdx --> |Routes| Tools
    
    Chat --> CoreImpl
    AChat --> AsyncImpl
    Tools --> ToolImpl
    
    CoreImpl --> Providers
    AsyncImpl --> Providers
    ToolImpl --> Providers
    
    Anthropic --> ApiDocs
    Bedrock --> ApiDocs
    Vertex --> ApiDocs
    
    Providers --> ModelDocs

    %% Styling
    classDef core fill:#2374ab
    classDef interface fill:#ff7f50
    classDef handler fill:#57a773
    classDef provider fill:#484d6d
    classDef docs fill:#f7d794
    classDef config fill:#95a5a6

    %% Click Events
    click Chat "https://github.com/AnswerDotAI/claudette/blob/main/claudette/core.py"
    click AChat "https://github.com/AnswerDotAI/claudette/blob/main/claudette/asink.py"
    click Tools "https://github.com/AnswerDotAI/claudette/blob/main/claudette/toolloop.py"
    click CoreImpl "https://github.com/AnswerDotAI/claudette/blob/main/00_core.ipynb"
    click ToolImpl "https://github.com/AnswerDotAI/claudette/blob/main/01_toolloop.ipynb"
    click AsyncImpl "https://github.com/AnswerDotAI/claudette/blob/main/02_async.ipynb"
    click Init "https://github.com/AnswerDotAI/claudette/blob/main/claudette/__init__.py"
    click ModIdx "https://github.com/AnswerDotAI/claudette/blob/main/claudette/_modidx.py"
    click ApiDocs "https://github.com/AnswerDotAI/claudette/blob/main/apilist.txt"
    click ModelDocs "https://github.com/AnswerDotAI/claudette/blob/main/llms.txt"
    click Project "https://github.com/AnswerDotAI/claudette/blob/main/pyproject.toml"
    click CI "https://github.com/AnswerDotAI/claudette/blob/main/.github/workflows/deploy.yaml"
```
