An Android document question-answering app that demonstrates how to combine Couchbase Lite, vector search, and Gemini to build an on-device/offline-first retrieval-augmented generation (RAG) experience.
The app is built with Jetpack Compose and uses Couchbase Lite Enterprise Edition with vector indexing support to store and search document content locally. Users can browse documents, ingest sample files, and ask natural-language questions through a chat experience backed by retrieval and LLM-based answer generation.
If your machine is already configured with Android Studio and the required Couchbase Lite dependencies:
git clone https://github.com/shivaycb/couchbase-lite-workshop.git
cd couchbase-lite-workshop
./gradlew assembleDebug
./gradlew installDebugThen open the app on an emulator or Android device.
This application appears to be a workshop/demo project for:
- Local-first document storage
- Vector indexing and semantic retrieval
- PDF/document ingestion
- Question answering over indexed content
- Gemini-powered answer generation
- Compose-based Android UI
- Dependency injection with Hilt
The app structure suggests a RAG-style workflow:
- Documents are added to the app
- Text is extracted and chunked
- Embeddings are generated
- Chunks and vectors are stored locally in Couchbase Lite
- User questions are matched against relevant chunks using vector search
- Retrieved context is sent to Gemini to generate answers
- Android Studio: Recent stable version recommended
- Android SDK:
- Minimum SDK: 26
- Target SDK: 34
- Compile SDK: 34
- Java: 8-compatible build target is configured
- Kotlin Android project support
- Internet access: Required for Gemini API calls
- Gemini API key: Required for LLM responses
- Access to Couchbase Maven repository: Required for Couchbase Lite EE dependencies
- Kotlin
- Jetpack Compose
- AndroidX Navigation Compose
- Material 3
- Hilt
- Couchbase Lite Android EE KTX
- Couchbase Lite Vector Search
- Google Gemini SDK
- Sentence Embeddings for Android
- Apache POI
- iTextPDF
- compose-markdown
Key dependencies visible in the project include:
com.couchbase.lite:couchbase-lite-android-ee-ktxcom.couchbase.lite:couchbase-lite-android-vector-search-arm64com.google.ai.client.generativeai:generativeai:0.6.0com.github.shubham0204:Sentence-Embeddings-Android:0.0.3com.itextpdf:itextpdf:5.5.13.3org.apache.poi:poiorg.apache.poi:poi-ooxmlcom.github.jeziellago:compose-markdown:0.5.0
Versions are managed partly through Gradle version catalogs in gradle/libs.versions.toml.
git clone https://github.com/shivaycb/couchbase-lite-workshop.git
cd couchbase-lite-workshopThe app reads geminiKey from local.properties. If local.properties is missing, it falls back to local.properties.default when present.
Create a file named local.properties in the project root:
geminiKey="YOUR_ACTUAL_API_KEY_HERE"If no key is provided, the build may still succeed, but Gemini-backed features will not function correctly.
Open the project in Android Studio and allow Gradle to sync.
Or from the command line:
./gradlew tasks./gradlew assembleDebug./gradlew installDebugThis project depends on the Couchbase mobile Maven repository.
The repository is configured in Gradle:
- top-level build configuration
- settings plugin management
- dependency resolution repositories
If dependency resolution fails, verify access to:
- Couchbase mobile Maven repository
- Maven Central
- Google Maven
- JitPack
- Namespace:
com.ml.couchbase.docqa - Application ID:
com.ml.couchbase.docqa - App class:
DocQAApplication - Launcher activity:
MainActivity
The app injects the Gemini key into BuildConfig for both:
debugrelease
So your geminiKey in local.properties becomes available at build time.
At launch, the application class initializes the database layer:
DocQAApplication- calls
DatabaseManager.init(this)
This indicates that database setup happens early in app startup before user interaction begins.
The main navigation flow is simple and Compose-based:
chat→ main question-answering screendocs→ document browsing / ingestion screen
The app starts on the chat route.
This suggests a workflow where:
- the user primarily interacts through chat
- documents can be opened or managed via a dedicated docs screen
The ChatScreen is the main entry point of the app. Based on naming and dependencies, it likely handles:
- question input
- retrieval-triggered prompts
- answer rendering
- markdown display
- navigation to the docs screen
The DocsScreen likely supports:
- browsing available documents
- importing or indexing documents
- selecting sample content
- returning to chat after ingestion
The repository includes a DatabaseManager abstraction.
The currently visible file suggests a placeholder/mock implementation, but commented code strongly indicates the intended design is:
- initialize Couchbase Lite
- enable vector search
- open a local database
- create/query indexes
- save documents
- run SQL++/query-based retrieval
The commented implementation references:
CouchbaseLite.init(context)CouchbaseLite.enableVectorSearch()- local database creation
- index creation
- query execution
- document save/delete operations
This suggests the workshop may progressively replace mock implementations with full Couchbase Lite-backed behavior across branches or exercises.
Based on the dependencies and package structure, the app’s intended RAG pipeline likely looks like this:
Supported document-related libraries indicate the app can parse:
- PDFs via iTextPDF
- Office documents / structured docs via Apache POI
Document content is extracted into plain text.
Large documents are typically split into smaller chunks so they can be embedded and searched efficiently.
The app includes a sentence embeddings library for Android, which suggests embeddings are generated locally on-device.
Chunks and embeddings are stored in Couchbase Lite documents.
A vector index is used to retrieve semantically similar chunks for the user’s question.
Relevant chunks are assembled into context for the LLM.
The Gemini SDK is used to generate a final answer grounded in the retrieved document context.
The repository includes a sample_pdfs folder with example content and prompts.
Examples referenced in the repository include:
- Couchbase Shell Documentation.pdf
- fina_sample_reports
Example prompt themes include:
- configuring Bedrock as the LLM in CB Shell
- registering a new Capella cluster in CB Shell
- finance-related ratio questions from report data
These samples appear intended to validate RAG quality and retrieval behavior.
.
├── app/
│ ├── build.gradle.kts
│ └── src/main/
│ ├── AndroidManifest.xml
│ ├── java/com/ml/couchbase/docqa/
│ │ ├── DocQAApplication.kt
│ │ ├── MainActivity.kt
│ │ └── data/
│ │ └── DatabaseManager.kt
│ └── res/
├── gradle/
│ └── libs.versions.toml
├── sample_pdfs/
│ └── README.md
├── build.gradle.kts
├── settings.gradle.kts
└── README.md
app/src/main/java/com/ml/couchbase/docqa/DocQAApplication.kt
Initializes the app and database layer.
app/src/main/java/com/ml/couchbase/docqa/MainActivity.kt
Sets up Compose UI and navigation between chat and docs screens.
app/src/main/java/com/ml/couchbase/docqa/data/DatabaseManager.kt
Encapsulates database initialization and storage/query operations.
app/src/main/AndroidManifest.xml
Registers the application class, main activity, and internet permission.
app/build.gradle.kts
Defines Android build settings, dependency declarations, Hilt, Compose, and Gemini key handling.
settings.gradle.ktsbuild.gradle.kts
Configure plugin management and repositories including Couchbase’s Maven endpoint.
./gradlew assembleDebug./gradlew installDebug./gradlew test./gradlew lint- Launch the app
- Open the documents screen if needed
- Add or inspect sample documents
- Return to the chat screen
- Ask questions about the indexed content
- Review the generated answer and retrieved context behavior