Kollama is a modern, cross-platform chat interface for Ollama models built with Kotlin Multiplatform and Compose Multiplatform. It provides a sleek, user-friendly way to interact with local AI models while offering advanced features like code formatting, markdown support, and animated UI elements.
- 🚀 Cross-Platform Support: Built with Kotlin Multiplatform and Compose Multiplatform
- 💬 Real-time Chat Interface:
- Streaming responses with real-time updates
- Concurrent chat support with efficient job management
- Smart session handling with LRU cache
- 🎨 Rich Markdown Support:
- Syntax-highlighted code blocks with customizable themes
- Tables and complex formatting
- Custom typography system
- Optimized rendering for large messages
- 🔄 Advanced Message Handling:
- Real-time message streaming with state management
- Robust error handling and retry mechanism
- Optimized clipboard operations
- Sophisticated message state tracking
- 💾 Persistent Storage:
- SQLDelight for efficient, type-safe SQL operations
- Cross-platform database support
- Optimized query performance
- 🎯 Advanced Model Integration:
- Dynamic model switching with state preservation
- Model details display with animated marquee
- Real-time model status indicators
- 🎭 Polished UI/UX:
- Animated right sheet with gesture support
- Custom animated borders and transitions
- Fluid dark/light theme switching
- Responsive layout with efficient recomposition
- Pulsating status indicators and loading states
- JDK 17 or higher
- Ollama installed and running (default: localhost:11434)
- At least one Ollama model downloaded
- Install Ollama from Ollama's official website
- Pull a model using Ollama CLI:
ollama pull deepseek-coder:33b
- Clone this repository:
git clone https://github.com/kashif-e/kollama.git
- Run using Gradle:
./gradlew run
Kollama follows clean architecture principles with a focus on modularity and testability:
-
Presentation Layer:
ChatViewModel
: Manages UI state and user interactionsChatScreen
: Main UI composition- Custom composables for reusable UI elements
- Advanced state management with Kotlin Flow
-
Domain Layer:
- Pure Kotlin models for type safety
- Repository interfaces for data abstraction
- Clear separation of concerns
-
Data Layer:
ChatRepository
: Implementation of data operationsOllamaService
: Handles AI model communicationDatabaseWrapper
: SQLDelight database operations- Efficient data mapping and transformation
-
Infrastructure:
- Koin for dependency injection
- SQLDelight for database operations
- Ktor for network communications
data class ChatUiState(
val isLoading: Boolean = false,
val error: String? = null,
val currentSession: ChatSessionDomainModel? = null,
val chatSessions: List<ChatSessionDomainModel> = emptyList(),
val selectedModel: OllamaModel? = null,
val availableModels: List<OllamaModel> = emptyList(),
val thinkingMessage: ChatMessageDomainModel? = null,
val showModelList: Boolean = false,
)
class ChatJobManager {
private val mutex = Mutex()
private val jobMap: MutableMap<String, JobState> = mutableMapOf()
private val lruList = DoublyLinkedList<String>()
// Manages concurrent chat sessions with LRU caching
}
@Composable
fun AnimatedBorderBox(
borderColors: List<Color>,
backgroundColor: Color,
shape: Shape = RectangleShape,
borderWidth: Dp = 1.dp,
animationDurationInMillis: Int = 3000,
content: @Composable BoxScope.() -> Unit
)
kollama/
├── data/
│ ├── local/
│ │ ├── database/
│ │ └── service/
│ ├── model/
│ └── repository/
├── domain/
│ ├── interfaces/
│ └── model/
├── presentation/
│ ├── components/
│ ├── modifier/
│ ├── state/
│ └── theme/
└── di/
- Animated message borders with gradient effects
- Pulsating status indicators
- Smooth sheet transitions with gesture support
- Marquee animations for model details
- Efficient recomposition with remember/derivedStateOf
- Smart job management for concurrent chats
- Optimized database operations
- Proper coroutine scope management
- Robust error handling with custom error types
- Retry mechanisms for failed requests
- Proper timeout and cancellation handling
- Stream processing for real-time updates
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request