# j040-99/tugaai architecture

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

- Interactive diagram: https://gitdiagram.com/j040-99/tugaai
- Repository: https://github.com/j040-99/tugaai

## Overview

Open WebUI is a self-hosted AI platform for chatting with local or compatible cloud models, extended by retrieval, tools, and collaborative workspaces. The central workflow runs from a user message through the chat interface and API to model selection and a provider response; optional retrieval and tools add context or actions. The README documents substantial capabilities beyond the sampled source, so those appear as product branches without asserting unsampled internal call wiring. Paths identify exact files or directories in the supplied tree.

Main entry points: [`backend/open_webui/main.py`](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/main.py) (Chat request handler), [`backend/open_webui/routers/retrieval.py`](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/retrieval.py) (Retrieval API), [`backend/open_webui/internal/db.py`](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/internal/db.py) (Application database), [`backend/open_webui/routers/models.py`](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/models.py) (Model connections)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Chat experience"]
  node_chat_ui["Chat interface<br/>[Chat.svelte]"]
  node_chat_api["Chat API client<br/>[index.ts]"]
  node_message_view["Response rendering<br/>[Messages.svelte]"]
end

subgraph group_inference["Model execution"]
  node_chat_handler["Chat request handler<br/>[main.py]"]
  node_model_router["Model connections<br/>[models.py]"]
  node_ollama["Ollama connector<br/>[ollama.py]"]
  node_openai["OpenAI connector<br/>[openai.py]"]
end

subgraph group_knowledge["Knowledge and retrieval"]
  node_retrieval_api["Retrieval API<br/>[retrieval.py]"]
  node_document_loader["Document extraction<br/>[main.py]"]
  node_vector_layer["Vector search<br/>[main.py]"]
  node_web_search["Web search<br/>[main.py]"]
  node_files["Files and knowledge<br/>[files.py]"]
end

subgraph group_workspaces["Collaboration and extensions"]
  node_plugins["Tools and plugins<br/>[tools.py]"]
  node_channels["Shared channels<br/>[channels.py]"]
  node_calendar["Calendar<br/>[calendar.py]"]
  node_automation["Scheduled automations<br/>[automations.py]"]
end

subgraph group_platform["Identity and persistence"]
  node_auth["Authentication and access<br/>[auths.py]"]
  node_users_groups["Users and groups<br/>[groups.py]"]
  node_database[("Application database<br/>[db.py]")]
  node_storage[("File storage<br/>[provider.py]")]
end

node_user(("User"))
node_model_services{{"Model providers"}}
node_vector_backends[("Vector databases")]
node_mcp{{"MCP servers<br/>[client.py]"}}

node_user -->|"writes prompt"| node_chat_ui
node_chat_ui -->|"submits chat"| node_chat_api
node_chat_api -->|"sends request"| node_chat_handler
node_chat_handler -->|"resolves model"| node_model_router
node_model_router -->|"routes local"| node_ollama
node_model_router -->|"routes compatible"| node_openai
node_ollama -->|"requests inference"| node_model_services
node_openai -->|"requests inference"| node_model_services
node_chat_handler -->|"streams response"| node_message_view
node_chat_handler -.->|"retrieves context"| node_retrieval_api
node_retrieval_api -->|"extracts content"| node_document_loader
node_retrieval_api -->|"searches vectors"| node_vector_layer
node_vector_layer -->|"queries vectors"| node_vector_backends
node_retrieval_api -.->|"searches web"| node_web_search
node_chat_handler -.->|"dispatches tools"| node_plugins
node_plugins -.->|"calls server"| node_mcp
node_chat_handler -->|"persists chats"| node_database
node_user -->|"collaborates"| node_channels
node_user -->|"manages events"| node_calendar
node_user -->|"schedules prompts"| node_automation
node_user -->|"imports documents"| node_files
node_files -->|"extracts content"| node_document_loader
node_files -->|"stores files"| node_storage
node_user -->|"authenticates"| node_auth
node_auth -->|"checks access"| node_users_groups
node_channels -->|"persists channel data"| node_database
node_calendar -->|"persists events"| node_database
node_automation -->|"persists schedules"| node_database

