# razajahangir/inhouse-ai architecture

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

- Interactive diagram: https://gitdiagram.com/razajahangir/inhouse-ai
- Repository: https://github.com/razajahangir/inhouse-ai

## Overview

Inhouse AI is a self-hosted, multi-user chat and document-question-answering stack. Users reach Open WebUI locally or through Cloudflare Access and an outbound tunnel; the UI provides chat and knowledge bases, while LiteLLM presents a model gateway backed by local inference. Postgres stores application data and document vectors. The README documents service roles and security boundaries, but no source excerpts were provided, so uncertain service-to-service calls are omitted or marked unverified.

Main entry points: [`docker-compose.yaml`](https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml) (Open WebUI), [`litellm/config.yaml`](https://github.com/razajahangir/inhouse-ai/blob/main/litellm/config.yaml) (LiteLLM Gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access_chat["Access &amp; Chat"]
  node_cloudflare_access["Cloudflare Access"]
  node_cloudflared["Cloudflare Tunnel"]
  node_open_webui["Open WebUI"]
  node_knowledge_bases["Knowledge Bases &amp; RAG"]
end

subgraph group_ai_runtime["AI Runtime"]
  node_litellm["LiteLLM Gateway<br/>[config.yaml]"]
  node_ollama["Ollama Model Server"]
  node_ollama_init["Model Download Job"]
  node_benchmark["Hardware Benchmark<br/>[bench.py]"]
end

subgraph group_local_state["Local Data &amp; Models"]
  node_postgres[("Postgres + pgvector")]
  node_model_weights[("Local Model Weights")]
end

node_user(("User"))

node_user -->|"requests access"| node_cloudflare_access
node_cloudflare_access -->|"admits identity"| node_cloudflared
node_cloudflared -->|"tunnels traffic"| node_open_webui
node_user -->|"uses local access"| node_open_webui
node_open_webui -->|"provides RAG"| node_knowledge_bases
node_open_webui -.->|"requests models"| node_litellm
node_litellm -->|"routes inference"| node_ollama
node_ollama_init -->|"downloads weights"| node_model_weights
node_ollama -.->|"loads weights"| node_model_weights
node_open_webui -->|"stores app data"| node_postgres
node_knowledge_bases -->|"stores vectors"| node_postgres

click node_cloudflared "https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml"
click node_open_webui "https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml"
click node_knowledge_bases "https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml"
click node_litellm "https://github.com/razajahangir/inhouse-ai/blob/main/litellm/config.yaml"
click node_ollama "https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml"
click node_ollama_init "https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml"
click node_postgres "https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml"
click node_model_weights "https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml"
click node_benchmark "https://github.com/razajahangir/inhouse-ai/blob/main/benchmarks/bench.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_cloudflare_access,node_cloudflared,node_open_webui,node_knowledge_bases,node_user toneBlue
class node_litellm,node_ollama,node_ollama_init,node_benchmark toneAmber
class node_postgres,node_model_weights toneMint
```

## Components

### Access & Chat

- **Cloudflare Access**
- [Cloudflare Tunnel](https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml): `docker-compose.yaml`
- [Open WebUI](https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml): `docker-compose.yaml`
- [Knowledge Bases & RAG](https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml): `docker-compose.yaml`

### AI Runtime

- [LiteLLM Gateway](https://github.com/razajahangir/inhouse-ai/blob/main/litellm/config.yaml): `litellm/config.yaml`
- [Ollama Model Server](https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml): `docker-compose.yaml`
- [Model Download Job](https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml): `docker-compose.yaml`
- [Hardware Benchmark](https://github.com/razajahangir/inhouse-ai/blob/main/benchmarks/bench.py): `benchmarks/bench.py`

### Local Data & Models

- [Postgres + pgvector](https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml): `docker-compose.yaml`
- [Local Model Weights](https://github.com/razajahangir/inhouse-ai/blob/main/docker-compose.yaml): `docker-compose.yaml`

### Other components

- **User**

## Connections

- User → Cloudflare Access: requests access (evidence: `README.md`)
- Cloudflare Access → Cloudflare Tunnel: admits identity (evidence: `README.md`)
- Cloudflare Tunnel → Open WebUI: tunnels traffic (evidence: `README.md`)
- User → Open WebUI: uses local access (evidence: `README.md`)
- Open WebUI → Knowledge Bases & RAG: provides RAG (evidence: `README.md`)
- Open WebUI → LiteLLM Gateway: requests models
- LiteLLM Gateway → Ollama Model Server: routes inference (evidence: `README.md`)
- Model Download Job → Local Model Weights: downloads weights (evidence: `README.md`)
- Ollama Model Server → Local Model Weights: loads weights
- Open WebUI → Postgres + pgvector: stores app data (evidence: `README.md`)
- Knowledge Bases & RAG → Postgres + pgvector: stores vectors (evidence: `README.md`)
