Project Structure
Divvy follows a clean architecture pattern organized by feature and layer:Key Directories
backend/ - Data Layer
Contains repository interfaces and Supabase implementations:
GroupRepository.kt/SupabaseGroupRepository.ktExpensesRepository.kt/SupabaseExpensesRepository.ktAuthRepository.kt/SupabaseAuthRepository.ktProfilesRepository.kt,MemberRepository.kt,BalanceRepository.ktDataResult.kt- Sealed class for async operation states
ui/ - Presentation Layer
Organized by feature, each with
Views/ and ViewModels/ subdirectories:home/- Activity feed and quick statsgroups/- Group list and creationgroupdetail/- Group expenses and membersexpenses/- Expense listsplitexpense/- Create and split expensesassignitems/- Itemized receipt splittingledger/- Settlement trackingprofile/- User profile settingsnavigation/- NavHost and destination definitions
models/ - Domain Models
Data classes representing core business entities:
Group.kt- Group information and balanceExpense.kt- Individual expense recordsUserProfile.kt- User account dataSplit.kt- Expense split allocationLedgerEntry.kt- Settlement records
components/ - Shared UI
Reusable Compose components:
PrimaryButton.kt- Primary CTA buttonOutlineButton.kt- Secondary buttonGroupIcon.kt- Group avatar componentAuthTextField.kt- Styled input field
MVVM Architecture
Divvy uses the Model-View-ViewModel (MVVM) pattern with Jetpack Compose:Workflow
- View - Composable functions observe ViewModel state
- ViewModel - Manages UI state and business logic, calls repositories
- Repository - Fetches data from Supabase, returns
Flow<DataResult<T>>
Example: HomeViewModel Pattern
app/src/main/java/com/example/divvy/ui/home/ViewModels/HomeViewModel.kt:1 for the full implementation.
Adding a New Feature
Follow these steps to add a new feature to Divvy:Coding Standards
Kotlin Style
- Follow Kotlin coding conventions
- Use meaningful variable names:
groupIdnotgid - Prefer
valovervarfor immutability - Use data classes for models
- Leverage Kotlin coroutines for async operations
Compose Best Practices
- State hoisting: Pass state and events down to composables
- Stateless composables: Keep UI functions pure when possible
- Preview annotations: Add
@Previewfor UI components - Modifier ordering: Size → Padding → Visual effects
- Remember state: Use
rememberfor UI-only state
Dependency Injection with Hilt
Divvy uses Hilt for dependency injection:- Mark Application class with
@HiltAndroidApp(seeDivvyApplication.kt:1) - Annotate ViewModels with
@HiltViewModel - Use
@Inject constructor()for repository dependencies - Register bindings in
@Moduleclasses underdi/
Working with Supabase
Database Schema
Divvy’s Supabase database includes these main tables:profiles- User account informationgroups- Group metadatagroup_members- Group membership junction tableexpenses- Expense recordsexpense_splits- How expenses are dividedledger_entries- Settlement transactions
Row Level Security (RLS)
Supabase RLS policies ensure users can only access their own data:- Users can only read groups they’re members of
- Only group members can create expenses for that group
- Profiles are readable by authenticated users
When adding new tables or modifying queries, ensure RLS policies are properly configured in the Supabase dashboard to prevent data leaks.
Making Queries
Use the Supabase Kotlin SDK via repositories:app/src/main/java/com/example/divvy/backend/SupabaseGroupRepository.kt:1 for real examples.
Feature Flags
Divvy uses feature flags to enable/disable features during development. Configuration:app/src/main/java/com/example/divvy/FeatureFlags.kt:1
local.properties and injected at build time:
Add new feature flags to
FeatureFlags.kt and app/build.gradle.kts as needed for experimental features.Team Workflow
Issue Tracking with Linear
The team uses Linear for project management:- Pick an issue: Check the current sprint and assign yourself to a task
- Update status: Move issues through “Todo”, “In Progress”, “In Review”, “Done”
- Link PRs: Reference Linear issue IDs in commit messages (e.g.,
DIV-123: Add transaction list)
UI Design with Figma
- Check designs first: Before implementing UI, review mockups in Figma
- Match styles: Use the design system defined in
ui/theme/to match Figma specs - Ask questions: If designs are unclear, ping the team on Discord
Communication on Discord
- Daily updates: Share progress and blockers
- Code reviews: Request reviews in the dev channel
- Quick questions: Use Discord for synchronous debugging help
Git Workflow
- Create a feature branch:
git checkout -b feature/transaction-list - Make commits with clear messages:
git commit -m "Add transaction repository" - Push and open a PR:
git push origin feature/transaction-list - Request review from team members
- Merge after approval
Next Steps
- Learn about Testing to ensure code quality
- Review the team contract
- Check out meeting minutes for context on decisions