# ramlasha/techtonic-robo architecture

> Architecture diagram of the GitHub repository ramlasha/techtonic-robo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ramlasha/techtonic-robo
- Repository: https://github.com/ramlasha/techtonic-robo

## Overview

Kibi-Kibi is an event-kiosk robot pairing an ESP32-S3 body with a laptop-based Python brain. A visitor triggers the robot; the backend greets them, captures speech using the laptop microphone, transcribes it offline, matches event facts, asks Groq to phrase an answer, synthesizes speech offline, and plays it on the laptop. The backend and ESP32 coordinate over USB serial. The README also documents the robot’s sensors, display, servo, LEDs, and speaker. The sampled backend currently captures and plays audio on the laptop, so those paths are shown as implemented; unsampled firmware behavior is based on README documentation.

Main entry points: [`robot_backend/main.py`](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/main.py) (Session orchestrator), [`robot_backend/config.py`](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/config.py) (Runtime settings), [`KibiKibi.ino`](https://github.com/ramlasha/techtonic-robo/blob/main/KibiKibi.ino) (ESP32 firmware), [`robot_backend/serial_link.py`](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/serial_link.py) (USB serial link)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_robot["Robot body"]
  node_esp32["ESP32 firmware<br/>[KibiKibi.ino]"]
end

subgraph group_control["Interaction control"]
  node_backend["Session orchestrator<br/>[main.py]"]
  node_serial["USB serial link<br/>[serial_link.py]"]
  node_mic["Laptop microphone<br/>[mic.py]"]
end

subgraph group_answer["Answer pipeline"]
  node_stt["Offline transcription<br/>[stt.py]"]
  node_rules["Fact matching<br/>[rulebook.py]"]
  node_facts["Event facts<br/>[rulebook.json]"]
  node_llm["Answer phrasing<br/>[llm.py]"]
  node_tts["Offline speech synthesis<br/>[tts.py]"]
end

subgraph group_settings["Configuration"]
  node_config["Runtime settings<br/>[config.py]"]
end

node_visitor(("Visitor"))
node_groq{{"Groq API"}}
node_speaker["Laptop speaker"]

node_visitor -->|"triggers"| node_esp32
node_esp32 -->|"sends trigger"| node_serial
node_backend -->|"commands and awaits"| node_serial
node_serial -->|"USB protocol"| node_esp32
node_backend -->|"records audio"| node_mic
node_backend -->|"transcribes audio"| node_stt
node_backend -->|"searches facts"| node_rules
node_rules -->|"loads"| node_facts
node_backend -->|"requests answer"| node_llm
node_llm -->|"requests phrasing"| node_groq
node_backend -->|"synthesizes answer"| node_tts
node_backend -->|"plays audio"| node_speaker
node_config -->|"configures"| node_backend
node_config -->|"configures"| node_mic
node_config -->|"configures"| node_stt
node_config -->|"configures"| node_llm
node_config -->|"configures"| node_tts

click node_esp32 "https://github.com/ramlasha/techtonic-robo/blob/main/KibiKibi.ino"
click node_backend "https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/main.py"
click node_serial "https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/serial_link.py"
click node_mic "https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/mic.py"
click node_stt "https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/stt.py"
click node_rules "https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/rulebook.py"
click node_facts "https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/data/rulebook.json"
click node_llm "https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/llm.py"
click node_tts "https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/tts.py"
click node_config "https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/config.py"

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_esp32 toneBlue
class node_backend,node_serial,node_mic toneAmber
class node_stt,node_rules,node_facts,node_llm,node_tts,node_groq toneMint
class node_config toneRose
class node_visitor,node_speaker toneIndigo
```

## Components

### Robot body

- [ESP32 firmware](https://github.com/ramlasha/techtonic-robo/blob/main/KibiKibi.ino): `KibiKibi.ino`

### Interaction control

- [Session orchestrator](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/main.py): `robot_backend/main.py`
- [USB serial link](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/serial_link.py): `robot_backend/serial_link.py`
- [Laptop microphone](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/mic.py): `robot_backend/mic.py`

### Answer pipeline

- [Offline transcription](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/stt.py): `robot_backend/stt.py`
- [Fact matching](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/rulebook.py): `robot_backend/rulebook.py`
- [Event facts](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/data/rulebook.json): `robot_backend/data/rulebook.json`
- [Answer phrasing](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/llm.py): `robot_backend/llm.py`
- [Offline speech synthesis](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/tts.py): `robot_backend/tts.py`

### Configuration

- [Runtime settings](https://github.com/ramlasha/techtonic-robo/blob/main/robot_backend/config.py): `robot_backend/config.py`

### Other components

- **Visitor**
- **Groq API**
- **Laptop speaker**

## Connections

- Visitor → ESP32 firmware: triggers (evidence: `README.md`)
- ESP32 firmware → USB serial link: sends trigger (evidence: `README.md`)
- Session orchestrator → USB serial link: commands and awaits (evidence: `robot_backend/main.py`)
- USB serial link → ESP32 firmware: USB protocol (evidence: `robot_backend/serial_link.py`)
- Session orchestrator → Laptop microphone: records audio (evidence: `robot_backend/main.py`)
- Session orchestrator → Offline transcription: transcribes audio (evidence: `robot_backend/main.py`)
- Session orchestrator → Fact matching: searches facts (evidence: `robot_backend/main.py`)
- Fact matching → Event facts: loads (evidence: `README.md`)
- Session orchestrator → Answer phrasing: requests answer (evidence: `robot_backend/main.py`)
- Answer phrasing → Groq API: requests phrasing (evidence: `robot_backend/llm.py`)
- Session orchestrator → Offline speech synthesis: synthesizes answer (evidence: `robot_backend/main.py`)
- Session orchestrator → Laptop speaker: plays audio (evidence: `robot_backend/main.py`)
- Runtime settings → Session orchestrator: configures (evidence: `robot_backend/main.py`)
- Runtime settings → Laptop microphone: configures (evidence: `robot_backend/mic.py`)
- Runtime settings → Offline transcription: configures (evidence: `robot_backend/stt.py`)
- Runtime settings → Answer phrasing: configures (evidence: `robot_backend/llm.py`)
- Runtime settings → Offline speech synthesis: configures (evidence: `robot_backend/tts.py`)
