# bipark/my_ollama_app architecture

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

- Interactive diagram: https://gitdiagram.com/bipark/my_ollama_app
- Repository: https://github.com/bipark/my_ollama_app

## Overview

#### Purpose and Entry Points
MyOllama is a Flutter client for chatting with models served by a remotely reachable Ollama host. The Dart application starts at `lib/main.dart`; native shells package it for Android, iOS, and macOS via `android/app/src/main/kotlin/com/example/my_ollama/MainActivity.kt`, `ios/Runner/AppDelegate.swift`, and `macos/Runner/MainFlutterWindow.swift`.

#### Application Composition
The root app selects platform-appropriate presentation and coordinates shared application state. `lib/views/desktop_view.dart` provides the desktop-oriented shell, while `lib/views/chat_view.dart` is the primary interactive chat surface. Reusable interaction controls, including model selection and dialogs, are in `lib/widgets/model_selector.dart` and `lib/widgets/dialogs.dart`.

#### State, Sessions, and UI Coordination
`lib/provider/main_provider.dart` is the central state-management boundary between views and domain/service operations. It manages user-visible state such as connection/model/chat selection and drives UI updates. Chat history and session-level conversation context are represented by `lib/models/chat_session.dart`; cross-component notifications use `lib/helpers/event_bus.dart`.

#### Ollama Integration and Chat Flow
`lib/services/chat_service.dart` is the external-service boundary for Ollama communication. The main flow is: user selects/configures an Ollama endpoint and model, submits a prompt from `lib/views/chat_view.dart`, provider state invokes the chat service, and returned model output updates the active `ChatSession` and rendered conversation. This boundary must accommodate Ollama-host availability, network failures, model capabilities such as image input, and streamed or asynchronous responses.

#### Model and Host Management
`lib/models/model_manager.dart` owns model-oriented domain behavior, supporting discovery/selection of models available from the configured Ollama server. Settings and connection configuration are exposed through `lib/views/settings.dart`, while `lib/widgets/model_selector.dart` binds available model state to user selection. The remote Ollama host is required infrastructure; it runs separately on the user’s computer and must be network-accessible by the device.

#### Platform-Specific Execution
Flutter targets Android, iOS/iPadOS, and macOS. `lib/utils/platform_utils.dart` and `lib/services/termux_service.dart` isolate platform-dependent behavior, with Termux indicating an Android-specific integration path. Packaging, permissions, launch behavior, and native build configuration remain outside the shared Dart layer in `android/app/src/main/AndroidManifest.xml`, `ios/Runner/Info.plist`, and `macos/Runner/Info.plist`.

#### Localization and User Data Boundary
The client ships English, Japanese, and Korean translation resources in `assets/translations/en-US.json`, `assets/translations/ja-JP.json`, and `assets/translations/ko-KR.json`. Conversation history is a client concern represented by session models and the drawer-oriented navigation UI in `lib/views/drawer.dart`; the README establishes no cloud backend or authentication service. The primary trust and security boundary is therefore the user-configured network path from the app to their Ollama instance.

