# pannu2009/ai-unkown architecture

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

- Interactive diagram: https://gitdiagram.com/pannu2009/ai-unkown
- Repository: https://github.com/pannu2009/ai-unkown

## Overview

NeuroBrain is a from-scratch character-level transformer with local chat and a browser-based inference option. Its principal workflow trains on text, saves model artifacts, and uses them to generate replies. The repository also contains a distinct self-directed agent subsystem for mood, learning, tool use, and personal records. Relationships below are limited to README statements and shown source references/calls; some agent scripts and browser wiring were not fully sampled.

Main entry points: [`agent/mood.py`](https://github.com/pannu2009/ai-unkown/blob/main/agent/mood.py) (Mood and feelings), [`model`](https://github.com/pannu2009/ai-unkown/tree/main/model) (Model artifacts), [`data`](https://github.com/pannu2009/ai-unkown/tree/main/data) (Training text), [`train.py`](https://github.com/pannu2009/ai-unkown/blob/main/train.py) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Model training and chat"]
  node_corpus["Training text"]
  node_trainer["Model training<br/>[train.py]"]
  node_trainer2["Mixed-corpus training<br/>[train_v2.py]"]
  node_weights[("Model artifacts")]
  node_localchat["Local chat<br/>[chat.py]"]
end

subgraph group_browser["Browser chat"]
  node_browserui["Browser chat UI<br/>[index.html]"]
  node_inference["Browser inference<br/>[brain.js]"]
  node_worker["Web worker<br/>[worker.js]"]
  node_kv[("Weights KV")]
end

subgraph group_agent["Agent behavior"]
  node_mood["Mood and feelings<br/>[mood.py]"]
  node_autotrain["Learning cycle<br/>[autotrain.py]"]
  node_harness["Tool guard and execution<br/>[harness.py]"]
  node_learn["Learning support<br/>[learn.py]"]
  node_devwall["Development wall<br/>[devwall.py]"]
  node_logrotate["Log rotation<br/>[logrotate.py]"]
end

subgraph group_records["Agent records"]
  node_briefing["Morning briefing<br/>[briefing.py]"]
  node_dayreport["Daily report<br/>[dayreport.py]"]
  node_messaging["User messaging<br/>[message_arzh.py]"]
  node_vault["Agent vault<br/>[vault.py]"]
end

node_user(("User"))

node_corpus -->|"trains on"| node_trainer
node_trainer -->|"saves checkpoints"| node_weights
node_corpus -->|"trains on"| node_trainer2
node_trainer2 -->|"saves checkpoints"| node_weights
node_user -->|"sends prompt"| node_localchat
node_localchat -->|"loads checkpoint"| node_weights
node_user -.->|"sends prompt"| node_browserui
node_browserui -->|"requests reply"| node_inference
node_inference -->|"fetches model data"| node_worker
node_worker -->|"reads model data"| node_kv
node_autotrain -->|"reads mood"| node_mood
node_briefing -->|"reads mood"| node_mood
node_dayreport -->|"reads feelings"| node_mood
node_messaging -->|"checks mood"| node_mood
node_harness -.->|"enforces rules"| node_user

click node_corpus "https://github.com/pannu2009/ai-unkown/tree/main/data"
click node_trainer "https://github.com/pannu2009/ai-unkown/blob/main/train.py"
click node_trainer2 "https://github.com/pannu2009/ai-unkown/blob/main/train_v2.py"
click node_weights "https://github.com/pannu2009/ai-unkown/tree/main/model"
click node_localchat "https://github.com/pannu2009/ai-unkown/blob/main/chat.py"
click node_browserui "https://github.com/pannu2009/ai-unkown/blob/main/web/index.html"
click node_inference "https://github.com/pannu2009/ai-unkown/blob/main/web/brain.js"
click node_worker "https://github.com/pannu2009/ai-unkown/blob/main/worker/worker.js"
click node_mood "https://github.com/pannu2009/ai-unkown/blob/main/agent/mood.py"
click node_autotrain "https://github.com/pannu2009/ai-unkown/blob/main/agent/autotrain.py"
click node_harness "https://github.com/pannu2009/ai-unkown/blob/main/agent/harness.py"
click node_learn "https://github.com/pannu2009/ai-unkown/blob/main/agent/learn.py"
click node_devwall "https://github.com/pannu2009/ai-unkown/blob/main/agent/devwall.py"
click node_logrotate "https://github.com/pannu2009/ai-unkown/blob/main/agent/logrotate.py"
click node_briefing "https://github.com/pannu2009/ai-unkown/blob/main/agent/briefing.py"
click node_dayreport "https://github.com/pannu2009/ai-unkown/blob/main/agent/dayreport.py"
click node_messaging "https://github.com/pannu2009/ai-unkown/blob/main/agent/message_arzh.py"
click node_vault "https://github.com/pannu2009/ai-unkown/blob/main/agent/vault.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_corpus,node_trainer,node_trainer2,node_weights,node_localchat,node_user toneBlue
class node_browserui,node_inference,node_worker,node_kv toneAmber
class node_mood,node_autotrain,node_harness,node_learn,node_devwall,node_logrotate toneMint
class node_briefing,node_dayreport,node_messaging,node_vault toneRose
```

## Components

### Model training and chat

- [Training text](https://github.com/pannu2009/ai-unkown/tree/main/data): `data`
- [Model training](https://github.com/pannu2009/ai-unkown/blob/main/train.py): `train.py`
- [Mixed-corpus training](https://github.com/pannu2009/ai-unkown/blob/main/train_v2.py): `train_v2.py`
- [Model artifacts](https://github.com/pannu2009/ai-unkown/tree/main/model): `model`
- [Local chat](https://github.com/pannu2009/ai-unkown/blob/main/chat.py): `chat.py`

### Browser chat

- [Browser chat UI](https://github.com/pannu2009/ai-unkown/blob/main/web/index.html): `web/index.html`
- [Browser inference](https://github.com/pannu2009/ai-unkown/blob/main/web/brain.js): `web/brain.js`
- [Web worker](https://github.com/pannu2009/ai-unkown/blob/main/worker/worker.js): `worker/worker.js`
- **Weights KV**

### Agent behavior

- [Mood and feelings](https://github.com/pannu2009/ai-unkown/blob/main/agent/mood.py): `agent/mood.py`
- [Learning cycle](https://github.com/pannu2009/ai-unkown/blob/main/agent/autotrain.py): `agent/autotrain.py`
- [Tool guard and execution](https://github.com/pannu2009/ai-unkown/blob/main/agent/harness.py): `agent/harness.py`
- [Learning support](https://github.com/pannu2009/ai-unkown/blob/main/agent/learn.py): `agent/learn.py`
- [Development wall](https://github.com/pannu2009/ai-unkown/blob/main/agent/devwall.py): `agent/devwall.py`
- [Log rotation](https://github.com/pannu2009/ai-unkown/blob/main/agent/logrotate.py): `agent/logrotate.py`

### Agent records

- [Morning briefing](https://github.com/pannu2009/ai-unkown/blob/main/agent/briefing.py): `agent/briefing.py`
- [Daily report](https://github.com/pannu2009/ai-unkown/blob/main/agent/dayreport.py): `agent/dayreport.py`
- [User messaging](https://github.com/pannu2009/ai-unkown/blob/main/agent/message_arzh.py): `agent/message_arzh.py`
- [Agent vault](https://github.com/pannu2009/ai-unkown/blob/main/agent/vault.py): `agent/vault.py`

### Other components

- **User**

## Connections

- Training text → Model training: trains on (evidence: `README.md`)
- Model training → Model artifacts: saves checkpoints (evidence: `README.md`)
- Training text → Mixed-corpus training: trains on (evidence: `train_v2.py`)
- Mixed-corpus training → Model artifacts: saves checkpoints (evidence: `train_v2.py`)
- User → Local chat: sends prompt (evidence: `README.md`)
- Local chat → Model artifacts: loads checkpoint (evidence: `chat.py`)
- User → Browser chat UI: sends prompt
- Browser chat UI → Browser inference: requests reply
- Browser inference → Web worker: fetches model data (evidence: `web/brain.js`)
- Web worker → Weights KV: reads model data (evidence: `worker/worker.js`)
- Learning cycle → Mood and feelings: reads mood (evidence: `agent/autotrain.py`)
- Morning briefing → Mood and feelings: reads mood (evidence: `agent/briefing.py`)
- Daily report → Mood and feelings: reads feelings (evidence: `agent/dayreport.py`)
- User messaging → Mood and feelings: checks mood (evidence: `agent/message_arzh.py`)
- Tool guard and execution → User: enforces rules
