The peer learning feature enables students from the same school and class to collaborate in study rooms with real-time chat and collaborative whiteboard.
- Location:
app/data/local/EncryptionManager.kt - Features:
- AES-256-CBC encryption for messages
- Session-based encryption keys
- Simple IV:ciphertext format
- Note: Uses simple AES instead of Signal Protocol for MVP
- Location:
app/data/realtime/SupabaseRealtimeManager.kt - Features:
- Real-time message broadcasting
- Presence tracking (who's online)
- Whiteboard operation sync
- Session management
- Configuration:
- Supabase URL:
https://pbgqfxexmgytuhvnvuxl.supabase.co ⚠️ ACTION REQUIRED: Replace placeholder anon key with actual key from Supabase Dashboard
- Supabase URL:
- Location:
app/data/repository/PeerRepository.kt - Features:
- Session CRUD operations
- Participant management
- Availability management
- Block/Report functionality
- Location:
app/ui/screens/peer/PeerLobbyScreen.kt - Features:
- Browse available study rooms
- Search by topic
- Filter by subject (Mathematics, Physics, Chemistry, Biology)
- Create new room with dialog
- Join existing rooms
- Real-time participant count
- Room status indicators (WAITING, ACTIVE, CLOSED)
- Location:
app/ui/screens/peer/StudyRoomScreen.kt - Features:
- Real-time encrypted chat
- Participant list with roles (HOST/PARTICIPANT)
- Message bubbles (sent/received)
- Whiteboard toggle
- Leave session confirmation
- Participant bottom sheet
- Location:
app/ui/screens/peer/WhiteboardScreen.kt - Features:
- Canvas-based drawing
- Tools: Draw, Erase, Text (placeholder)
- Color palette (Black, Red, Blue, Green, Yellow, Magenta)
- Stroke width control
- Clear all functionality
- Real-time collaborative sync (ready for integration)
Updated NavGraph.kt with:
Routes.PeerLobby→ PeerLobbyScreenRoutes.StudyRoom→ StudyRoomScreen (with sessionId parameter)
Important: Credentials are stored in app/local.properties which is gitignored for security.
- Go to Supabase Dashboard
- Select your project:
pbgqfxexmgytuhvnvuxl - Navigate to: Settings → API
- Copy the anon (public) key
- Edit
app/local.propertiesand replace:supabase.anon.key=YOUR_ACTUAL_ANON_KEY_HERE
The URL is already set to: https://pbgqfxexmgytuhvnvuxl.supabase.co
How it works:
- Credentials are loaded from
local.propertiesat build time - Injected into
BuildConfig.SUPABASE_URLandBuildConfig.SUPABASE_ANON_KEY SupabaseRealtimeManagerreads from BuildConfig- ✅ Never committed to git
- ✅ Safe for team development
The following dependencies were added to app/build.gradle.kts:
// Supabase Realtime
implementation("io.github.jan-tennert.supabase:realtime-kt:2.0.4")
implementation("io.ktor:ktor-client-okhttp:2.3.7")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")Run: File → Sync Project with Gradle Files
- From Dashboard, tap the "Peer Learning" button
- Create a new study room or join an existing one
- Send messages to test chat
- Toggle whiteboard to draw collaboratively
┌─────────────────┐
│ PeerLobbyScreen│
│ (List Rooms) │
└────────┬────────┘
│
├─ PeerLobbyViewModel
├─ PeerRepository
└─ PrepVerseApi
┌─────────────────┐
│ StudyRoomScreen │
│ (Chat + Board) │
└────────┬────────┘
│
├─ StudyRoomViewModel
├─ PeerRepository
├─ EncryptionManager (AES)
├─ SupabaseRealtimeManager
└─ PrepVerseApi
┌─────────────────┐
│WhiteboardScreen │
│ (Canvas Draw) │
└────────┬────────┘
│
└─ Canvas API
- User fills create dialog
PeerLobbyViewModel.createSession()callsPeerRepository- API creates session in Supabase
- User navigates to
StudyRoomScreen
- User taps "Join" on session card
PeerRepository.joinSession()adds user as participantStudyRoomViewModelinitializes:- Generates session encryption key
- Joins Supabase Realtime channel
- Loads existing messages
- When user sends message:
- Encrypt with AES for each participant
- Send to API (
POST /api/v1/peer/messages) - Broadcast via Supabase Realtime
- Other users receive via
realtimeManager.messageFlow - Decrypt and display in chat
- User toggles whiteboard
- Drawing operations captured on Canvas
- Operations sent to
StudyRoomViewModel - TODO: Sync to API and broadcast via Realtime
- School & Class Matching: Only students from same school/class can see each other
- AES Encryption: Messages encrypted with session key
- Block/Report: Users can block or report inappropriate behavior
- Voice calling (WebRTC)
- End-to-end encryption with Signal Protocol
- Whiteboard operation persistence to server
- Supabase Anon Key: Using placeholder - needs actual key
- User Context: Currently uses placeholder user IDs - needs integration with AuthRepository
- Whiteboard Sync: Drawing works locally, but server sync needs implementation
- Voice Chat: Skipped for MVP as requested
- Encryption: Using simple AES instead of Signal Protocol
- ✅ Get and add Supabase anon key
- ✅ Sync Gradle dependencies
- ✅ Test basic session creation/joining
- ✅ Integrate current user from AuthRepository
- Add WebRTC for voice calling
- Persist whiteboard state to server
- Add typing indicators
- Add message read receipts
- Add session history
- Upgrade to Signal Protocol encryption
- Add file sharing
- Add screen sharing
The backend already has all necessary endpoints implemented:
- ✅
POST /api/v1/peer/sessions- Create session - ✅
GET /api/v1/peer/sessions- List sessions - ✅
POST /api/v1/peer/sessions/{id}/join- Join session - ✅
POST /api/v1/peer/sessions/{id}/leave- Leave session - ✅
GET /api/v1/peer/sessions/{id}/participants- Get participants - ✅
POST /api/v1/peer/messages- Send message - ✅
GET /api/v1/peer/messages/{sessionId}- Get messages - ✅
POST /api/v1/peer/whiteboard/sync- Sync whiteboard - ✅
GET /api/v1/peer/whiteboard/{sessionId}- Get whiteboard state
- Run: Build → Clean Project then Build → Rebuild Project
- Ensure Kotlin version is 1.9.20+
- Verify anon key is correct
- Check internet permission in AndroidManifest.xml
- Test with:
adb logcat | grep Supabase
- Check encryption key is stored for session
- Verify Supabase Realtime channel is joined
- Look for decryption errors in logs
- Open peer lobby from dashboard
- Create a new study room
- Join the created room
- Send a message
- Verify message appears in chat
- Open whiteboard view
- Draw on canvas
- Toggle back to chat
- Leave the session
- Join an existing room
- Send messages between multiple users
app/data/realtime/SupabaseRealtimeManager.ktapp/ui/screens/peer/PeerLobbyScreen.ktapp/ui/screens/peer/PeerLobbyViewModel.ktapp/ui/screens/peer/StudyRoomScreen.ktapp/ui/screens/peer/StudyRoomViewModel.ktapp/ui/screens/peer/WhiteboardScreen.kt
app/data/local/EncryptionManager.kt- Replaced Signal Protocol with AESapp/ui/navigation/NavGraph.kt- Added peer routesapp/build.gradle.kts- Added Supabase dependencies
- Message Loading: Currently loads last 100 messages
- Realtime Connection: One connection per session
- Canvas Rendering: Redraws all operations on each frame
- Memory: Session keys stored in-memory (cleared on leave)
For issues or questions:
- Check backend logs:
tail -f backend/logs/app.log - Check Android logs:
adb logcat | grep PrepVerse - Verify Supabase dashboard for session/message data
- Test API endpoints with Postman/curl
Status: ✅ Core implementation complete. Ready for testing after Supabase anon key is added.