# flutter/ai architecture

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

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

## Overview

Flutter AI Toolkit is a set of embeddable Flutter chat widgets backed by a pluggable LLM-provider API. A user chats through the chat view; the configured provider supplies model responses, with Firebase AI available as a built-in integration. The documented feature set also includes streaming and multi-turn chat, rich text, voice input, attachments, conversation serialization, and extensive styling. No source excerpts were supplied, so internal calls and feature wiring are unverified; dashed, uncited edges mark those connections.

Main entry points: [`lib/src/views/llm_chat_view/llm_chat_view.dart`](https://github.com/flutter/ai/blob/main/lib/src/views/llm_chat_view/llm_chat_view.dart) (Chat view), [`lib/src/views/chat_input/chat_input.dart`](https://github.com/flutter/ai/blob/main/lib/src/views/chat_input/chat_input.dart) (Chat input), [`lib/src/providers/implementations/firebase_provider.dart`](https://github.com/flutter/ai/blob/main/lib/src/providers/implementations/firebase_provider.dart) (Firebase provider), [`lib/src/views/chat_message_view/llm_message_view.dart`](https://github.com/flutter/ai/blob/main/lib/src/views/chat_message_view/llm_message_view.dart) (Message views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chat_ui["Chat experience"]
  node_chat_view["Chat view<br/>[llm_chat_view.dart]"]
  node_chat_input["Chat input<br/>[chat_input.dart]"]
  node_voice_input["Voice input"]
  node_attachments["Attachments"]
  node_messages["Message views"]
  node_response_builder["Response rendering"]
end

subgraph group_chat_state["Chat state"]
  node_chat_model["Chat model"]
  node_chat_client["Provider client"]
  node_history["Chat history"]
end

subgraph group_llm["LLM providers"]
  node_provider_api["Provider API<br/>[llm_provider.dart]"]
  node_firebase_provider["Firebase provider"]
  node_echo_provider["Echo provider<br/>[echo_provider.dart]"]
end

subgraph group_customization["Customization"]
  node_styles["Chat styling"]
  node_strings["Custom strings"]
end

node_user(("Chat user"))
node_firebase_ai["Firebase AI"]

node_user -->|"chats in"| node_chat_view
node_chat_view -->|"configures provider"| node_firebase_provider
node_firebase_provider -->|"uses model"| node_firebase_ai
node_chat_view -.->|"manages turns"| node_chat_model
node_chat_model -.->|"dispatches requests"| node_chat_client
node_chat_client -.->|"calls provider"| node_provider_api
node_firebase_provider -.->|"implements API"| node_provider_api
node_chat_view -.->|"accepts prompts"| node_chat_input
node_chat_input -.->|"offers voice"| node_voice_input
node_chat_input -.->|"adds media"| node_attachments
node_chat_view -.->|"shows messages"| node_messages
node_messages -.->|"renders rich text"| node_response_builder
node_chat_view -.->|"supports serialization"| node_history
node_chat_view -.->|"applies styling"| node_styles
node_chat_view -.->|"uses custom strings"| node_strings

click node_chat_view "https://github.com/flutter/ai/blob/main/lib/src/views/llm_chat_view/llm_chat_view.dart"
click node_chat_input "https://github.com/flutter/ai/blob/main/lib/src/views/chat_input/chat_input.dart"
click node_voice_input "https://github.com/flutter/ai/blob/main/lib/src/views/chat_input/text_or_audio_input.dart"
click node_attachments "https://github.com/flutter/ai/blob/main/lib/src/views/chat_input/attachments_view.dart"
click node_messages "https://github.com/flutter/ai/blob/main/lib/src/views/chat_message_view/llm_message_view.dart"
click node_response_builder "https://github.com/flutter/ai/blob/main/lib/src/views/response_builder.dart"
click node_chat_model "https://github.com/flutter/ai/blob/main/lib/src/chat_view_model/chat_view_model.dart"
click node_chat_client "https://github.com/flutter/ai/blob/main/lib/src/chat_view_model/chat_view_model_client.dart"
click node_history "https://github.com/flutter/ai/blob/main/lib/src/views/chat_history_view.dart"
click node_provider_api "https://github.com/flutter/ai/blob/main/lib/src/providers/interface/llm_provider.dart"
click node_firebase_provider "https://github.com/flutter/ai/blob/main/lib/src/providers/implementations/firebase_provider.dart"
click node_echo_provider "https://github.com/flutter/ai/blob/main/lib/src/providers/implementations/echo_provider.dart"
click node_styles "https://github.com/flutter/ai/blob/main/lib/src/styles/llm_chat_view_style.dart"
click node_strings "https://github.com/flutter/ai/blob/main/lib/src/strings/llm_chat_view_strings.dart"

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_view,node_chat_input,node_voice_input,node_attachments,node_messages,node_response_builder,node_user toneBlue
class node_chat_model,node_chat_client,node_history toneAmber
class node_provider_api,node_firebase_provider,node_echo_provider toneMint
class node_styles,node_strings toneRose
class node_firebase_ai toneIndigo
```

## Components

### Chat experience

- [Chat view](https://github.com/flutter/ai/blob/main/lib/src/views/llm_chat_view/llm_chat_view.dart): `lib/src/views/llm_chat_view/llm_chat_view.dart`
- [Chat input](https://github.com/flutter/ai/blob/main/lib/src/views/chat_input/chat_input.dart): `lib/src/views/chat_input/chat_input.dart`
- [Voice input](https://github.com/flutter/ai/blob/main/lib/src/views/chat_input/text_or_audio_input.dart): `lib/src/views/chat_input/text_or_audio_input.dart`
- [Attachments](https://github.com/flutter/ai/blob/main/lib/src/views/chat_input/attachments_view.dart): `lib/src/views/chat_input/attachments_view.dart`
- [Message views](https://github.com/flutter/ai/blob/main/lib/src/views/chat_message_view/llm_message_view.dart): `lib/src/views/chat_message_view/llm_message_view.dart`
- [Response rendering](https://github.com/flutter/ai/blob/main/lib/src/views/response_builder.dart): `lib/src/views/response_builder.dart`

### Chat state

- [Chat model](https://github.com/flutter/ai/blob/main/lib/src/chat_view_model/chat_view_model.dart): `lib/src/chat_view_model/chat_view_model.dart`
- [Provider client](https://github.com/flutter/ai/blob/main/lib/src/chat_view_model/chat_view_model_client.dart): `lib/src/chat_view_model/chat_view_model_client.dart`
- [Chat history](https://github.com/flutter/ai/blob/main/lib/src/views/chat_history_view.dart): `lib/src/views/chat_history_view.dart`

### LLM providers

- [Provider API](https://github.com/flutter/ai/blob/main/lib/src/providers/interface/llm_provider.dart): `lib/src/providers/interface/llm_provider.dart`
- [Firebase provider](https://github.com/flutter/ai/blob/main/lib/src/providers/implementations/firebase_provider.dart): `lib/src/providers/implementations/firebase_provider.dart`
- [Echo provider](https://github.com/flutter/ai/blob/main/lib/src/providers/implementations/echo_provider.dart): `lib/src/providers/implementations/echo_provider.dart`

### Customization

- [Chat styling](https://github.com/flutter/ai/blob/main/lib/src/styles/llm_chat_view_style.dart): `lib/src/styles/llm_chat_view_style.dart`
- [Custom strings](https://github.com/flutter/ai/blob/main/lib/src/strings/llm_chat_view_strings.dart): `lib/src/strings/llm_chat_view_strings.dart`

### Other components

- **Chat user**
- **Firebase AI**

## Connections

- Chat user → Chat view: chats in (evidence: `README.md`)
- Chat view → Firebase provider: configures provider (evidence: `README.md`)
- Firebase provider → Firebase AI: uses model (evidence: `README.md`)
- Chat view → Chat model: manages turns
- Chat model → Provider client: dispatches requests
- Provider client → Provider API: calls provider
- Firebase provider → Provider API: implements API
- Chat view → Chat input: accepts prompts
- Chat input → Voice input: offers voice
- Chat input → Attachments: adds media
- Chat view → Message views: shows messages
- Message views → Response rendering: renders rich text
- Chat view → Chat history: supports serialization
- Chat view → Chat styling: applies styling
- Chat view → Custom strings: uses custom strings
