# hungson175/sonph-code architecture

> Architecture diagram of the GitHub repository hungson175/sonph-code, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hungson175/sonph-code
- Repository: https://github.com/hungson175/sonph-code

## Overview

##### Project type and purpose
- This is a Python-based, command-line coding assistant (“Coding Agent”) that mimics Claude Code’s functionality.
- It orchestrates an LLM via LangChain and the Anthropic API, exposes a suite of “tools” (file I/O, directory ops, shell commands, task writer, search), and runs in interactive mode.

##### File structure
- Top-level:
- coding_agent.py – entry point & CLI REPL
- pyproject.toml, uv.lock – Python project config
- .env.example – environment variables (API keys)
- Directories:
- data/ – API request samples, parsed outputs (for testing & reference)
- docs/claude-code/ – extracted system prompts & tool specifications
- No separate “frontend” or “backend”: it’s a single-process CLI agent.

##### README for additional insights
- Core flow: CLI → Agent Core (LangChain agent) → tool dispatch or API calls → back to CLI.
- Dependencies: Anthropic API, LangChain, ripgrep (for search), uv for dependency management.

##### Detail without over-splitting
- Tool as its own module block.
- Where environment/config is loaded.
- Both local system integration (filesystem, shell) and remote API calls.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entities
    User((User)):::external
    CLI[/CLI REPL/]:::core
    AgentCore["Agent Core\n(LangChain)"]:::core
    APIClient["API Client\n(Anthropic Wrapper)"]:::core
    Config["Environment & Config\n(pyproject.toml, uv.lock)"]:::config
    DataDocs[(Data & Docs)]:::data
    Anthropic((Anthropic API)):::external

    %% Tool Modules
    subgraph "Tool Modules"
        subgraph FileOps
            Read["Read"]:::tool
            Write["Write"]:::tool
            Edit["Edit"]:::tool
            MultiEdit["MultiEdit"]:::tool
        end
        subgraph DirOps
            LS["LS"]:::tool
            Glob["Glob"]:::tool
            Grep["Grep"]:::tool
        end
        subgraph ShellExec
            Bash["Bash"]:::tool
            BashOutput["BashOutput"]:::tool
            KillBash["KillBash"]:::tool
        end
        subgraph TaskMgr
            TodoWrite["TodoWrite"]:::tool
            Task["Task"]:::tool
        end
        subgraph SearchAnalysis
            WebSearch["WebSearch"]:::tool
            WebFetch["WebFetch"]:::tool
        end
    end

    %% Flows
    User -->|interacts| CLI
    CLI -->|invokes| AgentCore
    AgentCore -->|calls LLM| APIClient
    APIClient -->|sends request| Anthropic
    Anthropic -->|returns response| APIClient
    APIClient -->|delivers result| AgentCore

    AgentCore -->|dispatch| Read
    AgentCore --> DirOps
    AgentCore --> ShellExec
    AgentCore --> TaskMgr
    AgentCore --> SearchAnalysis

    Read -->|result| AgentCore
    LS --> AgentCore
    Bash --> AgentCore
    TodoWrite --> AgentCore
    WebSearch --> AgentCore

    Config -->|loads| AgentCore
    DataDocs -->|provides prompts & specs| AgentCore

    AgentCore -->|outputs| CLI
    CLI -->|displays| User

    %% Click Events
    click CLI "https://github.com/hungson175/sonph-code/blob/main/coding_agent.py"
    click AgentCore "https://github.com/hungson175/sonph-code/blob/main/coding_agent.py"
    click APIClient "https://github.com/hungson175/sonph-code/blob/main/coding_agent.py"
    click Config "https://github.com/hungson175/sonph-code/blob/main/pyproject.toml"
    click Config "https://github.com/hungson175/sonph-code/blob/main/uv.lock"
    click DataDocs "https://github.com/hungson175/sonph-code/tree/main/data/"
    click DataDocs "https://github.com/hungson175/sonph-code/tree/main/docs/claude-code/"
    click Read "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/Read.md"
    click Write "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/Write.md"
    click Edit "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/Edit.md"
    click MultiEdit "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/MultiEdit.md"
    click LS "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/LS.md"
    click Glob "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/Glob.md"
    click Grep "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/Grep.md"
    click Bash "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/Bash.md"
    click BashOutput "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/BashOutput.md"
    click KillBash "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/KillBash.md"
    click TodoWrite "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/TodoWrite.md"
    click Task "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/Task.md"
    click WebSearch "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/WebSearch.md"
    click WebFetch "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/WebFetch.md"
    click DataDocs "https://github.com/hungson175/sonph-code/blob/main/data/api_request_sample.json"
    click DataDocs "https://github.com/hungson175/sonph-code/blob/main/data/parsed_request.json"
    click DataDocs "https://github.com/hungson175/sonph-code/blob/main/data/output.md"
    click DataDocs "https://github.com/hungson175/sonph-code/blob/main/docs/claude-code/SystemPrompt.md"

    %% Styles
    classDef core fill:#D0E6FF,stroke:#1E90FF
    classDef tool fill:#E0FFE0,stroke:#00A000
    classDef external fill:#FFE0B2,stroke:#FF8C00
    classDef data fill:#F0F0F0,stroke:#A8A8A8
    classDef config fill:#F5E1FF,stroke:#AA00FF
```
