Skip to content

Latest commit

 

History

History
169 lines (141 loc) · 4.67 KB

File metadata and controls

169 lines (141 loc) · 4.67 KB

AI Chakra — Android AI Assistant

Overview

AI Chakra is an Android application that provides a floating AI assistant overlay button visible across all apps. Built with Kotlin, Jetpack Compose, and powered by Sarvam AI (via a backend server).


Project Setup

1. Open in Android Studio

  • Open Android Studio Hedgehog or newer
  • Select: File → Open → choose this folder
  • Wait for Gradle sync to complete

2. Configure Backend URL

Edit app/build.gradle.kts:

// For production
//buildConfigField("String", "BASE_URL", "\"https://your-backend.com/\"")

// For local development
buildConfigField("String", "BASE_URL", "\"http://10.0.2.2:8080/\"")

⚠️ Do NOT embed Sarvam AI API keys in the app. All AI requests go through your backend server.

3. Backend API Endpoints Required

Your backend server must expose:

Method Endpoint Description
POST /ai/chat General AI chat
POST /ai/translate Translate content
POST /ai/summarize Summarize content
POST /ai/explain Explain content

Request format:

{
  "prompt": "Explain this text",
  "content": "Text to process",
  "language": "hi"
}

Permissions Required

The user must grant these during onboarding:

Permission Purpose
SYSTEM_ALERT_WINDOW Floating overlay button
FOREGROUND_SERVICE Keep overlay alive
RECORD_AUDIO Voice input
CAMERA Camera image capture
READ_MEDIA_IMAGES Image upload from gallery
INTERNET AI API calls
Accessibility Service Read screen text

Architecture

UI (Compose Screens)
    ↕
ViewModel (Hilt, StateFlow)
    ↕
Repository (AiRepository)
    ↕              ↕
Network (Retrofit)   Local (Room DB)
(Sarvam AI backend)  (Chat History)

Module Structure

app/src/main/java/com/aichakra/app/
├── AiChakraApp.kt               # Application class
├── accessibility/
│   └── AiChakraAccessibilityService.kt
├── data/
│   ├── local/
│   │   ├── AiChakraDatabase.kt
│   │   ├── dao/ChatHistoryDao.kt
│   │   └── entity/ChatHistoryEntity.kt
│   └── remote/
│       ├── api/AiChakraApiService.kt
│       └── model/ApiModels.kt
├── di/
│   ├── AppModule.kt
│   └── PreferencesModule.kt
├── ocr/OcrEngine.kt
├── overlay/
│   ├── FloatingButtonComposeView.kt
│   ├── FloatingOverlayService.kt
│   └── ScreenCaptureService.kt
├── repository/AiRepository.kt
├── speech/SpeechManager.kt
├── ui/
│   ├── MainActivity.kt
│   ├── components/UiComponents.kt
│   ├── navigation/
│   │   ├── AppNavGraph.kt
│   │   └── Screen.kt
│   ├── screens/
│   │   ├── HomeScreen.kt
│   │   ├── AskAiScreen.kt
│   │   ├── TranslateScreen.kt
│   │   ├── ExplainSummarizeScreens.kt
│   │   ├── VoiceAskScreen.kt
│   │   ├── HistoryScreen.kt
│   │   ├── SettingsScreen.kt
│   │   └── ImageUploadScreen.kt
│   ├── theme/
│   │   ├── Color.kt
│   │   ├── Theme.kt
│   │   └── Type.kt
│   └── viewmodel/
│       ├── AiViewModel.kt
│       ├── HistoryViewModel.kt
│       └── SettingsViewModel.kt
└── utils/
    ├── PreferencesManager.kt
    └── Result.kt

Features

  • 🤖 Floating AI Button — Draggable, snaps to screen edges
  • 💬 Ask AI — Type any question
  • 🌐 Translate Screen — Reads visible text, translates to 9 Indian languages
  • 💡 Explain Screen — AI explains screen content simply
  • 📋 Summarize — Summarize WhatsApp/emails/articles
  • 📸 Image Upload — OCR + AI analysis
  • 🎙️ Voice Ask — Speak your question
  • 🔊 Text-to-Speech — AI reads responses aloud
  • 📜 History — All queries stored locally in Room DB
  • ⚙️ Settings — Language, overlay, auto-translate, TTS

Testing

./gradlew test           # Unit tests
./gradlew connectedAndroidTest  # Instrumented tests

Build

./gradlew assembleDebug   # Debug APK
./gradlew assembleRelease # Release APK (requires signing config)

Notes for Production

  1. Add signing config to app/build.gradle.kts for release builds
  2. Add google-services.json if using Firebase ML Kit hosting features
  3. Set up a proper backend server using Node.js/Python/Go that proxies Sarvam AI
  4. Consider adding rate limiting on the backend
  5. Add crash reporting (Firebase Crashlytics recommended)