# priyankshu-07/lokal architecture

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

- Interactive diagram: https://gitdiagram.com/priyankshu-07/lokal
- Repository: https://github.com/priyankshu-07/lokal

## Overview

This is a browser-based Japanese LLM chat app. A user submits messages through the React interface; the app sends the conversation to a Web Worker, which loads the LFM2.5-1.2B-JP model with Transformers.js on WebGPU and streams generated text and status back to the interface. The interface renders chat, loading progress, and generation controls. The excerpts show the main UI-to-worker flow and rendering integrations; model hosting and browser caching are described in the README, while their detailed runtime behavior is not sampled.

Main entry points: [`src/App.jsx`](https://github.com/priyankshu-07/lokal/blob/main/src/App.jsx) (Chat App), [`src/components/Chat.jsx`](https://github.com/priyankshu-07/lokal/blob/main/src/components/Chat.jsx) (Chat View), [`src/worker.js`](https://github.com/priyankshu-07/lokal/blob/main/src/worker.js) (Generation Worker), [`src/main.jsx`](https://github.com/priyankshu-07/lokal/blob/main/src/main.jsx) (React Entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat Interface"]
  node_entry["React Entry<br/>[main.jsx]"]
  node_app["Chat App<br/>[App.jsx]"]
  node_progress["Load Progress<br/>[Progress.jsx]"]
  node_send_icon["Send Icon<br/>[ArrowRightIcon.jsx]"]
  node_stop_icon["Stop Icon<br/>[StopIcon.jsx]"]
end

subgraph group_runtime["Local Generation"]
  node_worker["Generation Worker<br/>[worker.js]"]
  node_transformers["Transformers.js"]
  node_model[("LFM2.5 Model")]
  node_webgpu["Browser WebGPU"]
end

subgraph group_rendering["Message Rendering"]
  node_chat["Chat View<br/>[Chat.jsx]"]
  node_markdown["Markdown Parser"]
  node_sanitizer["HTML Sanitizer"]
  node_mathjax["MathJax"]
  node_bot_icon["Bot Icon<br/>[BotIcon.jsx]"]
  node_user_icon["User Icon<br/>[UserIcon.jsx]"]
end

node_user(("User"))

node_entry -->|"renders"| node_app
node_user -->|"submits prompts"| node_app
node_app -->|"posts commands"| node_worker
node_worker -->|"posts status and output"| node_app
node_app -->|"renders messages"| node_chat
node_app -->|"renders loading progress"| node_progress
node_app -->|"renders"| node_send_icon
node_app -->|"renders"| node_stop_icon
node_worker -->|"loads and generates with"| node_transformers
node_worker -->|"loads model"| node_model
node_worker -->|"checks and targets"| node_webgpu
node_chat -->|"parses responses"| node_markdown
node_chat -->|"sanitizes HTML"| node_sanitizer
node_chat -->|"typesets messages"| node_mathjax
node_chat -->|"renders"| node_bot_icon
node_chat -->|"renders"| node_user_icon

click node_entry "https://github.com/priyankshu-07/lokal/blob/main/src/main.jsx"
click node_app "https://github.com/priyankshu-07/lokal/blob/main/src/App.jsx"
click node_progress "https://github.com/priyankshu-07/lokal/blob/main/src/components/Progress.jsx"
click node_send_icon "https://github.com/priyankshu-07/lokal/blob/main/src/components/icons/ArrowRightIcon.jsx"
click node_stop_icon "https://github.com/priyankshu-07/lokal/blob/main/src/components/icons/StopIcon.jsx"
click node_worker "https://github.com/priyankshu-07/lokal/blob/main/src/worker.js"
click node_chat "https://github.com/priyankshu-07/lokal/blob/main/src/components/Chat.jsx"
click node_bot_icon "https://github.com/priyankshu-07/lokal/blob/main/src/components/icons/BotIcon.jsx"
click node_user_icon "https://github.com/priyankshu-07/lokal/blob/main/src/components/icons/UserIcon.jsx"

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_entry,node_app,node_progress,node_send_icon,node_stop_icon,node_user toneBlue
class node_worker,node_transformers,node_model,node_webgpu toneAmber
class node_chat,node_markdown,node_sanitizer,node_mathjax,node_bot_icon,node_user_icon toneMint
```

## Components

### Chat Interface

- [React Entry](https://github.com/priyankshu-07/lokal/blob/main/src/main.jsx): `src/main.jsx`
- [Chat App](https://github.com/priyankshu-07/lokal/blob/main/src/App.jsx): `src/App.jsx`
- [Load Progress](https://github.com/priyankshu-07/lokal/blob/main/src/components/Progress.jsx): `src/components/Progress.jsx`
- [Send Icon](https://github.com/priyankshu-07/lokal/blob/main/src/components/icons/ArrowRightIcon.jsx): `src/components/icons/ArrowRightIcon.jsx`
- [Stop Icon](https://github.com/priyankshu-07/lokal/blob/main/src/components/icons/StopIcon.jsx): `src/components/icons/StopIcon.jsx`

### Local Generation

- [Generation Worker](https://github.com/priyankshu-07/lokal/blob/main/src/worker.js): `src/worker.js`
- **Transformers.js**
- **LFM2.5 Model**
- **Browser WebGPU**

### Message Rendering

- [Chat View](https://github.com/priyankshu-07/lokal/blob/main/src/components/Chat.jsx): `src/components/Chat.jsx`
- **Markdown Parser**
- **HTML Sanitizer**
- **MathJax**
- [Bot Icon](https://github.com/priyankshu-07/lokal/blob/main/src/components/icons/BotIcon.jsx): `src/components/icons/BotIcon.jsx`
- [User Icon](https://github.com/priyankshu-07/lokal/blob/main/src/components/icons/UserIcon.jsx): `src/components/icons/UserIcon.jsx`

### Other components

- **User**

## Connections

- React Entry → Chat App: renders (evidence: `src/main.jsx`)
- User → Chat App: submits prompts (evidence: `src/App.jsx`)
- Chat App → Generation Worker: posts commands (evidence: `src/App.jsx`)
- Generation Worker → Chat App: posts status and output (evidence: `src/worker.js`)
- Chat App → Chat View: renders messages (evidence: `src/App.jsx`)
- Chat App → Load Progress: renders loading progress (evidence: `src/App.jsx`)
- Chat App → Send Icon: renders (evidence: `src/App.jsx`)
- Chat App → Stop Icon: renders (evidence: `src/App.jsx`)
- Generation Worker → Transformers.js: loads and generates with (evidence: `src/worker.js`)
- Generation Worker → LFM2.5 Model: loads model (evidence: `src/worker.js`)
- Generation Worker → Browser WebGPU: checks and targets (evidence: `src/worker.js`)
- Chat View → Markdown Parser: parses responses (evidence: `src/components/Chat.jsx`)
- Chat View → HTML Sanitizer: sanitizes HTML (evidence: `src/components/Chat.jsx`)
- Chat View → MathJax: typesets messages (evidence: `src/components/Chat.jsx`)
- Chat View → Bot Icon: renders (evidence: `src/components/Chat.jsx`)
- Chat View → User Icon: renders (evidence: `src/components/Chat.jsx`)
