# ahmadfauzi34/oopbot architecture

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

- Interactive diagram: https://gitdiagram.com/ahmadfauzi34/oopbot
- Repository: https://github.com/ahmadfauzi34/oopbot

## Overview

OOPBoT combines an Android workspace/chat app, a Termux host bridge, and a Rust agent runtime; the README’s primary workflow is composing a chat in Android, running a per-session JSONL RPC process in Termux, and streaming agent events and tool results back to the UI. The app also supports local on-device inference, remote hosts, files, Git, terminals, session archives, and background/subagent and web-access extensions. Edges are limited to relationships shown in excerpts, the SOURCE INDEX, or README; several unsampled feature links are therefore omitted.

Main entry points: [`android/host/src/main.ts`](https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/main.ts) (Host dispatcher), [`src/main.rs`](https://github.com/ahmadfauzi34/oopbot/blob/main/src/main.rs) (CLI entry), [`src/agent.rs`](https://github.com/ahmadfauzi34/oopbot/blob/main/src/agent.rs) (Agent loop), [`android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/InferenceEngine.kt`](https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/InferenceEngine.kt) (Engine contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Android app"]
  node_activity["App shell<br/>[MainActivity.kt]"]
  node_chat["Chat controller<br/>[ChatController.kt]"]
  node_sessions["Session repository"]
  node_agentprocess["Agent process<br/>[AgentProcess.kt]"]
  node_hostclient["Host client<br/>[HostClient.kt]"]
end

subgraph group_bridge["Termux host bridge"]
  node_hostmain["Host dispatcher<br/>[main.ts]"]
  node_framing["JSONL framing<br/>[framing.ts]"]
  node_rpcmode["RPC mode<br/>[rpc.ts]"]
end

subgraph group_agent["Rust agent runtime"]
  node_rustmain["CLI entry<br/>[main.rs]"]
  node_rpc["JSONL RPC<br/>[rpc.rs]"]
  node_agentcore["Agent loop<br/>[agent.rs]"]
  node_tools["Built-in tools<br/>[tools.rs]"]
  node_llm["Provider client<br/>[gemini.rs]"]
  node_models[("Model catalog<br/>[models.rs]")]
  node_ffi["C ABI<br/>[ffi.rs]"]
end

subgraph group_local["Local inference"]
  node_ondevice["Inference service"]
  node_engine["Engine contract<br/>[InferenceEngine.kt]"]
  node_llama["Llama engine<br/>[LlamaEngine.kt]"]
  node_litert["LiteRT engine<br/>[LiteRtEngine.kt]"]
end

subgraph group_extensions["Agent extensions"]
  node_web["Web access<br/>[page-query.ts]"]
  node_background["Background tasks<br/>[tasks.ts]"]
  node_webstore[("Web result store<br/>[storage.ts]")]
end

node_user(("App user"))

node_user -->|"uses"| node_activity
node_activity -->|"opens chat"| node_chat
node_chat -->|"sends prompts"| node_agentprocess
node_agentprocess -->|"starts RPC"| node_rpcmode
node_rpcmode -->|"spawns binary"| node_rustmain
node_hostclient -->|"sends requests"| node_hostmain
node_hostmain -->|"dispatches"| node_rpcmode
node_hostmain -->|"parses messages"| node_framing
node_rustmain -->|"runs RPC mode"| node_rpc
node_rpc -->|"runs agent"| node_agentcore
node_agentcore -->|"executes tools"| node_tools
node_agentcore -->|"requests completions"| node_llm
node_llm -->|"scans models"| node_models
node_rustmain -->|"exports library"| node_ffi
node_user -.->|"manages chats"| node_sessions
node_ondevice -->|"selects engine"| node_engine
node_engine -->|"implemented by"| node_llama
node_engine -->|"implemented by"| node_litert
node_web -.->|"stores results"| node_webstore
node_background -.->|"runs tasks"| node_user

click node_activity "https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/MainActivity.kt"
click node_chat "https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/ui/chat/ChatController.kt"
click node_sessions "https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/data/SessionRepository.kt"
click node_agentprocess "https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/agent/AgentProcess.kt"
click node_hostclient "https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/host/HostClient.kt"
click node_hostmain "https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/main.ts"
click node_framing "https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/framing.ts"
click node_rpcmode "https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/modes/rpc.ts"
click node_rustmain "https://github.com/ahmadfauzi34/oopbot/blob/main/src/main.rs"
click node_rpc "https://github.com/ahmadfauzi34/oopbot/blob/main/src/rpc.rs"
click node_agentcore "https://github.com/ahmadfauzi34/oopbot/blob/main/src/agent.rs"
click node_tools "https://github.com/ahmadfauzi34/oopbot/blob/main/src/tools.rs"
click node_llm "https://github.com/ahmadfauzi34/oopbot/blob/main/src/gemini.rs"
click node_models "https://github.com/ahmadfauzi34/oopbot/blob/main/src/models.rs"
click node_ffi "https://github.com/ahmadfauzi34/oopbot/blob/main/src/ffi.rs"
click node_ondevice "https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/InferenceService.kt"
click node_engine "https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/InferenceEngine.kt"
click node_llama "https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/llama/LlamaEngine.kt"
click node_litert "https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/litert/LiteRtEngine.kt"
click node_web "https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/pi-extensions/pipkin-web-access/page-query.ts"
click node_background "https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/pi-extensions/pipkin-background/tasks.ts"
click node_webstore "https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/pi-extensions/pipkin-web-access/storage.ts"

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_activity,node_chat,node_sessions,node_agentprocess,node_hostclient,node_user toneBlue
class node_hostmain,node_framing,node_rpcmode toneAmber
class node_rustmain,node_rpc,node_agentcore,node_tools,node_llm,node_models,node_ffi toneMint
class node_ondevice,node_engine,node_llama,node_litert toneRose
class node_web,node_background,node_webstore toneIndigo
```

## Components

### Android app

- [App shell](https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/MainActivity.kt): `android/app/src/main/kotlin/io/jeph/pipkin/MainActivity.kt`
- [Chat controller](https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/ui/chat/ChatController.kt): `android/app/src/main/kotlin/io/jeph/pipkin/ui/chat/ChatController.kt`
- [Session repository](https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/data/SessionRepository.kt): `android/app/src/main/kotlin/io/jeph/pipkin/data/SessionRepository.kt`
- [Agent process](https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/agent/AgentProcess.kt): `android/app/src/main/kotlin/io/jeph/pipkin/agent/AgentProcess.kt`
- [Host client](https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/host/HostClient.kt): `android/app/src/main/kotlin/io/jeph/pipkin/host/HostClient.kt`

### Termux host bridge

- [Host dispatcher](https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/main.ts): `android/host/src/main.ts`
- [JSONL framing](https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/framing.ts): `android/host/src/framing.ts`
- [RPC mode](https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/modes/rpc.ts): `android/host/src/modes/rpc.ts`

### Rust agent runtime

- [CLI entry](https://github.com/ahmadfauzi34/oopbot/blob/main/src/main.rs): `src/main.rs`
- [JSONL RPC](https://github.com/ahmadfauzi34/oopbot/blob/main/src/rpc.rs): `src/rpc.rs`
- [Agent loop](https://github.com/ahmadfauzi34/oopbot/blob/main/src/agent.rs): `src/agent.rs`
- [Built-in tools](https://github.com/ahmadfauzi34/oopbot/blob/main/src/tools.rs): `src/tools.rs`
- [Provider client](https://github.com/ahmadfauzi34/oopbot/blob/main/src/gemini.rs): `src/gemini.rs`
- [Model catalog](https://github.com/ahmadfauzi34/oopbot/blob/main/src/models.rs): `src/models.rs`
- [C ABI](https://github.com/ahmadfauzi34/oopbot/blob/main/src/ffi.rs): `src/ffi.rs`

### Local inference

- [Inference service](https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/InferenceService.kt): `android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/InferenceService.kt`
- [Engine contract](https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/InferenceEngine.kt): `android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/InferenceEngine.kt`
- [Llama engine](https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/llama/LlamaEngine.kt): `android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/llama/LlamaEngine.kt`
- [LiteRT engine](https://github.com/ahmadfauzi34/oopbot/blob/main/android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/litert/LiteRtEngine.kt): `android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/litert/LiteRtEngine.kt`

### Agent extensions

- [Web access](https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/pi-extensions/pipkin-web-access/page-query.ts): `android/host/src/pi-extensions/pipkin-web-access/page-query.ts`
- [Background tasks](https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/pi-extensions/pipkin-background/tasks.ts): `android/host/src/pi-extensions/pipkin-background/tasks.ts`
- [Web result store](https://github.com/ahmadfauzi34/oopbot/blob/main/android/host/src/pi-extensions/pipkin-web-access/storage.ts): `android/host/src/pi-extensions/pipkin-web-access/storage.ts`

### Other components

- **App user**

## Connections

- App user → App shell: uses (evidence: `android/app/src/main/kotlin/io/jeph/pipkin/MainActivity.kt`)
- App shell → Chat controller: opens chat (evidence: `android/app/src/main/kotlin/io/jeph/pipkin/MainActivity.kt`)
- Chat controller → Agent process: sends prompts (evidence: `android/app/src/main/kotlin/io/jeph/pipkin/ui/chat/ChatController.kt`)
- Agent process → RPC mode: starts RPC (evidence: `README.md`)
- RPC mode → CLI entry: spawns binary (evidence: `README.md`)
- Host client → Host dispatcher: sends requests (evidence: `android/app/src/main/kotlin/io/jeph/pipkin/host/HostClient.kt`)
- Host dispatcher → RPC mode: dispatches (evidence: `android/host/src/main.ts`)
- Host dispatcher → JSONL framing: parses messages (evidence: `android/host/src/main.ts`)
- CLI entry → JSONL RPC: runs RPC mode (evidence: `README.md`)
- JSONL RPC → Agent loop: runs agent (evidence: `README.md`)
- Agent loop → Built-in tools: executes tools (evidence: `README.md`)
- Agent loop → Provider client: requests completions (evidence: `README.md`)
- Provider client → Model catalog: scans models (evidence: `README.md`)
- CLI entry → C ABI: exports library (evidence: `README.md`)
- App user → Session repository: manages chats
- Inference service → Engine contract: selects engine (evidence: `android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/InferenceService.kt`)
- Engine contract → Llama engine: implemented by (evidence: `android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/llama/LlamaEngine.kt`)
- Engine contract → LiteRT engine: implemented by (evidence: `android/app/src/main/kotlin/io/jeph/pipkin/localmodel/engine/litert/LiteRtEngine.kt`)
- Web access → Web result store: stores results
- Background tasks → App user: runs tasks
