Query System Architecture
Overview
The Query System is the heart of Claude Code - it manages the conversation with Claude's API, handles tool execution, and orchestrates the entire interaction flow.
┌─────────────────────────────────────────────────────────────────────────────┐
│ QUERY SYSTEM │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Query │───►│ Query │───►│ Claude │ │
│ │ Engine │ │ (query.ts) │ │ API │ │
│ │ (class) │◄───│ │◄───│ │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │
│ │ ┌──────▼──────┐ │
│ │ │ Streaming │ │
│ │ │ Executor │ │
│ │ └──────┬──────┘ │
│ │ │ │
│ │ ┌──────▼──────┐ │
│ └───────────►│ Tool │ │
│ │ Execution │ │
│ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