# mobile-artificial-intelligence/maid architecture

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

- Interactive diagram: https://gitdiagram.com/mobile-artificial-intelligence/maid
- Repository: https://github.com/mobile-artificial-intelligence/maid

## Overview

Maid is an Android React Native app for chatting with local llama.cpp models or remote model providers. Users choose or download a model, compose prompts and optional images, stream responses, and manage conversations; settings customize model parameters and assistant identity. Optional account sync backs up settings and chat history through Supabase. The graph reflects documented capabilities and sampled provider/context wiring; unsampled screens and persistence details are represented only where the README supports them.

Main entry points: [`context/system.tsx`](https://github.com/mobile-artificial-intelligence/maid/blob/main/context/system.tsx) (Assistant settings), [`context/language-model/index.tsx`](https://github.com/mobile-artificial-intelligence/maid/blob/main/context/language-model/index.tsx) (Provider manager), [`utilities/supabase.ts`](https://github.com/mobile-artificial-intelligence/maid/blob/main/utilities/supabase.ts) (Supabase), [`app/chat/index.tsx`](https://github.com/mobile-artificial-intelligence/maid/blob/main/app/chat/index.tsx) (Chat screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_chat["Chat screen<br/>[index.tsx]"]
  node_prompt["Prompt composer"]
  node_messages["Message display<br/>[content-view.tsx]"]
  node_downloads["Model downloads<br/>[download.tsx]"]
  node_navigation["Chat navigation<br/>[drawer-content.tsx]"]
end

subgraph group_inference["Model inference"]
  node_llm_context["Provider manager<br/>[index.tsx]"]
  node_llama["Local llama.cpp<br/>[llama.tsx]"]
  node_ollama["Ollama provider<br/>[ollama.tsx]"]
  node_remote["Remote providers"]
  node_model_store["Model files<br/>[llama.tsx]"]
end

subgraph group_state["Conversation and settings"]
  node_chat_state["Conversation state<br/>[chat.tsx]"]
  node_local_db[("Local database<br/>[local-db.ts]")]
  node_system["Assistant settings<br/>[system.tsx]"]
  node_voice["Voice output<br/>[use-voice.ts]"]
  node_theme["Theme<br/>[use-theme.ts]"]
end

subgraph group_services["Account and sync"]
  node_sync_hooks["Synced preferences"]
  node_image_sync["Synced images"]
  node_auth["Authentication"]
  node_supabase["Supabase<br/>[supabase.ts]"]
  node_account["Account screens<br/>[register.tsx]"]
end

node_user(("App user"))

node_user -->|"opens"| node_chat
node_chat -->|"renders"| node_prompt
node_chat -->|"renders"| node_messages
node_prompt -.->|"submits prompts"| node_chat_state
node_messages -->|"requests responses"| node_llm_context
node_llm_context -->|"dispatches local"| node_llama
node_llm_context -->|"dispatches provider"| node_ollama
node_llm_context -->|"dispatches provider"| node_remote
node_llama -.->|"loads model files"| node_model_store
node_user -->|"browses models"| node_downloads
node_downloads -->|"downloads GGUF"| node_model_store
node_navigation -->|"manages conversations"| node_chat_state
node_chat_state -.->|"persists locally"| node_local_db
node_user -->|"customizes assistant"| node_system
node_system -->|"stores preferences"| node_sync_hooks
node_system -->|"stores profile images"| node_image_sync
node_sync_hooks -->|"checks session"| node_auth
node_image_sync -->|"checks session"| node_auth
node_auth -->|"uses client"| node_supabase
node_sync_hooks -->|"syncs settings"| node_supabase
node_image_sync -->|"syncs images"| node_supabase
node_user -->|"registers or logs in"| node_account
node_account -->|"authenticates"| node_supabase
node_user -->|"pairs voice output"| node_voice
node_system -->|"configures voice"| node_voice
node_system -->|"reads theme"| node_theme

click node_chat "https://github.com/mobile-artificial-intelligence/maid/blob/main/app/chat/index.tsx"
click node_prompt "https://github.com/mobile-artificial-intelligence/maid/blob/main/components/groups/prompt-input-group.tsx"
click node_messages "https://github.com/mobile-artificial-intelligence/maid/blob/main/components/views/message/content-view.tsx"
click node_downloads "https://github.com/mobile-artificial-intelligence/maid/blob/main/app/download.tsx"
click node_navigation "https://github.com/mobile-artificial-intelligence/maid/blob/main/components/layout/drawer-content.tsx"
click node_llm_context "https://github.com/mobile-artificial-intelligence/maid/blob/main/context/language-model/index.tsx"
click node_llama "https://github.com/mobile-artificial-intelligence/maid/blob/main/context/language-model/llama.tsx"
click node_ollama "https://github.com/mobile-artificial-intelligence/maid/blob/main/context/language-model/ollama.tsx"
click node_remote "https://github.com/mobile-artificial-intelligence/maid/tree/main/context/language-model"
click node_model_store "https://github.com/mobile-artificial-intelligence/maid/blob/main/context/language-model/llama.tsx"
click node_chat_state "https://github.com/mobile-artificial-intelligence/maid/blob/main/context/chat.tsx"
click node_local_db "https://github.com/mobile-artificial-intelligence/maid/blob/main/utilities/local-db.ts"
click node_system "https://github.com/mobile-artificial-intelligence/maid/blob/main/context/system.tsx"
click node_sync_hooks "https://github.com/mobile-artificial-intelligence/maid/blob/main/hooks/use-synced-string.ts"
click node_image_sync "https://github.com/mobile-artificial-intelligence/maid/blob/main/hooks/use-synced-image.ts"
click node_auth "https://github.com/mobile-artificial-intelligence/maid/blob/main/hooks/use-authentication.ts"
click node_supabase "https://github.com/mobile-artificial-intelligence/maid/blob/main/utilities/supabase.ts"
click node_account "https://github.com/mobile-artificial-intelligence/maid/blob/main/app/account/register.tsx"
click node_voice "https://github.com/mobile-artificial-intelligence/maid/blob/main/hooks/use-voice.ts"
click node_theme "https://github.com/mobile-artificial-intelligence/maid/blob/main/hooks/use-theme.ts"

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,node_prompt,node_messages,node_downloads,node_navigation,node_user toneBlue
class node_llm_context,node_llama,node_ollama,node_remote,node_model_store toneAmber
class node_chat_state,node_local_db,node_system,node_voice,node_theme toneMint
class node_sync_hooks,node_image_sync,node_auth,node_supabase,node_account toneRose
```

## Components

### App experience

- [Chat screen](https://github.com/mobile-artificial-intelligence/maid/blob/main/app/chat/index.tsx): `app/chat/index.tsx`
- [Prompt composer](https://github.com/mobile-artificial-intelligence/maid/blob/main/components/groups/prompt-input-group.tsx): `components/groups/prompt-input-group.tsx`
- [Message display](https://github.com/mobile-artificial-intelligence/maid/blob/main/components/views/message/content-view.tsx): `components/views/message/content-view.tsx`
- [Model downloads](https://github.com/mobile-artificial-intelligence/maid/blob/main/app/download.tsx): `app/download.tsx`
- [Chat navigation](https://github.com/mobile-artificial-intelligence/maid/blob/main/components/layout/drawer-content.tsx): `components/layout/drawer-content.tsx`

### Model inference

- [Provider manager](https://github.com/mobile-artificial-intelligence/maid/blob/main/context/language-model/index.tsx): `context/language-model/index.tsx`
- [Local llama.cpp](https://github.com/mobile-artificial-intelligence/maid/blob/main/context/language-model/llama.tsx): `context/language-model/llama.tsx`
- [Ollama provider](https://github.com/mobile-artificial-intelligence/maid/blob/main/context/language-model/ollama.tsx): `context/language-model/ollama.tsx`
- [Remote providers](https://github.com/mobile-artificial-intelligence/maid/tree/main/context/language-model): `context/language-model`
- [Model files](https://github.com/mobile-artificial-intelligence/maid/blob/main/context/language-model/llama.tsx): `context/language-model/llama.tsx`

### Conversation and settings

- [Conversation state](https://github.com/mobile-artificial-intelligence/maid/blob/main/context/chat.tsx): `context/chat.tsx`
- [Local database](https://github.com/mobile-artificial-intelligence/maid/blob/main/utilities/local-db.ts): `utilities/local-db.ts`
- [Assistant settings](https://github.com/mobile-artificial-intelligence/maid/blob/main/context/system.tsx): `context/system.tsx`
- [Voice output](https://github.com/mobile-artificial-intelligence/maid/blob/main/hooks/use-voice.ts): `hooks/use-voice.ts`
- [Theme](https://github.com/mobile-artificial-intelligence/maid/blob/main/hooks/use-theme.ts): `hooks/use-theme.ts`

### Account and sync

- [Synced preferences](https://github.com/mobile-artificial-intelligence/maid/blob/main/hooks/use-synced-string.ts): `hooks/use-synced-string.ts`
- [Synced images](https://github.com/mobile-artificial-intelligence/maid/blob/main/hooks/use-synced-image.ts): `hooks/use-synced-image.ts`
- [Authentication](https://github.com/mobile-artificial-intelligence/maid/blob/main/hooks/use-authentication.ts): `hooks/use-authentication.ts`
- [Supabase](https://github.com/mobile-artificial-intelligence/maid/blob/main/utilities/supabase.ts): `utilities/supabase.ts`
- [Account screens](https://github.com/mobile-artificial-intelligence/maid/blob/main/app/account/register.tsx): `app/account/register.tsx`

### Other components

- **App user**

## Connections

- App user → Chat screen: opens (evidence: `README.md`)
- Chat screen → Prompt composer: renders (evidence: `app/chat/index.tsx`)
- Chat screen → Message display: renders (evidence: `app/chat/index.tsx`)
- Prompt composer → Conversation state: submits prompts
- Message display → Provider manager: requests responses (evidence: `components/views/message/content-view.tsx`)
- Provider manager → Local llama.cpp: dispatches local (evidence: `context/language-model/index.tsx`)
- Provider manager → Ollama provider: dispatches provider (evidence: `context/language-model/index.tsx`)
- Provider manager → Remote providers: dispatches provider (evidence: `context/language-model/index.tsx`)
- Local llama.cpp → Model files: loads model files
- App user → Model downloads: browses models (evidence: `README.md`)
- Model downloads → Model files: downloads GGUF (evidence: `README.md`)
- Chat navigation → Conversation state: manages conversations (evidence: `README.md`)
- Conversation state → Local database: persists locally
- App user → Assistant settings: customizes assistant (evidence: `README.md`)
- Assistant settings → Synced preferences: stores preferences (evidence: `context/system.tsx`)
- Assistant settings → Synced images: stores profile images (evidence: `context/system.tsx`)
- Synced preferences → Authentication: checks session (evidence: `hooks/use-synced-string.ts`)
- Synced images → Authentication: checks session (evidence: `hooks/use-synced-image.ts`)
- Authentication → Supabase: uses client (evidence: `hooks/use-authentication.ts`)
- Synced preferences → Supabase: syncs settings (evidence: `hooks/use-synced-string.ts`)
- Synced images → Supabase: syncs images (evidence: `hooks/use-synced-image.ts`)
- App user → Account screens: registers or logs in (evidence: `README.md`)
- Account screens → Supabase: authenticates (evidence: `app/account/register.tsx`)
- App user → Voice output: pairs voice output (evidence: `README.md`)
- Assistant settings → Voice output: configures voice (evidence: `context/system.tsx`)
- Assistant settings → Theme: reads theme (evidence: `context/system.tsx`)
