Introducing MobileGraph: An Open-Source AI Application Framework for Kotlin Multiplatform
MobileGraph is an open-source Kotlin Multiplatform SDK built strictly for the realities of Android and iOS edge devices. It allows you to orchestrate non-deterministic AI tasks — from streaming chatbots to autonomous ReAct agents — with absolute deterministic lifecycle control. This is Part 1 (Introduction) of a series on building AI-powered mobile applications with MobileGraph. Think of it as…
MobileGraph is a Kotlin Multiplatform SDK designed for Android and iOS edge devices, allowing developers to orchestrate non-deterministic AI tasks with deterministic lifecycle control. This article is the first part of a series on building AI-powered mobile applications using MobileGraph, focusing on its architectural principles based on LangGraph, tailored for mobile lifecycles.
The framework is available on Maven Central and follows Apache 2.0 licensing, integrating seamlessly with Jetpack Compose and SwiftUI state structures.
To demonstrate its capabilities, let's explore a simple streaming chat example with three lines of Kotlin code. The session is created and a plan for a 3-day trip to Tokyo is sent to the AI. The AI's response is then printed in chunks using Kotlin Flow for structured concurrency and cooperative cancellation.
MobileGraph offers more than just chat functionality. It serves as a full AI application framework with several major capability areas:
- Multi-Provider Chat: Developers can register multiple AI providers, including OpenAI, Google Gemini, Anthropic Claude, DeepSeek, and OpenRouter, using a unified API. This allows for seamless swapping between models based on prompt complexity or requirements.
- On-Device Retrieval Augmented Generation (RAG): With MobileGraph, developers can load documents, split them into chunks, embed them, and search all on-device. This includes defining a vector embedding model, creating a vector store, and loading documents using loaders for various formats such as PDF, Markdown, HTML, JSON, CSV, and websites.
- Retrieval and Generative Models: MobileGraph supports built-in retrievers like VectorStoreRetriever, BM25Retriever, HybridRetriever, MultiQueryRetriever, and RAG Pipeline. The RAG Pipeline orchestrates the search, augmentation, and generation processes, allowing for a seamless user experience.
Autonomous tool-calling agents are another key feature of MobileGraph. Developers can define Kotlin functions that the AI can autonomously decide to call, enabling the AI to "have hands." For example, a weather tool can be registered, allowing the AI to invoke this function to provide weather information for a specific city.
In summary, MobileGraph is not just a chat wrapper but a comprehensive AI application framework that simplifies the integration of various AI capabilities into mobile applications. By supporting multi-provider chat, on-device RAG, retrieval, generative models, and autonomous tool-calling agents, MobileGraph empowers developers to create sophisticated AI-powered mobile applications with ease.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.