# k-ashix/edu-babu architecture

> Architecture diagram of the GitHub repository k-ashix/edu-babu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/k-ashix/edu-babu
- Repository: https://github.com/k-ashix/edu-babu

## Overview

Edu Babu is a local-first AI study companion. Its main workflow takes a student’s question from the chat composer through app-state coordination and prompt construction, routes generation to on-device, paired-runtime, or cloud compute, then streams the answer into the chat UI. Chat history is stored locally. The README also describes model management, PDF export, math and Mermaid rendering, and encrypted storage. Connections for unsampled Dart subsystems follow documented README relationships; the native bridge is shown only where its excerpt identifies the Dart FFI consumer.

Main entry points: [`lib/app/app_state_send_entry_controller.dart`](https://github.com/k-ashix/edu-babu/blob/main/lib/app/app_state_send_entry_controller.dart) (App state), [`lib/services/generation/router`](https://github.com/k-ashix/edu-babu/tree/main/lib/services/generation/router) (Generation routing), [`lib/features/chat/presentation/chat_screen.dart`](https://github.com/k-ashix/edu-babu/blob/main/lib/features/chat/presentation/chat_screen.dart) (Chat UI), [`lib/features/chat/composer/edu_babu_composer.dart`](https://github.com/k-ashix/edu-babu/blob/main/lib/features/chat/composer/edu_babu_composer.dart) (Chat composer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chat["Chat workflow"]
  node_composer["Chat composer"]
  node_appstate["App state"]
  node_chatui["Chat UI<br/>[chat_screen.dart]"]
end

subgraph group_generation["Prompt and generation"]
  node_prompt["Prompt framework"]
  node_router["Generation routing"]
end

subgraph group_compute["Compute backends"]
  node_ffi["Llama FFI"]
  node_native["llama.cpp bridge<br/>[llama_bridge.cpp]"]
  node_paired["Paired runtime"]
  node_cloud["Cloud API"]
  node_model["GGUF model"]
end

subgraph group_storage["Local data"]
  node_database[("Drift database<br/>[app_database.dart]")]
  node_history["Chat repository"]
end

subgraph group_product["Study features"]
  node_offline["Offline models"]
  node_render["Rich response rendering"]
  node_export["PDF export"]
end

node_student(("Student"))
node_actor_pc(("Paired PC"))
node_actor_api(("Cloud provider"))

node_student -->|"asks question"| node_composer
node_composer -->|"sends query"| node_appstate
node_appstate -->|"builds prompt"| node_prompt
node_appstate -->|"routes generation"| node_router
node_router -->|"selects backend"| node_ffi
node_router -->|"selects backend"| node_paired
node_router -->|"selects backend"| node_cloud
node_ffi -->|"calls FFI"| node_native
node_native -->|"loads and infers"| node_model
node_paired -->|"offloads inference"| node_actor_pc
node_cloud -->|"requests inference"| node_actor_api
node_router -->|"streams answer"| node_chatui
node_appstate -->|"persists chat"| node_history
node_history -->|"reads and writes"| node_database
node_appstate -->|"manages models"| node_offline
node_chatui -->|"renders response"| node_render
node_chatui -->|"exports chat"| node_export

click node_composer "https://github.com/k-ashix/edu-babu/blob/main/lib/features/chat/composer/edu_babu_composer.dart"
click node_appstate "https://github.com/k-ashix/edu-babu/blob/main/lib/app/app_state_send_entry_controller.dart"
click node_chatui "https://github.com/k-ashix/edu-babu/blob/main/lib/features/chat/presentation/chat_screen.dart"
click node_prompt "https://github.com/k-ashix/edu-babu/tree/main/lib/features/chat/prompting"
click node_router "https://github.com/k-ashix/edu-babu/tree/main/lib/services/generation/router"
click node_ffi "https://github.com/k-ashix/edu-babu/blob/main/lib/services/inference/llama_ffi_bridge.dart"
click node_native "https://github.com/k-ashix/edu-babu/blob/main/android/app/src/main/cpp/llama_bridge.cpp"
click node_paired "https://github.com/k-ashix/edu-babu/tree/main/lib/features/runtime"
click node_cloud "https://github.com/k-ashix/edu-babu/tree/main/lib/services/generation/transport"
click node_database "https://github.com/k-ashix/edu-babu/blob/main/lib/data/local/db/app_database.dart"
click node_history "https://github.com/k-ashix/edu-babu/blob/main/lib/features/chat/data/drift_chat_repository.dart"
click node_offline "https://github.com/k-ashix/edu-babu/tree/main/lib/features/offline_models"
click node_render "https://github.com/k-ashix/edu-babu/tree/main/lib/features/chat/presentation/rendering"
click node_export "https://github.com/k-ashix/edu-babu/tree/main/lib/features/export"

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_composer,node_appstate,node_chatui toneBlue
class node_prompt,node_router toneAmber
class node_ffi,node_native,node_paired,node_cloud,node_model toneMint
class node_database,node_history toneRose
class node_offline,node_render,node_export,node_student,node_actor_pc,node_actor_api toneIndigo
```

## Components

### Chat workflow

- [Chat composer](https://github.com/k-ashix/edu-babu/blob/main/lib/features/chat/composer/edu_babu_composer.dart): `lib/features/chat/composer/edu_babu_composer.dart`
- [App state](https://github.com/k-ashix/edu-babu/blob/main/lib/app/app_state_send_entry_controller.dart): `lib/app/app_state_send_entry_controller.dart`
- [Chat UI](https://github.com/k-ashix/edu-babu/blob/main/lib/features/chat/presentation/chat_screen.dart): `lib/features/chat/presentation/chat_screen.dart`

### Prompt and generation

- [Prompt framework](https://github.com/k-ashix/edu-babu/tree/main/lib/features/chat/prompting): `lib/features/chat/prompting`
- [Generation routing](https://github.com/k-ashix/edu-babu/tree/main/lib/services/generation/router): `lib/services/generation/router`

### Compute backends

- [Llama FFI](https://github.com/k-ashix/edu-babu/blob/main/lib/services/inference/llama_ffi_bridge.dart): `lib/services/inference/llama_ffi_bridge.dart`
- [llama.cpp bridge](https://github.com/k-ashix/edu-babu/blob/main/android/app/src/main/cpp/llama_bridge.cpp): `android/app/src/main/cpp/llama_bridge.cpp`
- [Paired runtime](https://github.com/k-ashix/edu-babu/tree/main/lib/features/runtime): `lib/features/runtime`
- [Cloud API](https://github.com/k-ashix/edu-babu/tree/main/lib/services/generation/transport): `lib/services/generation/transport`
- **GGUF model**

### Local data

- [Drift database](https://github.com/k-ashix/edu-babu/blob/main/lib/data/local/db/app_database.dart): `lib/data/local/db/app_database.dart`
- [Chat repository](https://github.com/k-ashix/edu-babu/blob/main/lib/features/chat/data/drift_chat_repository.dart): `lib/features/chat/data/drift_chat_repository.dart`

### Study features

- [Offline models](https://github.com/k-ashix/edu-babu/tree/main/lib/features/offline_models): `lib/features/offline_models`
- [Rich response rendering](https://github.com/k-ashix/edu-babu/tree/main/lib/features/chat/presentation/rendering): `lib/features/chat/presentation/rendering`
- [PDF export](https://github.com/k-ashix/edu-babu/tree/main/lib/features/export): `lib/features/export`

### Other components

- **Student**
- **Paired PC**
- **Cloud provider**

## Connections

- Student → Chat composer: asks question (evidence: `README.md`)
- Chat composer → App state: sends query (evidence: `README.md`)
- App state → Prompt framework: builds prompt (evidence: `README.md`)
- App state → Generation routing: routes generation (evidence: `README.md`)
- Generation routing → Llama FFI: selects backend (evidence: `README.md`)
- Generation routing → Paired runtime: selects backend (evidence: `README.md`)
- Generation routing → Cloud API: selects backend (evidence: `README.md`)
- Llama FFI → llama.cpp bridge: calls FFI (evidence: `android/app/src/main/cpp/llama_bridge.cpp`)
- llama.cpp bridge → GGUF model: loads and infers (evidence: `android/app/src/main/cpp/llama_bridge.cpp`)
- Paired runtime → Paired PC: offloads inference (evidence: `README.md`)
- Cloud API → Cloud provider: requests inference (evidence: `README.md`)
- Generation routing → Chat UI: streams answer (evidence: `README.md`)
- App state → Chat repository: persists chat (evidence: `README.md`)
- Chat repository → Drift database: reads and writes (evidence: `README.md`)
- App state → Offline models: manages models (evidence: `README.md`)
- Chat UI → Rich response rendering: renders response (evidence: `README.md`)
- Chat UI → PDF export: exports chat (evidence: `README.md`)
