How kashif-e/kollama works
Project Type & Purpose
• Kollama is a client-side, full-stack application in the sense that it runs entirely locally on multiple platforms (Android, iOS, Desktop JVM, Web, Native).
• Its purpose is to provide a polished chat UI for interacting with local Ollama AI models, with persistence (SQLDelight) and real-time streaming.
File Structure & Architecture
• Top-level modules:
• composeApp/ – Kotlin Multiplatform module (commonMain + androidMain, iosMain, jvmMain, jsMain, nativeMain) containing UI, domain, data layers.
• iosApp/ – Xcode project that depends on the KMP framework produced by composeApp.
• Layers inside composeApp/src/commonMain:
a. presentation/ – Composables, ViewModel, state, theme, modifiers
b. domain/ – Interfaces and domain models
c. data/ – Repositories, service wrappers (OllamaService), DB wrappers (Database)
d. di/ – Koin modules
• Platform-specific source sets provide implementations for the service (HTTP via Ktor) and database (SQLDelight drivers).
README Architecture Section
• Confirms Clean Architecture: Presentation → Domain → Data → Infrastructure.
• Key technologies: Kotlin Multiplatform, Compose MPP, SQLDelight, Ktor, Koin
Main Components & Relationships
• Client Apps (Platform Targets)
• Android App (AndroidManifest & androidMain)
• iOS App (Xcode/iosApp)
• Desktop JVM (jvmMain)
• Web (jsMain + webpack)
• Native binaries (nativeMain)
• Shared KMP Framework
• Presentation Layer
• Domain Layer
• Data Layer
• DI Module
• External Systems
• Local Ollama server (HTTP API at localhost:11434)
• Local database (SQLDelight engine per platform)
Interactions & Data Flows
• User Interaction → Composables (ChatScreen, UI components)
→ ChatViewModel (state management, Kotlin Flow)
→ Domain interfaces (ChatRepository)
→ Data implementation (ChatRepositoryImpl)
→ a) OllamaService: streams requests/responses to local Ollama server
b) DatabaseWrapper: reads/writes chat history via SQLDelight
• Job Management: ChatJobManager handles concurrent sessions, LRU caching
• DI: Koin provides repository, service, database, ViewModel injection
Architectural Patterns & Principles
• Clean Architecture: strict dependency direction (presentation → domain → data → infra)
• Kotlin Multiplatform: share core logic, customize per-platform drivers
• Compose Multiplatform: single UI codebase for all targets
• Reactive State: Kotlin Flow, remember/derivedStateOf for recomposition
• LRU Caching: ChatJobManager for session lifecycle
Final Checklist
• [ ] Layers clearly separated (Client Platforms, Presentation, Domain, Data, Infra)
• [ ] Components labeled (ViewModel, Repository, Services, DB)
• [ ] External Ollama server and local DB drawn at Infra layer