# janhq/jan architecture

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

- Interactive diagram: https://gitdiagram.com/janhq/jan
- Repository: https://github.com/janhq/jan

## Overview

1. **This is a monorepo for Jan, a desktop-first AI application with a local runtime, optional cloud providers, and a documentation site.**  
   The main product is the Tauri app; surrounding packages support model execution, plugins, docs, QA, and packaging for multiple platforms.

2. **The primary user-facing app is `web-app/`, a React + Vite frontend.**  
   Its architecture is organized around routes, providers, hooks, containers, services, and stores. The UI includes chat, threads, settings, assistants, projects, model management, MCP configuration, logs, and system monitoring.

3. **The frontend is built around a service abstraction layer rather than direct backend calls.**  
   `web-app/src/services/*` contains per-domain service interfaces and implementations such as app, core, dialogs, hardware, messages, models, providers, threads, updater, and window. This lets the same UI logic run against Tauri, default/mock, or mobile implementations.

4. **Cross-cutting frontend state and behavior live in providers and hooks.**  
   Providers manage data loading, extension state, theming, event handling, analytics, keyboard shortcuts, and the “service hub.” Hooks encapsulate the app’s operational workflows: model loading, thread management, tool approval, attachments, hardware, local API server, MCP servers, updates, and prompt composition.

5. **The Rust backend in `src-tauri/` is the control plane for the desktop app.**  
   It exposes Tauri commands and internal modules for app setup, downloads, filesystem, MCP, server/proxying, system info, threads, updater, and extensions. This is where local desktop capabilities are implemented and where the frontend’s Tauri service layer ultimately routes actions.

6. **Backend state is organized by domain, with persistence and session management centered on threads, models, and servers.**  
   The Rust `core` modules include thread database logic, server proxying, app configuration, downloads, filesystem helpers, and update/session handling. This is the layer that coordinates app lifecycle, local storage, and operational state.

7. **Model execution is split across runtime-specific subsystems and plugins.**  
   The repo includes support for local `llama.cpp`, MLX, and Foundation Models, plus remote providers. The corresponding Tauri plugins manage process lifecycle, backend discovery, model loading/unloading, device enumeration, supported feature detection, and version handling.

8. **There is a clear plugin boundary between Rust commands and JavaScript guest bindings.**  
   Under `src-tauri/plugins/*`, each plugin has Rust command handlers, permission manifests, and a `guest-js` package for the frontend to call. This isolates privileged OS/model operations from the React layer while still exposing typed APIs.

9. **The app’s AI features depend on two major data-processing subsystems: RAG and vector storage.**  
   The RAG plugin parses documents, while the vector-db plugin creates collections, chunks text, stores embeddings/chunks, and supports attachment search. Together they back file attachments, retrieval-augmented prompts, and project/document workflows.

10. **MCP is a first-class integration point for tool use and agentic workflows.**  
   Both frontend and backend contain MCP-specific modules for server configuration, routing, telemetry, lockfiles, and tool approval. This is a distinct subsystem that sits alongside chat/model execution rather than being embedded in the chat UI itself.

11. **The local OpenAI-compatible server is an important external boundary.**  
   The backend exposes a localhost API server for other applications, and the frontend has dedicated settings and logs surfaces for it. This makes Jan both an end-user chat app and a local AI service host.

12. **Persistence and filesystem layout are significant architectural concerns.**  
   Threads, downloads, attachments, model files, and configuration data are all managed locally, with explicit filesystem helpers and data-folder settings in the UI. The architecture assumes local-first storage with privacy-sensitive boundaries.

13. **`autoqa/` is a separate functional subsystem for end-to-end validation.**  
   It contains Python-based test orchestration, OS-specific install/download/setup scripts, screen recording, and reportportal integration. Its job is to exercise the shipped app across platforms rather than test a single library in isolation.

14. **`docs/` is an independent Next.js documentation and marketing site.**  
   It publishes product docs, changelogs, API reference material, and tutorials, and includes an OpenAPI document. This is separate from the desktop runtime, but it mirrors product capabilities and release communication.

15. **Packaging and release automation span multiple targets and platform-specific installers.**  
   The repository includes Flatpak config, Tauri platform configs, MLX Swift server code, Windows/macOS/Linux workflows, and release automation scripts. These are not core runtime logic, but they define how the same product is built and distributed across environments.

16. **If you draw the architecture, the main flows are: user action in `web-app` → service abstraction → Tauri command/plugin or local API server → model/runtime/process/filesystem/vector store → persisted local state and events back to the UI.**  
   The key boundaries are frontend vs. Rust backend, command APIs vs. plugins, local models vs. remote providers, and product runtime vs. docs/QA/build infrastructure.