click node_chat_ui "https://github.com/j040-99/tugaai/blob/main/src/lib/components/chat/Chat.svelte"
click node_chat_api "https://github.com/j040-99/tugaai/blob/main/src/lib/apis/chats/index.ts"
click node_chat_handler "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/main.py"
click node_model_router "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/models.py"
click node_ollama "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/ollama.py"
click node_openai "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/openai.py"
click node_message_view "https://github.com/j040-99/tugaai/blob/main/src/lib/components/chat/Messages.svelte"
click node_retrieval_api "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/retrieval.py"
click node_document_loader "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/retrieval/loaders/main.py"
click node_vector_layer "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/retrieval/vector/main.py"
click node_vector_backends "https://github.com/j040-99/tugaai/tree/main/backend/open_webui/retrieval/vector/dbs"
click node_web_search "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/retrieval/web/main.py"
click node_plugins "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/utils/tools.py"
click node_mcp "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/utils/mcp/client.py"
click node_channels "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/channels.py"
click node_calendar "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/calendar.py"
click node_automation "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/automations.py"
click node_files "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/files.py"
click node_auth "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/auths.py"
click node_users_groups "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/groups.py"
click node_database "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/internal/db.py"
click node_storage "https://github.com/j040-99/tugaai/blob/main/backend/open_webui/storage/provider.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_chat_ui,node_chat_api,node_message_view,node_user toneBlue
class node_chat_handler,node_model_router,node_ollama,node_openai,node_vector_backends toneAmber
class node_retrieval_api,node_document_loader,node_vector_layer,node_web_search,node_files,node_mcp toneMint
class node_plugins,node_channels,node_calendar,node_automation toneRose
class node_auth,node_users_groups,node_database,node_storage,node_model_services toneIndigo
```

## Components

### Chat experience

- [Chat interface](https://github.com/j040-99/tugaai/blob/main/src/lib/components/chat/Chat.svelte): `src/lib/components/chat/Chat.svelte`
- [Chat API client](https://github.com/j040-99/tugaai/blob/main/src/lib/apis/chats/index.ts): `src/lib/apis/chats/index.ts`
- [Response rendering](https://github.com/j040-99/tugaai/blob/main/src/lib/components/chat/Messages.svelte): `src/lib/components/chat/Messages.svelte`

### Model execution

- [Chat request handler](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/main.py): `backend/open_webui/main.py`
- [Model connections](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/models.py): `backend/open_webui/routers/models.py`
- [Ollama connector](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/ollama.py): `backend/open_webui/routers/ollama.py`
- [OpenAI connector](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/openai.py): `backend/open_webui/routers/openai.py`

### Knowledge and retrieval

- [Retrieval API](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/retrieval.py): `backend/open_webui/routers/retrieval.py`
- [Document extraction](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/retrieval/loaders/main.py): `backend/open_webui/retrieval/loaders/main.py`
- [Vector search](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/retrieval/vector/main.py): `backend/open_webui/retrieval/vector/main.py`
- [Web search](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/retrieval/web/main.py): `backend/open_webui/retrieval/web/main.py`
- [Files and knowledge](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/files.py): `backend/open_webui/routers/files.py`

### Collaboration and extensions

- [Tools and plugins](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/utils/tools.py): `backend/open_webui/utils/tools.py`
- [Shared channels](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/channels.py): `backend/open_webui/routers/channels.py`
- [Calendar](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/calendar.py): `backend/open_webui/routers/calendar.py`
- [Scheduled automations](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/automations.py): `backend/open_webui/routers/automations.py`

### Identity and persistence

- [Authentication and access](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/auths.py): `backend/open_webui/routers/auths.py`
- [Users and groups](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/routers/groups.py): `backend/open_webui/routers/groups.py`
- [Application database](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/internal/db.py): `backend/open_webui/internal/db.py`
- [File storage](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/storage/provider.py): `backend/open_webui/storage/provider.py`

### Other components

- **User**
- **Model providers**
- [Vector databases](https://github.com/j040-99/tugaai/tree/main/backend/open_webui/retrieval/vector/dbs): `backend/open_webui/retrieval/vector/dbs`
- [MCP servers](https://github.com/j040-99/tugaai/blob/main/backend/open_webui/utils/mcp/client.py): `backend/open_webui/utils/mcp/client.py`

## Connections

- User → Chat interface: writes prompt
- Chat interface → Chat API client: submits chat
- Chat API client → Chat request handler: sends request
- Chat request handler → Model connections: resolves model
- Model connections → Ollama connector: routes local
- Model connections → OpenAI connector: routes compatible
- Ollama connector → Model providers: requests inference
- OpenAI connector → Model providers: requests inference
- Chat request handler → Response rendering: streams response
- Chat request handler → Retrieval API: retrieves context
- Retrieval API → Document extraction: extracts content
- Retrieval API → Vector search: searches vectors
- Vector search → Vector databases: queries vectors
- Retrieval API → Web search: searches web
- Chat request handler → Tools and plugins: dispatches tools
- Tools and plugins → MCP servers: calls server
- Chat request handler → Application database: persists chats
- User → Shared channels: collaborates
- User → Calendar: manages events
- User → Scheduled automations: schedules prompts
- User → Files and knowledge: imports documents
- Files and knowledge → Document extraction: extracts content
- Files and knowledge → File storage: stores files
- User → Authentication and access: authenticates
- Authentication and access → Users and groups: checks access
- Shared channels → Application database: persists channel data
- Calendar → Application database: persists events
- Scheduled automations → Application database: persists schedules
