# runningwa/thinking-claude architecture

> Architecture diagram of the GitHub repository runningwa/thinking-claude, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/runningwa/thinking-claude
- Repository: https://github.com/runningwa/thinking-claude

## Overview

##### Main Components
- Browser Extension: Represent this as the core interactive element that users install (with separate subcomponents for Chrome, Firefox, and even a legacy version for Chrome_v0).
– For the modern Chrome extension, include elements such as background scripts, content scripts, UI components (instruction-selector, various UI elements, etc.), hooks (e.g., use-content-sync, use-model-instructions), services (e.g., mutation observer), and utilities.
- Thinking Protocol (Model Instructions): Represent this as the data/instructions store (all the versioned markdown files under the model_instructions directory) that drives Claude's deep "thought process" instructions.

##### Break Down the Extension’s Internal Architecture
- Client-Side Components:
– Content Scripts: Include how these scripts are injected into pages—specifically into https://claude.ai—to capture and process content so that Claude’s thought process becomes organized.
– Background Scripts & Managers: Represent background scripts (such as the background/index.ts) and managers (extension-manager, feature-manager) that handle internal logic and interactions between the content scripts and the extension’s services.
- External Dependencies / Build / Configuration:
– Mention supporting configuration files (webpack config files for bundling, tailwind configuration, ESLint, Prettier, etc.) which are indirectly part of the architecture.
– Note GitHub workflows (.github) and Husky configuration to indicate continuous integration and code quality practices.

##### Relationships and Data Flow
- That UI components (built using React/TypeScript as seen by the .tsx files) interact with the background or content scripts.

##### Architectural Patterns & Design Principles
- Separation of concerns:
– User Interface components (for rendering and user interaction) are maintained separately from logic layers (like managers, hooks, or services).
– The browser extension follows a modular structure where background processing, content injection, and UI rendering are decoupled.
- That modern web development practices are used (as indicated by the use of TypeScript, React-like file naming conventions with .tsx, utility libraries, and module-based architecture).
- For extensibility, reference that different browser versions (Chrome, Firefox, and legacy Chrome_v0) are isolated into different folders, implying versioning and support for multiple platforms.

##### Final Assembly

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Browser Extension (Modern Chrome)"
        subgraph "UI Components"
            A["Chrome Extension UI - Instruction Selector"]:::ui
            B["Chrome Extension UI - Additional Elements"]:::ui
        end
        subgraph "Background Processing"
            C["Chrome Extension Background Scripts"]:::background
        end
        subgraph "Content Scripts"
            D["Chrome Extension Content Script - Base"]:::content
            E["Content Script Feature - Instruction Selector"]:::content
            F["Content Script Feature - Thinking Block"]:::content
        end
        subgraph "Managers & Coordination"
            G["Content Managers"]:::managers
        end
        subgraph "Hooks & Services"
            H["State & Instruction Sync Hooks"]:::hooks
            I["Mutation Observer Service"]:::services
        end
    end

    subgraph "Thinking Protocol"
        J["Model Instructions Repository"]:::protocol
    end

    K["Claude.ai Page"]:::external

    %% Relationships and Data Flow
    A -->|"triggers"| C
    B -->|"triggers"| C
    C -->|"coordinatesWith"| G
    D -->|"injectedInto"| K
    E -->|"updates"| G
    F -->|"updates"| G
    G -->|"syncsStateWith"| H
    H -->|"utilizes"| I
    C -->|"readsInstructionsFrom"| J
    D -->|"fetchesInstructionsFrom"| J
    H -->|"updatesUI"| A
    A -->|"affects"| D

    click A "https://github.com/runningwa/thinking-claude/tree/main/extensions/chrome/src/components/instruction-selector"
    click B "https://github.com/runningwa/thinking-claude/tree/main/extensions/chrome/src/components/ui"
    click C "https://github.com/runningwa/thinking-claude/blob/main/extensions/chrome/src/background/index.ts"
    click D "https://github.com/runningwa/thinking-claude/blob/main/extensions/chrome/src/content/index.ts"
    click E "https://github.com/runningwa/thinking-claude/tree/main/extensions/chrome/src/content/v3/features/instruction-selector"
    click F "https://github.com/runningwa/thinking-claude/tree/main/extensions/chrome/src/content/v3/features/thinking-block"
    click G "https://github.com/runningwa/thinking-claude/tree/main/extensions/chrome/src/content/v3/managers"
    click H "https://github.com/runningwa/thinking-claude/tree/main/extensions/chrome/src/hooks"
    click I "https://github.com/runningwa/thinking-claude/blob/main/extensions/chrome/src/services/mutation-observer.ts"
    click J "https://github.com/runningwa/thinking-claude/tree/main/model_instructions"

    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef background fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef content fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef managers fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef hooks fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef services fill:#ffeeba,stroke:#856404,stroke-width:2px;
    classDef protocol fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef external fill:#f5f5f5,stroke:#6c757d,stroke-dasharray:5, 5,stroke-width:2px;
```