Main entry points: [`lib/provider/main_provider.dart`](https://github.com/bipark/my_ollama_app/blob/main/lib/provider/main_provider.dart) (Main provider), [`lib/main.dart`](https://github.com/bipark/my_ollama_app/blob/main/lib/main.dart) (App entry), [`lib/views/chat_view.dart`](https://github.com/bipark/my_ollama_app/blob/main/lib/views/chat_view.dart) (Chat view), [`lib/views/settings.dart`](https://github.com/bipark/my_ollama_app/blob/main/lib/views/settings.dart) (Settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flutter["Flutter client"]
  node_main(("App entry<br/>Flutter bootstrap<br/>[main.dart]"))
  node_app_shell["App composition<br/>platform-aware shell"]
  node_desktop_view["Desktop shell<br/>presentation<br/>[desktop_view.dart]"]
  node_chat_view["Chat view<br/>interactive presentation<br/>[chat_view.dart]"]
  node_drawer["Session drawer<br/>navigation UI<br/>[drawer.dart]"]
  node_settings["Settings<br/>configuration UI<br/>[settings.dart]"]
  node_model_selector["Model selector<br/>reusable control"]
  node_dialogs["Dialogs<br/>reusable UI<br/>[dialogs.dart]"]
  node_provider{{"Main provider<br/>state boundary<br/>[main_provider.dart]"}}
  node_chat_session["Chat session<br/>conversation model<br/>[chat_session.dart]"]
  node_model_manager["Model manager<br/>model domain<br/>[model_manager.dart]"]
  node_chat_service{{"Chat service<br/>Ollama gateway<br/>[chat_service.dart]"}}
  node_event_bus["Event bus<br/>notifications<br/>[event_bus.dart]"]
  node_platform_utils["Platform utilities<br/>platform abstraction"]
  node_termux_service["Termux service<br/>Android integration"]
  node_translations["Translations<br/>localized resources<br/>[en-US.json]"]
end

subgraph group_native["Native targets"]
  node_android["Android shell<br/>native runtime<br/>[MainActivity.kt]"]
  node_ios["iOS shell<br/>native runtime<br/>[AppDelegate.swift]"]
  node_macos["macOS shell<br/>native runtime"]
end

subgraph group_external["User infrastructure"]
  node_ollama[("Remote Ollama host<br/>model server")]
end

node_android -->|"launches Flutter"| node_main
node_ios -->|"launches Flutter"| node_main
node_macos -->|"launches Flutter"| node_main
node_main -->|"bootstraps"| node_app_shell
node_app_shell -->|"desktop presentation"| node_desktop_view
node_app_shell -->|"chat surface"| node_chat_view
node_app_shell -->|"session navigation"| node_drawer
node_app_shell -->|"connection settings"| node_settings
node_app_shell -->|"localizes UI"| node_translations
node_chat_view -->|"submits prompts"| node_provider
node_settings -->|"updates endpoint"| node_provider
node_model_selector -->|"selects model"| node_provider
node_provider -->|"loads models"| node_model_manager
node_provider -->|"requests chat"| node_chat_service
node_provider -->|"updates active session"| node_chat_session
node_provider -.->|"publishes updates"| node_event_bus
node_chat_service -->|"network chat requests"| node_ollama
node_model_manager -->|"discovers models"| node_ollama
node_platform_utils -.->|"Android-specific path"| node_termux_service
node_provider -.->|"uses platform behavior"| node_platform_utils

click node_main "https://github.com/bipark/my_ollama_app/blob/main/lib/main.dart"
click node_desktop_view "https://github.com/bipark/my_ollama_app/blob/main/lib/views/desktop_view.dart"
click node_chat_view "https://github.com/bipark/my_ollama_app/blob/main/lib/views/chat_view.dart"
click node_drawer "https://github.com/bipark/my_ollama_app/blob/main/lib/views/drawer.dart"
click node_settings "https://github.com/bipark/my_ollama_app/blob/main/lib/views/settings.dart"
click node_model_selector "https://github.com/bipark/my_ollama_app/blob/main/lib/widgets/model_selector.dart"
click node_dialogs "https://github.com/bipark/my_ollama_app/blob/main/lib/widgets/dialogs.dart"
click node_provider "https://github.com/bipark/my_ollama_app/blob/main/lib/provider/main_provider.dart"
click node_chat_session "https://github.com/bipark/my_ollama_app/blob/main/lib/models/chat_session.dart"
click node_model_manager "https://github.com/bipark/my_ollama_app/blob/main/lib/models/model_manager.dart"
click node_chat_service "https://github.com/bipark/my_ollama_app/blob/main/lib/services/chat_service.dart"
click node_event_bus "https://github.com/bipark/my_ollama_app/blob/main/lib/helpers/event_bus.dart"
click node_platform_utils "https://github.com/bipark/my_ollama_app/blob/main/lib/utils/platform_utils.dart"
click node_termux_service "https://github.com/bipark/my_ollama_app/blob/main/lib/services/termux_service.dart"
click node_translations "https://github.com/bipark/my_ollama_app/blob/main/assets/translations/en-US.json"
click node_android "https://github.com/bipark/my_ollama_app/blob/main/android/app/src/main/kotlin/com/example/my_ollama/MainActivity.kt"
click node_ios "https://github.com/bipark/my_ollama_app/blob/main/ios/Runner/AppDelegate.swift"
click node_macos "https://github.com/bipark/my_ollama_app/blob/main/macos/Runner/MainFlutterWindow.swift"

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_main,node_app_shell,node_desktop_view,node_chat_view,node_drawer,node_settings,node_model_selector,node_dialogs,node_provider,node_chat_session,node_model_manager,node_chat_service,node_event_bus,node_platform_utils,node_termux_service,node_translations toneBlue
class node_android,node_ios,node_macos toneAmber
class node_ollama toneMint
```

## Components

### Flutter client

- [App entry](https://github.com/bipark/my_ollama_app/blob/main/lib/main.dart): Flutter bootstrap · `lib/main.dart`
- **App composition**: platform-aware shell
- [Desktop shell](https://github.com/bipark/my_ollama_app/blob/main/lib/views/desktop_view.dart): presentation · `lib/views/desktop_view.dart`
- [Chat view](https://github.com/bipark/my_ollama_app/blob/main/lib/views/chat_view.dart): interactive presentation · `lib/views/chat_view.dart`
- [Session drawer](https://github.com/bipark/my_ollama_app/blob/main/lib/views/drawer.dart): navigation UI · `lib/views/drawer.dart`
- [Settings](https://github.com/bipark/my_ollama_app/blob/main/lib/views/settings.dart): configuration UI · `lib/views/settings.dart`
- [Model selector](https://github.com/bipark/my_ollama_app/blob/main/lib/widgets/model_selector.dart): reusable control · `lib/widgets/model_selector.dart`
- [Dialogs](https://github.com/bipark/my_ollama_app/blob/main/lib/widgets/dialogs.dart): reusable UI · `lib/widgets/dialogs.dart`
- [Main provider](https://github.com/bipark/my_ollama_app/blob/main/lib/provider/main_provider.dart): state boundary · Coordinates visible connection, model, and chat state. · `lib/provider/main_provider.dart`
- [Chat session](https://github.com/bipark/my_ollama_app/blob/main/lib/models/chat_session.dart): conversation model · `lib/models/chat_session.dart`
- [Model manager](https://github.com/bipark/my_ollama_app/blob/main/lib/models/model_manager.dart): model domain · `lib/models/model_manager.dart`
- [Chat service](https://github.com/bipark/my_ollama_app/blob/main/lib/services/chat_service.dart): Ollama gateway · Handles availability, failures, streaming, and model capabilities. · `lib/services/chat_service.dart`
- [Event bus](https://github.com/bipark/my_ollama_app/blob/main/lib/helpers/event_bus.dart): notifications · `lib/helpers/event_bus.dart`
- [Platform utilities](https://github.com/bipark/my_ollama_app/blob/main/lib/utils/platform_utils.dart): platform abstraction · `lib/utils/platform_utils.dart`
- [Termux service](https://github.com/bipark/my_ollama_app/blob/main/lib/services/termux_service.dart): Android integration · `lib/services/termux_service.dart`
- [Translations](https://github.com/bipark/my_ollama_app/blob/main/assets/translations/en-US.json): localized resources · English, Japanese, and Korean resources. · `assets/translations/en-US.json`

### Native targets

- [Android shell](https://github.com/bipark/my_ollama_app/blob/main/android/app/src/main/kotlin/com/example/my_ollama/MainActivity.kt): native runtime · `android/app/src/main/kotlin/com/example/my_ollama/MainActivity.kt`
- [iOS shell](https://github.com/bipark/my_ollama_app/blob/main/ios/Runner/AppDelegate.swift): native runtime · `ios/Runner/AppDelegate.swift`
- [macOS shell](https://github.com/bipark/my_ollama_app/blob/main/macos/Runner/MainFlutterWindow.swift): native runtime · `macos/Runner/MainFlutterWindow.swift`

### User infrastructure

- **Remote Ollama host**: model server · User-configured network endpoint outside the client trust boundary.

## Connections

- Android shell → App entry: launches Flutter
- iOS shell → App entry: launches Flutter
- macOS shell → App entry: launches Flutter
- App entry → App composition: bootstraps
- App composition → Desktop shell: desktop presentation
- App composition → Chat view: chat surface
- App composition → Session drawer: session navigation
- App composition → Settings: connection settings
- App composition → Translations: localizes UI
- Chat view → Main provider: submits prompts
- Settings → Main provider: updates endpoint
- Model selector → Main provider: selects model
- Main provider → Model manager: loads models
- Main provider → Chat service: requests chat
- Main provider → Chat session: updates active session
- Main provider → Event bus: publishes updates
- Chat service → Remote Ollama host: network chat requests
- Model manager → Remote Ollama host: discovers models
- Platform utilities → Termux service: Android-specific path
- Main provider → Platform utilities: uses platform behavior
