Overview
GroupRepository handles all group-related data operations including creating groups, fetching group lists, updating group details, and deleting groups.
Interface: backend/GroupRepository.kt:12Implementation:
backend/SupabaseGroupRepository.kt:45
Interface Definition
Implementation
SupabaseGroupRepository
Loading and automatically refreshes on creation.
Methods
listGroups
Returns a reactive Flow of all groups for the current user.Flow<DataResult<List<Group>>> - Stream of group list with loading/error states
Example Usage:
getGroup
Returns a Flow for a single group by ID.String
required
The unique identifier of the group to retrieve
Flow<Group> - Stream of the requested group (returns placeholder if not found)
Example Usage:
createGroup
Creates a new group with the current user as owner.String
required
The display name for the new group
GroupIcon
required
The icon to display for the group (e.g.,
GroupIcon.Home, GroupIcon.Flight)Group - The newly created group object
Throws: Exception if Supabase call fails
Example Usage:
create_group_with_owner - Creates the group and adds the current user as a member
updateGroup
Updates an existing group’s name and icon.String
required
The ID of the group to update
String
required
The new name for the group
GroupIcon
required
The new icon for the group
deleteGroup
Deletes a group and all associated data (expenses, splits, members).String
required
The ID of the group to delete
delete_group_cascade - Deletes the group and all related records
refreshGroups
Forces a refresh of the groups list from Supabase.get_my_groups_summary - Returns groups with member counts and balance calculations
Data Models
Group
Source:models/Group.kt:7
Internal Models
Error Handling
Error States
The repository wraps all Supabase operations in try-catch blocks and updates the state flow:Common Errors
- Network errors: Connection timeout, no internet
- Authentication errors: Invalid session, expired token
- Database errors: Constraint violations, RLS policy failures