Technical Reference
Database Schema
Pebbl uses Room (SQLite) for local data persistence. Current version: 4
Entity Relationship Diagram
┌─────────────────┐
│ ProjectEntity │
└────────┬────────┘
│ 1
│
│ *
┌────┴────────────────────────┐
│ │
↓ ↓
┌────────────────┐ ┌──────────────┐
│VoiceStream │ │ DraftEntity │
│Entity │ └──────────────┘
└────────────────┘
┌─────────────────┐
│ LectureEntity │
└────────┬────────┘
│ 1
│
│ *
↓
┌──────────────────┐
│LectureOutput │
│Entity │
└──────────────────┘
┌──────────────────┐
│Achievement │
│Entity │
└──────────────────┘Entities
ProjectEntity
Represents a writing project or assignment.
Indexes: None currently (consider adding index on isActive for filtering)
VoiceStreamEntity
Stores conversation exchanges in a voice session.
Foreign Keys: Cascading delete when project deleted Indexes: projectId for efficient queries
DraftEntity
Stores generated academic drafts with versioning.
Versioning: Each generation creates new version, previous marked isCurrent = false
LectureEntity
Represents a recorded lecture with transcription.
LectureOutputEntity
Stores AI-generated outputs for lectures.
Output Types:
AchievementEntity
Tracks unlocked achievements/pebbles.
Database Migrations
Version 1 → 2: Added LectureEntity and LectureOutputEntity
Version 2 → 3: Added AchievementEntity, courseId to projects/lectures
Version 3 → 4: Added linkedLectureIds to ProjectEntity
API Integration
OpenRouter Service
Pebbl uses OpenRouter as a unified gateway to access AI models.
Configuration
Service Interface
Request Model
Response Model
Error Handling
AI Model
Model Used: google/gemini-2.5-flash-lite
Characteristics:
Fast response times (1-3 seconds)
Cost-effective
Good instruction following
Supports long context (up to 32K tokens)
Alternative Models (can be configured):
google/gemini-2.5-pro- Higher quality, sloweranthropic/claude-3-haiku- Fast, conciseopenai/gpt-4o-mini- Balanced quality/speed
API Call Examples
Generate Follow-Up Questions
Generate Draft
Voice Recognition
Pebbl uses Vosk for offline speech recognition, ensuring privacy and no internet dependency during recording.
Vosk Model
Model: vosk-model-small-en-us-0.15
Size: ~40MB
Language: US English
Accuracy: ~85-90% in quiet environments
Speed: Real-time on most devices
Alternative Models (can be downloaded separately):
vosk-model-en-us-0.22(Large, 1.8GB, higher accuracy)vosk-model-small-en-in-0.4(Indian English)Other languages available on Vosk website
VoiceRecognitionManager
Core class managing speech recognition lifecycle.
Initialization
Recording
Amplitude Calculation (for visualization)
Cleanup
Permissions
Required in AndroidManifest.xml:
Runtime permission request in MainActivity.kt:
AI Models
Prompt Engineering
Pebbl uses carefully crafted prompts to ensure consistent, high-quality outputs.
Follow-Up Questions Prompt Template
Draft Generation Prompt Template
Lecture Output Prompts
Overview Prompt:
Detailed Notes Prompt:
Summary Prompt:
Flashcards Prompt:
Component Reference
ViewModels
ViewModels manage UI state and business logic, surviving configuration changes.
ProjectViewModel
Manages project list and CRUD operations.
File: ui/viewmodel/ProjectViewModel.kt
State:
Public API:
Usage Example:
VoiceSessionViewModel
Manages voice recording and conversation flow for essay development.
File: ui/viewmodel/VoiceSessionViewModel.kt
State:
Public API:
LectureRecordingViewModel
Manages lecture recording, transcription, and AI output generation.
File: ui/viewmodel/LectureRecordingViewModel.kt
State:
Public API:
State Flow:
LectureOutputViewModel
Manages display of lecture analysis outputs.
File: ui/viewmodel/LectureOutputViewModel.kt
State:
Public API:
Repositories
AiRepository
Central repository for all AI API calls.
File: data/repository/AiRepository.kt
Constructor:
Methods:
Data Classes:
Error Handling:
DAOs
Data Access Objects provide type-safe database queries.
ProjectDao
File: data/local/dao/ProjectDao.kt
VoiceStreamDao
File: data/local/dao/VoiceStreamDao.kt
DraftDao
File: data/local/dao/DraftDao.kt
LectureDao
File: data/local/dao/LectureDao.kt
LectureOutputDao
File: data/local/dao/LectureOutputDao.kt
AchievementDao
File: data/local/dao/AchievementDao.kt
UI Screens
ProjectListScreen
File: ui/screens/ProjectListScreen.kt
Purpose: Main home screen showing all projects
Features:
List of all active projects
Recent pebbles row at top
Floating action button to create new project
Project cards with title, tags, timestamps
Actions: Start session, view draft, delete
Composable Signature:
Key Components:
RecentPebblesRow: Shows last 3 achievementsProjectCard: Individual project displayDeleteConfirmationDialog: Confirm before deleting
VoiceSessionScreen
File: ui/screens/VoiceSessionScreen.kt
Purpose: Record thoughts and engage in AI conversation
Features:
Large microphone button (start/stop recording)
Live transcription display
Three AI-generated questions
Conversation history scrollable list
Progress indicator during AI processing
Composable Signature:
UI States:
Idle: "Tap microphone to start"
Recording: Animated mic icon, live text
Processing: "AI is thinking..." with spinner
Questions displayed: Three clickable cards
DraftViewScreen
File: ui/screens/DraftViewScreen.kt
Purpose: View and configure generated drafts
Features:
Scrollable draft text display
Configuration panel (expandable)
Word goal slider
Tone selector (chips or dropdown)
Refinement level selector
Optional sections checkboxes
"Regenerate" button
Export/share button
Composable Signature:
Configuration Panel:
LectureRecordingScreen
File: ui/screens/LectureRecordingScreen.kt
Purpose: Record lectures with real-time transcription
Features:
Record/pause/resume/stop buttons
Duration timer (MM:SS format)
Live transcription text (scrollable)
Amplitude waveform visualization
Status indicators (initializing, recording, processing)
Composable Signature:
Amplitude Visualization:
LectureOutputViewScreen
File: ui/screens/LectureOutputViewScreen.kt
Purpose: Display AI-generated lecture analysis
Features:
Tab layout (Overview, Notes, Summary, Flashcards)
Formatted markdown rendering
Copy to clipboard
Share functionality
Flashcard flip animation (future)
Composable Signature:
Tab Structure:
Markdown Rendering:
PebbleCollectionScreen
File: ui/screens/PebbleCollectionScreen.kt
Purpose: Display all achievements (locked and unlocked)
Features:
Grid layout of pebble cards
Visual distinction (color vs grayscale)
Unlock date for earned pebbles
Unlock condition for locked pebbles
Total count for repeated achievements
Composable Signature:
Pebble Card:
Last updated
