# rvbyy/sensai architecture

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

- Interactive diagram: https://gitdiagram.com/rvbyy/sensai
- Repository: https://github.com/rvbyy/sensai

## Overview

SensAI is a local Ollama assistant with two visible interaction paths: the main persisted chat framework and a smaller Alibi chatbot. In the framework path, the main entry point manages profiles and conversation context, streams chat through the API client, and supports long-term memory retrieval. ORM models represent messages, generation settings, tools, responses, profiles, and memory. The README documents only the product’s local-assistant purpose; several framework capabilities are evident in sampled source, but the web interface and some model behavior were not inspected.

Main entry points: [`src/galerelm/models/chat.py`](https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/chat.py) (Chat generation), [`src/main.py`](https://github.com/rvbyy/sensai/blob/main/src/main.py) (Framework entry), [`src/model/basic_chat_bot.py`](https://github.com/rvbyy/sensai/blob/main/src/model/basic_chat_bot.py) (Basic chatbot), [`src/galerelm/models/context.py`](https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/context.py) (Short-term context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interaction"]
  node_main["Framework entry<br/>[main.py]"]
  node_webapp["Web app setup<br/>[init_app.py]"]
end

subgraph group_framework["Chat framework"]
  node_chat["Chat generation<br/>[chat.py]"]
  node_api["HTTP API client<br/>[client.py]"]
  node_options["Generation options<br/>[options.py]"]
  node_tooldefs["Tool definitions<br/>[tools.py]"]
  node_response["Chat response data<br/>[response.py]"]
  node_generation["Generation utilities<br/>[generate.py]"]
end

subgraph group_memory["Conversation data"]
  node_profile["User profile<br/>[profile.py]"]
  node_context["Short-term context<br/>[context.py]"]
  node_deep["Long-term memory<br/>[deep_context.py]"]
  node_messages["Messages and tools<br/>[message.py]"]
  node_database[("SQLite database<br/>[galerelm.db]")]
end

subgraph group_alibi["Alibi chatbot"]
  node_alibi_bot["Basic chatbot<br/>[basic_chat_bot.py]"]
  node_classifier["Intent classifier"]
  node_prompt["Prompt template<br/>[prompt_template.py]"]
  node_ollama_client["Ollama client<br/>[ollama_client.py]"]
end

node_user(("User"))
node_ollama{{"Ollama service"}}

node_user -->|"interacts with"| node_main
node_main -->|"loads or creates"| node_profile
node_main -->|"manages"| node_context
node_main -->|"initializes"| node_database
node_main -->|"builds and streams"| node_chat
node_chat -->|"streams requests"| node_api
node_api -->|"sends HTTP requests"| node_ollama
node_context -->|"archives overflow"| node_deep
node_deep -->|"requests embeddings"| node_api
node_context -->|"holds messages"| node_messages
node_chat -->|"formats conversation"| node_messages
node_chat -->|"formats settings"| node_options
node_chat -->|"formats tools"| node_tooldefs
node_chat -->|"builds response"| node_response
node_user -->|"sends prompt"| node_alibi_bot
node_webapp -->|"uses chatbot"| node_alibi_bot
node_alibi_bot -->|"classifies request"| node_classifier
node_alibi_bot -->|"generates prompt"| node_prompt
node_alibi_bot -->|"requests completion"| node_ollama_client
node_ollama_client -->|"posts chat request"| node_ollama

click node_main "https://github.com/rvbyy/sensai/blob/main/src/main.py"
click node_webapp "https://github.com/rvbyy/sensai/blob/main/src/webapp/init_app.py"
click node_chat "https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/chat.py"
click node_api "https://github.com/rvbyy/sensai/blob/main/src/rapideAPI/client.py"
click node_profile "https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/profile.py"
click node_context "https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/context.py"
click node_deep "https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/deep_context.py"
click node_messages "https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/message.py"
click node_options "https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/options.py"
click node_tooldefs "https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/tools.py"
click node_response "https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/response.py"
click node_generation "https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/generate.py"
click node_database "https://github.com/rvbyy/sensai/blob/main/src/galerelm.db"
click node_alibi_bot "https://github.com/rvbyy/sensai/blob/main/src/model/basic_chat_bot.py"
click node_classifier "https://github.com/rvbyy/sensai/blob/main/src/model/intent_classifier.py"
click node_prompt "https://github.com/rvbyy/sensai/blob/main/src/model/prompt_template.py"
click node_ollama_client "https://github.com/rvbyy/sensai/blob/main/src/model/ollama_client.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_main,node_webapp,node_user toneBlue
class node_chat,node_api,node_options,node_tooldefs,node_response,node_generation toneAmber
class node_profile,node_context,node_deep,node_messages,node_database toneMint
class node_alibi_bot,node_classifier,node_prompt,node_ollama_client toneRose
class node_ollama toneIndigo
```

## Components

### User interaction

- [Framework entry](https://github.com/rvbyy/sensai/blob/main/src/main.py): `src/main.py`
- [Web app setup](https://github.com/rvbyy/sensai/blob/main/src/webapp/init_app.py): `src/webapp/init_app.py`

### Chat framework

- [Chat generation](https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/chat.py): `src/galerelm/models/chat.py`
- [HTTP API client](https://github.com/rvbyy/sensai/blob/main/src/rapideAPI/client.py): `src/rapideAPI/client.py`
- [Generation options](https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/options.py): `src/galerelm/models/options.py`
- [Tool definitions](https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/tools.py): `src/galerelm/models/tools.py`
- [Chat response data](https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/response.py): `src/galerelm/models/response.py`
- [Generation utilities](https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/generate.py): `src/galerelm/models/generate.py`

### Conversation data

- [User profile](https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/profile.py): `src/galerelm/models/profile.py`
- [Short-term context](https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/context.py): `src/galerelm/models/context.py`
- [Long-term memory](https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/deep_context.py): `src/galerelm/models/deep_context.py`
- [Messages and tools](https://github.com/rvbyy/sensai/blob/main/src/galerelm/models/message.py): `src/galerelm/models/message.py`
- [SQLite database](https://github.com/rvbyy/sensai/blob/main/src/galerelm.db): `src/galerelm.db`

### Alibi chatbot

- [Basic chatbot](https://github.com/rvbyy/sensai/blob/main/src/model/basic_chat_bot.py): `src/model/basic_chat_bot.py`
- [Intent classifier](https://github.com/rvbyy/sensai/blob/main/src/model/intent_classifier.py): `src/model/intent_classifier.py`
- [Prompt template](https://github.com/rvbyy/sensai/blob/main/src/model/prompt_template.py): `src/model/prompt_template.py`
- [Ollama client](https://github.com/rvbyy/sensai/blob/main/src/model/ollama_client.py): `src/model/ollama_client.py`

### Other components

- **User**
- **Ollama service**

## Connections

- User → Framework entry: interacts with (evidence: `src/main.py`)
- Framework entry → User profile: loads or creates (evidence: `src/main.py`)
- Framework entry → Short-term context: manages (evidence: `src/main.py`)
- Framework entry → SQLite database: initializes (evidence: `src/main.py`)
- Framework entry → Chat generation: builds and streams (evidence: `src/main.py`)
- Chat generation → HTTP API client: streams requests (evidence: `src/galerelm/models/chat.py`)
- HTTP API client → Ollama service: sends HTTP requests (evidence: `src/rapideAPI/client.py`)
- Short-term context → Long-term memory: archives overflow (evidence: `src/galerelm/models/context.py`)
- Long-term memory → HTTP API client: requests embeddings (evidence: `src/galerelm/models/deep_context.py`)
- Short-term context → Messages and tools: holds messages (evidence: `src/galerelm/models/context.py`)
- Chat generation → Messages and tools: formats conversation (evidence: `src/galerelm/models/chat.py`)
- Chat generation → Generation options: formats settings (evidence: `src/galerelm/models/chat.py`)
- Chat generation → Tool definitions: formats tools (evidence: `src/galerelm/models/chat.py`)
- Chat generation → Chat response data: builds response (evidence: `src/galerelm/models/chat.py`)
- User → Basic chatbot: sends prompt (evidence: `src/model/basic_chat_bot.py`)
- Web app setup → Basic chatbot: uses chatbot (evidence: `src/webapp/init_app.py`)
- Basic chatbot → Intent classifier: classifies request (evidence: `src/model/basic_chat_bot.py`)
- Basic chatbot → Prompt template: generates prompt (evidence: `src/model/basic_chat_bot.py`)
- Basic chatbot → Ollama client: requests completion (evidence: `src/model/basic_chat_bot.py`)
- Ollama client → Ollama service: posts chat request (evidence: `src/model/ollama_client.py`)
