# orfanel-0205/code_hero architecture

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

- Interactive diagram: https://gitdiagram.com/orfanel-0205/code_hero
- Repository: https://github.com/orfanel-0205/code_hero

## Overview

CODE HERO/Kiritan is a beginner-focused JavaScript mentor, delivered through a desktop floating-character app or terminal, with a VS Code extension connection. The main workflow accepts a learner question or code context, routes it through mentoring and code analysis, then provides teaching, review, or code-with-me feedback; proposed edits are checked before acceptance. Separate product branches cover curriculum, project planning, Git coaching, live collaboration, voice, privacy/audit, and sandboxed execution. The README is empty, so capabilities and links here rely on the supplied tree and source excerpts/index; unsampled modules are represented conservatively.

Main entry points: [`mentor/core.js`](https://github.com/orfanel-0205/code_hero/blob/main/mentor/core.js) (Mentor core), [`mentor/app/main.js`](https://github.com/orfanel-0205/code_hero/blob/main/mentor/app/main.js) (Desktop app), [`mentor/prompts.js`](https://github.com/orfanel-0205/code_hero/blob/main/mentor/prompts.js) (Prompt design), [`mentor/cowork.js`](https://github.com/orfanel-0205/code_hero/blob/main/mentor/cowork.js) (Code with me)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["User interfaces"]
  node_desktop["Desktop app<br/>[main.js]"]
  node_renderer["App interface<br/>[renderer.js]"]
  node_preload["App bridge<br/>[preload.cjs]"]
  node_terminal["Terminal app<br/>[index.js]"]
  node_vscode["VS Code extension<br/>[extension.js]"]
  node_extlogic["Editor context<br/>[lib.js]"]
  node_bridge["Editor bridge<br/>[bridge.js]"]
end

subgraph group_mentor["Mentoring workflow"]
  node_core["Mentor core<br/>[core.js]"]
  node_ai["AI models<br/>[ai.js]"]
  node_cloud["Cloud fallback<br/>[cloud.js]"]
  node_prompts["Prompt design<br/>[prompts.js]"]
end

subgraph group_learn["Learning and coding"]
  node_analysis["Code analysis<br/>[analysis.js]"]
  node_teaching["Teaching and debugging<br/>[teaching.js]"]
  node_curriculum["Concept curriculum<br/>[concepts.js]"]
  node_exercises["Exercises<br/>[exercises.js]"]
  node_cowork["Code with me<br/>[cowork.js]"]
  node_planner["Project planner<br/>[planner.js]"]
  node_gitcoach["Git coaching<br/>[gitcoach.js]"]
  node_live["Live collaboration<br/>[live.js]"]
end

subgraph group_trust["Safety and privacy"]
  node_verify["Code verification<br/>[verify.js]"]
  node_sandbox["Execution sandbox<br/>[sandbox.js]"]
  node_firewall["Network firewall<br/>[firewall.js]"]
  node_privacy["Secret protection<br/>[privacy.js]"]
  node_audit[("Audit log<br/>[audit.js]")]
  node_db[("Local state<br/>[db.js]")]
end

subgraph group_voice["Voice interaction"]
  node_voiceinput["Voice input<br/>[voice-input.js]"]
  node_commands["Voice commands<br/>[voice-commands.js]"]
  node_voice["Voice output<br/>[voice.js]"]
  node_voicevox["Voice engine<br/>[voicevox.js]"]
  node_speech["Speech support<br/>[speech.js]"]
end

node_learner(("Learner"))

node_learner -->|"asks or edits"| node_desktop
node_learner -->|"asks or edits"| node_terminal
node_learner -.->|"shares editor context"| node_vscode
node_desktop -.->|"displays events"| node_renderer
node_renderer -.->|"sends requests"| node_preload
node_desktop -->|"routes mentoring"| node_core
node_terminal -->|"starts mentoring"| node_core
node_desktop -->|"starts editor link"| node_bridge
node_terminal -->|"starts editor link"| node_bridge
node_vscode -->|"filters context"| node_extlogic
node_vscode -.->|"connects editor"| node_bridge
node_core -->|"requests responses"| node_ai
node_core -->|"uses fallback"| node_cloud
node_core -->|"builds requests"| node_prompts
node_core -->|"analyzes code"| node_analysis
node_core -.->|"coordinates teaching"| node_teaching
node_core -->|"runs exercise tests"| node_exercises
node_core -->|"checks suggestions"| node_verify
node_teaching -->|"looks up concepts"| node_curriculum
node_teaching -->|"finds exercises"| node_exercises
node_cowork -->|"builds code task"| node_prompts
node_cowork -->|"checks proposed code"| node_verify
node_cowork -->|"runs tests"| node_exercises
node_planner -->|"builds plan request"| node_prompts
node_gitcoach -->|"builds commit request"| node_prompts
node_core -->|"runs code safely"| node_sandbox
node_sandbox -->|"records execution"| node_audit
node_firewall -->|"resolves executable"| node_sandbox
node_core -->|"finds secrets"| node_privacy
node_audit -->|"scrubs records"| node_privacy
node_core -.->|"persists state"| node_db
node_desktop -.->|"captures speech"| node_voiceinput
node_desktop -->|"parses commands"| node_commands
node_core -.->|"speaks responses"| node_voice
node_voice -->|"uses voice engine"| node_voicevox
node_voicevox -->|"uses speech support"| node_speech

click node_desktop "https://github.com/orfanel-0205/code_hero/blob/main/mentor/app/main.js"
click node_renderer "https://github.com/orfanel-0205/code_hero/blob/main/mentor/app/renderer.js"
click node_preload "https://github.com/orfanel-0205/code_hero/blob/main/mentor/app/preload.cjs"
click node_terminal "https://github.com/orfanel-0205/code_hero/blob/main/mentor/index.js"
click node_vscode "https://github.com/orfanel-0205/code_hero/blob/main/kiritan-vscode/extension.js"
click node_extlogic "https://github.com/orfanel-0205/code_hero/blob/main/kiritan-vscode/lib.js"
click node_bridge "https://github.com/orfanel-0205/code_hero/blob/main/mentor/bridge.js"
click node_core "https://github.com/orfanel-0205/code_hero/blob/main/mentor/core.js"
click node_ai "https://github.com/orfanel-0205/code_hero/blob/main/mentor/ai.js"
click node_cloud "https://github.com/orfanel-0205/code_hero/blob/main/mentor/cloud.js"
click node_prompts "https://github.com/orfanel-0205/code_hero/blob/main/mentor/prompts.js"
click node_analysis "https://github.com/orfanel-0205/code_hero/blob/main/mentor/analysis.js"
click node_teaching "https://github.com/orfanel-0205/code_hero/blob/main/mentor/teaching.js"
click node_curriculum "https://github.com/orfanel-0205/code_hero/blob/main/mentor/curriculum/concepts.js"
click node_exercises "https://github.com/orfanel-0205/code_hero/blob/main/mentor/exercises.js"
click node_cowork "https://github.com/orfanel-0205/code_hero/blob/main/mentor/cowork.js"
click node_planner "https://github.com/orfanel-0205/code_hero/blob/main/mentor/planner.js"
click node_gitcoach "https://github.com/orfanel-0205/code_hero/blob/main/mentor/gitcoach.js"
click node_live "https://github.com/orfanel-0205/code_hero/blob/main/mentor/live.js"
click node_verify "https://github.com/orfanel-0205/code_hero/blob/main/mentor/verify.js"
click node_sandbox "https://github.com/orfanel-0205/code_hero/blob/main/mentor/sandbox.js"
click node_firewall "https://github.com/orfanel-0205/code_hero/blob/main/mentor/sandbox/firewall.js"
click node_privacy "https://github.com/orfanel-0205/code_hero/blob/main/mentor/privacy.js"
click node_audit "https://github.com/orfanel-0205/code_hero/blob/main/mentor/audit.js"
click node_db "https://github.com/orfanel-0205/code_hero/blob/main/mentor/db.js"
click node_voiceinput "https://github.com/orfanel-0205/code_hero/blob/main/mentor/voice-input.js"
click node_commands "https://github.com/orfanel-0205/code_hero/blob/main/mentor/voice-commands.js"
click node_voice "https://github.com/orfanel-0205/code_hero/blob/main/mentor/voice.js"
click node_voicevox "https://github.com/orfanel-0205/code_hero/blob/main/mentor/voicevox.js"
click node_speech "https://github.com/orfanel-0205/code_hero/blob/main/mentor/speech.js"

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_desktop,node_renderer,node_preload,node_terminal,node_vscode,node_extlogic,node_bridge toneBlue
class node_core,node_ai,node_cloud,node_prompts toneAmber
class node_analysis,node_teaching,node_curriculum,node_exercises,node_cowork,node_planner,node_gitcoach,node_live toneMint
class node_verify,node_sandbox,node_firewall,node_privacy,node_audit,node_db toneRose
class node_voiceinput,node_commands,node_voice,node_voicevox,node_speech,node_learner toneIndigo
```

## Components

### User interfaces

- [Desktop app](https://github.com/orfanel-0205/code_hero/blob/main/mentor/app/main.js): `mentor/app/main.js`
- [App interface](https://github.com/orfanel-0205/code_hero/blob/main/mentor/app/renderer.js): `mentor/app/renderer.js`
- [App bridge](https://github.com/orfanel-0205/code_hero/blob/main/mentor/app/preload.cjs): `mentor/app/preload.cjs`
- [Terminal app](https://github.com/orfanel-0205/code_hero/blob/main/mentor/index.js): `mentor/index.js`
- [VS Code extension](https://github.com/orfanel-0205/code_hero/blob/main/kiritan-vscode/extension.js): `kiritan-vscode/extension.js`
- [Editor context](https://github.com/orfanel-0205/code_hero/blob/main/kiritan-vscode/lib.js): `kiritan-vscode/lib.js`
- [Editor bridge](https://github.com/orfanel-0205/code_hero/blob/main/mentor/bridge.js): `mentor/bridge.js`

### Mentoring workflow

- [Mentor core](https://github.com/orfanel-0205/code_hero/blob/main/mentor/core.js): `mentor/core.js`
- [AI models](https://github.com/orfanel-0205/code_hero/blob/main/mentor/ai.js): `mentor/ai.js`
- [Cloud fallback](https://github.com/orfanel-0205/code_hero/blob/main/mentor/cloud.js): `mentor/cloud.js`
- [Prompt design](https://github.com/orfanel-0205/code_hero/blob/main/mentor/prompts.js): `mentor/prompts.js`

### Learning and coding

- [Code analysis](https://github.com/orfanel-0205/code_hero/blob/main/mentor/analysis.js): `mentor/analysis.js`
- [Teaching and debugging](https://github.com/orfanel-0205/code_hero/blob/main/mentor/teaching.js): `mentor/teaching.js`
- [Concept curriculum](https://github.com/orfanel-0205/code_hero/blob/main/mentor/curriculum/concepts.js): `mentor/curriculum/concepts.js`
- [Exercises](https://github.com/orfanel-0205/code_hero/blob/main/mentor/exercises.js): `mentor/exercises.js`
- [Code with me](https://github.com/orfanel-0205/code_hero/blob/main/mentor/cowork.js): `mentor/cowork.js`
- [Project planner](https://github.com/orfanel-0205/code_hero/blob/main/mentor/planner.js): `mentor/planner.js`
- [Git coaching](https://github.com/orfanel-0205/code_hero/blob/main/mentor/gitcoach.js): `mentor/gitcoach.js`
- [Live collaboration](https://github.com/orfanel-0205/code_hero/blob/main/mentor/live.js): `mentor/live.js`

### Safety and privacy

- [Code verification](https://github.com/orfanel-0205/code_hero/blob/main/mentor/verify.js): `mentor/verify.js`
- [Execution sandbox](https://github.com/orfanel-0205/code_hero/blob/main/mentor/sandbox.js): `mentor/sandbox.js`
- [Network firewall](https://github.com/orfanel-0205/code_hero/blob/main/mentor/sandbox/firewall.js): `mentor/sandbox/firewall.js`
- [Secret protection](https://github.com/orfanel-0205/code_hero/blob/main/mentor/privacy.js): `mentor/privacy.js`
- [Audit log](https://github.com/orfanel-0205/code_hero/blob/main/mentor/audit.js): `mentor/audit.js`
- [Local state](https://github.com/orfanel-0205/code_hero/blob/main/mentor/db.js): `mentor/db.js`

### Voice interaction

- [Voice input](https://github.com/orfanel-0205/code_hero/blob/main/mentor/voice-input.js): `mentor/voice-input.js`
- [Voice commands](https://github.com/orfanel-0205/code_hero/blob/main/mentor/voice-commands.js): `mentor/voice-commands.js`
- [Voice output](https://github.com/orfanel-0205/code_hero/blob/main/mentor/voice.js): `mentor/voice.js`
- [Voice engine](https://github.com/orfanel-0205/code_hero/blob/main/mentor/voicevox.js): `mentor/voicevox.js`
- [Speech support](https://github.com/orfanel-0205/code_hero/blob/main/mentor/speech.js): `mentor/speech.js`

### Other components

- **Learner**

## Connections

- Learner → Desktop app: asks or edits
- Learner → Terminal app: asks or edits (evidence: `mentor/index.js`)
- Learner → VS Code extension: shares editor context
- Desktop app → App interface: displays events
- App interface → App bridge: sends requests
- Desktop app → Mentor core: routes mentoring (evidence: `mentor/app/main.js`)
- Terminal app → Mentor core: starts mentoring (evidence: `mentor/index.js`)
- Desktop app → Editor bridge: starts editor link (evidence: `mentor/app/main.js`)
- Terminal app → Editor bridge: starts editor link (evidence: `mentor/index.js`)
- VS Code extension → Editor context: filters context (evidence: `kiritan-vscode/extension.js`)
- VS Code extension → Editor bridge: connects editor
- Mentor core → AI models: requests responses (evidence: `mentor/core.js`)
- Mentor core → Cloud fallback: uses fallback (evidence: `mentor/core.js`)
- Mentor core → Prompt design: builds requests (evidence: `mentor/core.js`)
- Mentor core → Code analysis: analyzes code (evidence: `mentor/core.js`)
- Mentor core → Teaching and debugging: coordinates teaching (evidence: `mentor/teaching.js`)
- Mentor core → Exercises: runs exercise tests (evidence: `mentor/core.js`)
- Mentor core → Code verification: checks suggestions (evidence: `mentor/core.js`)
- Teaching and debugging → Concept curriculum: looks up concepts (evidence: `mentor/teaching.js`)
- Teaching and debugging → Exercises: finds exercises (evidence: `mentor/teaching.js`)
- Code with me → Prompt design: builds code task (evidence: `mentor/cowork.js`)
- Code with me → Code verification: checks proposed code (evidence: `mentor/cowork.js`)
- Code with me → Exercises: runs tests (evidence: `mentor/cowork.js`)
- Project planner → Prompt design: builds plan request (evidence: `mentor/planner.js`)
- Git coaching → Prompt design: builds commit request (evidence: `mentor/gitcoach.js`)
- Mentor core → Execution sandbox: runs code safely (evidence: `mentor/core.js`)
- Execution sandbox → Audit log: records execution (evidence: `mentor/sandbox.js`)
- Network firewall → Execution sandbox: resolves executable (evidence: `mentor/sandbox/firewall.js`)
- Mentor core → Secret protection: finds secrets (evidence: `mentor/core.js`)
- Audit log → Secret protection: scrubs records (evidence: `mentor/audit.js`)
- Mentor core → Local state: persists state (evidence: `mentor/core.js`)
- Desktop app → Voice input: captures speech (evidence: `mentor/app/main.js`)
- Desktop app → Voice commands: parses commands (evidence: `mentor/app/main.js`)
- Mentor core → Voice output: speaks responses
- Voice output → Voice engine: uses voice engine (evidence: `mentor/voice.js`)
- Voice engine → Speech support: uses speech support (evidence: `mentor/voicevox.js`)
