Clean Architecture layers
The application is organized into three primary layers, each with specific responsibilities:Presentation layer
Presentation layer
Contains all UI-related code including Jetpack Compose screens, ViewModels, and UI state management.Location:
presentation/Key components:- Composable UI screens (
presentation/screen/) - ViewModels extending
BaseViewModel(presentation/screen/*/viewmodel/) - UI state, events, and actions
- Navigation graphs (
navigation/graph/)
Domain layer
Domain layer
The core business logic layer containing use cases, repository interfaces, and domain models. This layer has no Android dependencies.Location:
domain/Key components:- Use cases implementing
BaseUseCase(domain/use_case/) - Repository interfaces (
domain/repository/) - Domain models (
domain/model/) - Business logic and validation
Data layer
Data layer
Manages data sources including Room database, DataStore, and external APIs. Implements repository interfaces from the domain layer.Location:
data/Key components:- Repository implementations
- Room database and DAOs (
data/local/dao/) - Entity models (
data/local/model/) - Mappers for data transformation (
data/local/mapper/)
Project structure
Here’s the complete directory structure of GemAI:MVVM pattern implementation
GemAI uses the MVVM pattern with Unidirectional Data Flow (UDF) for predictable state management:Unidirectional Data Flow ensures that:
- State flows down from ViewModel to UI
- Actions flow up from UI to ViewModel
- Events are one-time occurrences (navigation, toasts, etc.)
Dependency injection with Hilt
GemAI uses Hilt for dependency injection, providing a clean way to manage dependencies:Dependency flow
The architecture enforces strict dependency rules:Next steps
Core components
Learn about base classes, use cases, and AI models
Data layer
Explore Room database, repositories, and data flow
Extending GemAI
Add new features while maintaining architecture