How bipark/my_ollama_app works
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: main_provider.dart Main provider · main.dart App entry · chat_view.dart Chat view · settings.dart Settings
Components 20
Flutter client
- App entry
lib/main.dart - App composition
- Desktop shell
lib/views/desktop_view.dart - Chat view
lib/views/chat_view.dart - Session drawer
lib/views/drawer.dart - Settings
lib/views/settings.dart - Model selector
lib/widgets/model_selector.dart - Dialogs
lib/widgets/dialogs.dart - Main provider · Coordinates visible connection, model, and chat state.
lib/provider/main_provider.dart - Chat session
lib/models/chat_session.dart - Model manager
lib/models/model_manager.dart - Chat service · Handles availability, failures, streaming, and model capabilities.
lib/services/chat_service.dart - Event bus
lib/helpers/event_bus.dart - Platform utilities
lib/utils/platform_utils.dart - Termux service
lib/services/termux_service.dart - Translations · English, Japanese, and Korean resources.
assets/translations/en-US.json
Native targets
- Android shell
android/app/src/main/kotlin/com/example/my_ollama/MainActivity.kt - iOS shell
ios/Runner/AppDelegate.swift - macOS shell
macos/Runner/MainFlutterWindow.swift
User infrastructure
- Remote Ollama host · User-configured network endpoint outside the client trust boundary.
Connections 20
- 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