Main entry points: [`src-tauri/src/core`](https://github.com/janhq/jan/tree/main/src-tauri/src/core) (Core domains), [`web-app`](https://github.com/janhq/jan/tree/main/web-app) (App shell), [`.github/workflows`](https://github.com/janhq/jan/blob/main/.github/workflows) (Packaging), [`web-app/src/services`](https://github.com/janhq/jan/tree/main/web-app/src/services) (Services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend app"]
  node_web_app_shell["App shell<br/>React/Vite UI"]
  node_web_app_routes["Routes<br/>Navigation pages"]
  node_web_app_services["Services<br/>Client adapters"]
  node_web_app_hooks["Hooks"]
  node_web_app_providers["Providers<br/>Cross-cutting state"]
  node_web_app_stores["Stores<br/>UI state"]
end

subgraph group_backend["Desktop backend"]
  node_core_pkg["Core pkg<br/>Shared TS core"]
  node_tauri_backend["Tauri backend<br/>Rust control plane"]
  node_tauri_core["Core domains<br/>Rust domains"]
  node_tauri_server["Local API<br/>OpenAI-compatible server"]
  node_tauri_threads["Threads<br/>Persistence domain"]
  node_tauri_mcp["MCP core<br/>Tool integration"]
  node_tauri_updater["Updater<br/>Release lifecycle"]
end

subgraph group_plugins["Plugins"]
  node_plugin_llama["llama.cpp<br/>Model runtime plugin"]
  node_plugin_mlx["MLX<br/>Model runtime plugin"]
  node_plugin_fm["Foundation Models<br/>Model runtime plugin"]
  node_plugin_rag["RAG parser<br/>Document parser"]
  node_plugin_vdb[("Vector DB<br/>Embedding store")]
end

subgraph group_extensions["Extensions"]
  node_ext_bundle["Extensions<br/>TS extension pack"]
end

subgraph group_docs["Docs site"]
  node_docs_site["Docs site<br/>Next.js site"]
end

subgraph group_qa["QA"]
  node_autoqa["AutoQA<br/>E2E validation"]
end

subgraph group_release["Packaging"]
  node_packaging["Packaging<br/>Build/release<br/>[workflows]"]
  node_mlx_server["MLX server<br/>Swift service"]
end

node_web_app_shell -->|"navigates"| node_web_app_routes
node_web_app_shell -->|"wraps"| node_web_app_providers
node_web_app_shell -->|"drives"| node_web_app_hooks
node_web_app_shell -->|"calls"| node_web_app_services
node_web_app_hooks -->|"uses"| node_web_app_services
node_web_app_providers -->|"configures"| node_web_app_services
node_web_app_stores -->|"feeds"| node_web_app_hooks
node_web_app_services -->|"bridges"| node_tauri_backend
node_web_app_services -->|"shares types"| node_core_pkg
node_tauri_backend -->|"contains"| node_tauri_core
node_tauri_core -->|"persists"| node_tauri_threads
node_tauri_core -->|"exposes"| node_tauri_server
node_tauri_core -->|"coordinates"| node_tauri_mcp
node_tauri_core -->|"updates"| node_tauri_updater
node_tauri_core -->|"invokes"| node_plugin_llama
node_tauri_core -->|"invokes"| node_plugin_mlx
node_tauri_core -->|"invokes"| node_plugin_fm
node_tauri_core -->|"ingests"| node_plugin_rag
node_tauri_core -->|"stores"| node_plugin_vdb
node_plugin_rag -->|"feeds chunks"| node_plugin_vdb
node_ext_bundle -->|"builds on"| node_core_pkg
node_ext_bundle -->|"extends"| node_tauri_backend
node_docs_site -->|"documents"| node_packaging
node_autoqa -->|"validates"| node_packaging
node_packaging -->|"builds"| node_tauri_backend
node_packaging -->|"bundles"| node_web_app_shell
node_packaging -->|"ships"| node_mlx_server

click node_web_app_shell "https://github.com/janhq/jan/tree/main/web-app"
click node_web_app_routes "https://github.com/janhq/jan/tree/main/web-app/src/routes"
click node_web_app_services "https://github.com/janhq/jan/tree/main/web-app/src/services"
click node_web_app_hooks "https://github.com/janhq/jan/tree/main/web-app/src/hooks"
click node_web_app_providers "https://github.com/janhq/jan/tree/main/web-app/src/providers"
click node_web_app_stores "https://github.com/janhq/jan/tree/main/web-app/src/stores"
click node_core_pkg "https://github.com/janhq/jan/tree/main/core"
click node_tauri_backend "https://github.com/janhq/jan/tree/main/src-tauri"
click node_tauri_core "https://github.com/janhq/jan/tree/main/src-tauri/src/core"
click node_tauri_server "https://github.com/janhq/jan/tree/main/src-tauri/src/core/server"
click node_tauri_threads "https://github.com/janhq/jan/tree/main/src-tauri/src/core/threads"
click node_tauri_mcp "https://github.com/janhq/jan/tree/main/src-tauri/src/core/mcp"
click node_tauri_updater "https://github.com/janhq/jan/tree/main/src-tauri/src/core/updater"
click node_plugin_llama "https://github.com/janhq/jan/tree/main/src-tauri/plugins/tauri-plugin-llamacpp"
click node_plugin_mlx "https://github.com/janhq/jan/tree/main/src-tauri/plugins/tauri-plugin-mlx"
click node_plugin_fm "https://github.com/janhq/jan/tree/main/src-tauri/plugins/tauri-plugin-foundation-models"
click node_plugin_rag "https://github.com/janhq/jan/tree/main/src-tauri/plugins/tauri-plugin-rag"
click node_plugin_vdb "https://github.com/janhq/jan/tree/main/src-tauri/plugins/tauri-plugin-vector-db"
click node_ext_bundle "https://github.com/janhq/jan/tree/main/extensions"
click node_docs_site "https://github.com/janhq/jan/tree/main/docs"
click node_autoqa "https://github.com/janhq/jan/tree/main/autoqa"
click node_packaging "https://github.com/janhq/jan/blob/main/.github/workflows"
click node_mlx_server "https://github.com/janhq/jan/tree/main/mlx-server"

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_web_app_shell,node_web_app_routes,node_web_app_services,node_web_app_hooks,node_web_app_providers,node_web_app_stores,node_packaging,node_mlx_server toneBlue
class node_core_pkg,node_tauri_backend,node_tauri_core,node_tauri_server,node_tauri_threads,node_tauri_mcp,node_tauri_updater toneAmber
class node_plugin_llama,node_plugin_mlx,node_plugin_fm,node_plugin_rag,node_plugin_vdb toneMint
class node_ext_bundle toneRose
class node_docs_site toneIndigo
class node_autoqa toneTeal
```

## Components

### Frontend app

React/Vite desktop UI and its client-side architecture

- [App shell](https://github.com/janhq/jan/tree/main/web-app): React/Vite UI · Primary Jan desktop frontend with routes, providers, hooks, and UI containers · `web-app`
- [Routes](https://github.com/janhq/jan/tree/main/web-app/src/routes): Navigation pages · Top-level app screens for chat, threads, settings, hub, logs, and system monitor · `web-app/src/routes`
- [Services](https://github.com/janhq/jan/tree/main/web-app/src/services): Client adapters · Domain service abstraction layer with Tauri/default/mobile implementations · `web-app/src/services`
- [Hooks](https://github.com/janhq/jan/tree/main/web-app/src/hooks): Workflow hooks · Operational hooks for model load, threads, MCP, attachments, updates, and prompts · `web-app/src/hooks`
- [Providers](https://github.com/janhq/jan/tree/main/web-app/src/providers): Cross-cutting state · Theme, events, analytics, keyboard shortcuts, extension state, and service hub wiring · `web-app/src/providers`
- [Stores](https://github.com/janhq/jan/tree/main/web-app/src/stores): UI state · Local client stores for chat session and message queue behavior · `web-app/src/stores`

### Desktop backend

Tauri control plane, core domains, and local server

- [Core pkg](https://github.com/janhq/jan/tree/main/core): Shared TS core · Shared browser-side core abstractions for extensions, engines, models, and types · `core`
- [Tauri backend](https://github.com/janhq/jan/tree/main/src-tauri): Rust control plane · Desktop runtime commands, setup, lifecycle, and backend orchestration · `src-tauri`
- [Core domains](https://github.com/janhq/jan/tree/main/src-tauri/src/core): Rust domains · App, downloads, filesystem, MCP, server, system, threads, updater, and extension coordination · `src-tauri/src/core`
- [Local API](https://github.com/janhq/jan/tree/main/src-tauri/src/core/server): OpenAI-compatible server · Local localhost API boundary and request proxying for external clients · `src-tauri/src/core/server`
- [Threads](https://github.com/janhq/jan/tree/main/src-tauri/src/core/threads): Persistence domain · Thread database, session state, and conversation lifecycle management · `src-tauri/src/core/threads`
- [MCP core](https://github.com/janhq/jan/tree/main/src-tauri/src/core/mcp): Tool integration · MCP server configuration, routing, telemetry, and lockfile handling · `src-tauri/src/core/mcp`
- [Updater](https://github.com/janhq/jan/tree/main/src-tauri/src/core/updater): Release lifecycle · Update checks, session handling, and custom updater logic · `src-tauri/src/core/updater`

### Plugins

Privileged Rust/JS plugin boundary for OS and model operations

- [llama.cpp](https://github.com/janhq/jan/tree/main/src-tauri/plugins/tauri-plugin-llamacpp): Model runtime plugin · Model loading, process lifecycle, backend discovery, and device/feature detection · `src-tauri/plugins/tauri-plugin-llamacpp`
- [MLX](https://github.com/janhq/jan/tree/main/src-tauri/plugins/tauri-plugin-mlx): Model runtime plugin · Apple-native MLX model lifecycle and loaded-session management · `src-tauri/plugins/tauri-plugin-mlx`
- [Foundation Models](https://github.com/janhq/jan/tree/main/src-tauri/plugins/tauri-plugin-foundation-models): Model runtime plugin · Swift-backed Foundation Models integration for Apple runtime support · `src-tauri/plugins/tauri-plugin-foundation-models`
- [RAG parser](https://github.com/janhq/jan/tree/main/src-tauri/plugins/tauri-plugin-rag): Document parser · Document parsing and ingestion for retrieval-augmented workflows · `src-tauri/plugins/tauri-plugin-rag`
- [Vector DB](https://github.com/janhq/jan/tree/main/src-tauri/plugins/tauri-plugin-vector-db): Embedding store · Collections, chunking, attachment search, and persisted embedding storage · `src-tauri/plugins/tauri-plugin-vector-db`

### Extensions

Reusable app extensions and model/runtime add-ons

- [Extensions](https://github.com/janhq/jan/tree/main/extensions): TS extension pack · Jan browser/browser-like extension layer and runtime-specific add-ons · `extensions`

### Docs site

Independent Next.js documentation and marketing site

- [Docs site](https://github.com/janhq/jan/tree/main/docs): Next.js site · Documentation, changelog, tutorials, API reference, and product marketing · `docs`

### QA

End-to-end validation and release exercise harness

- [AutoQA](https://github.com/janhq/jan/tree/main/autoqa): E2E validation · Python-based cross-platform install, launch, recording, and report automation · `autoqa`

### Packaging

Build, installer, and platform release automation

- [Packaging](https://github.com/janhq/jan/blob/main/.github/workflows): Build/release · Platform installers, Flatpak, MLX server, and CI release workflows · `.github/workflows`
- [MLX server](https://github.com/janhq/jan/tree/main/mlx-server): Swift service · Standalone MLX server implementation used for Apple model execution support · `mlx-server`

## Connections

- App shell → Routes: navigates · Routes define the user-facing screens and navigation structure
- App shell → Providers: wraps · Providers inject app-wide services, state, and runtime behavior
- App shell → Hooks: drives · Hooks coordinate workflows for chat, models, MCP, attachments, and updates
- App shell → Services: calls · UI logic reaches backend capabilities through service adapters
- Hooks → Services: uses · Operational hooks delegate effects and data access to services
- Providers → Services: configures · Service hub and global providers select the active runtime implementation
- Stores → Hooks: feeds · Stores support session and queue state used by app workflows
- Services → Tauri backend: bridges · Tauri implementations forward desktop actions into Rust commands
- Services → Core pkg: shares types · Frontend services and extensions consume shared core abstractions
- Tauri backend → Core domains: contains · Core Rust domains coordinate the desktop app lifecycle and features
- Core domains → Threads: persists · Thread storage and conversation state are centralized here
- Core domains → Local API: exposes · Local API server and proxying are managed by the server domain
- Core domains → MCP core: coordinates · MCP routing and approval flow are handled as a first-class backend domain
- Core domains → Updater: updates · Update session and version handling live in the updater domain
- Core domains → llama.cpp: invokes · Core runtime flows delegate model execution to the llama.cpp plugin
- Core domains → MLX: invokes · Apple MLX model execution is delegated to the MLX plugin
- Core domains → Foundation Models: invokes · Foundation Models support is separated behind its plugin boundary
- Core domains → RAG parser: ingests · Document parsing and retrieval preprocessing are plugin responsibilities
- Core domains → Vector DB: stores · Vector storage and attachment search are handled by the vector DB plugin
- RAG parser → Vector DB: feeds chunks · Parsed documents become stored chunks and embeddings for retrieval
- Extensions → Core pkg: builds on · Extensions use the shared browser/core model and engine abstractions
- Extensions → Tauri backend: extends · Extensions plug into desktop runtime capabilities and commands
- Docs site → Packaging: documents · Docs site communicates product capabilities, releases, and installation
- AutoQA → Packaging: validates · End-to-end QA exercises the packaged app across platforms
- Packaging → Tauri backend: builds · Tauri build and installer workflows package the desktop runtime
- Packaging → App shell: bundles · Frontend assets are assembled into the shipped desktop app
- Packaging → MLX server: ships · Platform packaging includes the standalone MLX service component
