Architecture Principles
The app is structured around three core architectural principles:- Separation of Concerns: Each layer has a distinct responsibility
- Dependency Inversion: Dependencies point inward toward the domain layer
- Testability: Business logic is independent of Android framework
Layer Structure
The application is organized into three main layers:Presentation
UI components, ViewModels, and user interaction logic
Domain
Business logic, use cases, and domain models
Data
Data sources, repositories, and API clients
Package Structure
The codebase is organized into the following packages:Data Flow
The typical data flow through the architecture follows this pattern:Core Components
Resource Wrapper
The app uses a sealed class to represent operation states:com/bsvillarraga/spaceflightnews/core/common/Resource.kt
The
Resource class provides a type-safe way to handle loading, success, and error states throughout the application.Dependency Injection
The app uses Dagger Hilt for dependency injection, configured at the application level:com/bsvillarraga/spaceflightnews/MyApp.kt:4-7
Key Features
Clean Architecture
Clean Architecture
- Clear separation between layers
- Business logic independent of frameworks
- Easy to test and maintain
Reactive Programming
Reactive Programming
- Kotlin Coroutines for asynchronous operations
- LiveData and StateFlow for reactive UI updates
- Flow-based search with debouncing
Dependency Injection
Dependency Injection
- Dagger Hilt for compile-time dependency injection
- Singleton components for shared resources
- Constructor injection for testability
Type Safety
Type Safety
- Kotlin’s type system for compile-time safety
- Domain models separate from DTOs
- Sealed classes for state management
Next Steps
Clean Architecture
Deep dive into the three-layer architecture
Dependency Injection
Learn how Dagger Hilt is configured