How josealcerreca/android-architecture works
Based on your provided file tree and README, you’re working with an Android sample project that demonstrates modern architectural practices for Android app development. This To-Do app is built using Jetpack Compose for the UI, follows a single-activity and navigation-compose pattern, relies on ViewModels paired with reactive streams (via Flow and Coroutines), and uses Hilt for dependency injection. It also features a clearly defined data layer—with a repository that abstracts local (Room) and network (a fake remote data source) operations—and a comprehensive suite of tests (unit, integration, and end-to-end).
Main Components
• UI/Presentation Layer:
• Compose Screens (e.g., TasksScreen, AddEditTaskScreen, TaskDetailScreen, StatisticsScreen)
• Navigation: Single Activity with Navigation Compose, which handles screen transitions (e.g., TodoActivity, TodoNavGraph)
• ViewModels: Each screen has an associated ViewModel that manages UI state (e.g., TasksViewModel, AddEditTaskViewModel)
• Data Layer:
• Repository: Abstracts data access (e.g., DefaultTaskRepository)
• Data Sources:
▪ Local Data Source: Using Room database (e.g., ToDoDatabase, TaskDao, LocalTask)
▪ Network Data Source: A fake or simulated remote data source (e.g., NetworkTaskDataSource, NetworkDataSource)
• Model Mapping and Domain Models: Entities like Task and mapping extensions
• Dependency Injection:
• Hilt is used to inject dependencies across layers, as seen with modules such as DataModules, CoroutinesModule
• Test-specific dependency modules also exist (e.g., in the shared-test directory)
• Configuration and Build:
• Gradle build scripts, product flavors (mock and prod), and CI configurations (GitHub workflows)
• Testing:
• A broad test suite that includes unit tests for viewmodels and repository logic, integration tests for data sources, and UI tests (both instrumented and shared tests)
Component Relationships/Interactions
• The UI layer (Compose screens) sends user actions to its corresponding ViewModel.
• The ViewModel interacts with the repository from the data layer to fetch/update task data.
• The repository decides whether to use the local data source (Room database) or the network data source.
• Hilt mediates dependency injection, ensuring that each layer receives the proper instances without manual wiring.
• Automated tests exercise components in isolation (unit tests) or in integration (UI and shared tests).
• Separation of Concerns: Clearly distinguish between presentation (UI/Compose screens, navigation, ViewModels), business/data logic (Repository), and data sources (local and network).
• Reactive Programming: Incorporate Flow and Coroutines for asynchronous data handling.
• Modularization: Highlight the presence of shared test modules and how product flavors facilitate build variants for testing vs. production.
Technologies, Frameworks, and Tools
• Jetpack Compose, Navigation Compose for building and managing UI.
• Room for local storage, coupled with DAOs.
• Kotlin Coroutines and Flow for asynchronous operations.
• Hilt for dependency injection.
• Gradle for build configuration.
• Testing frameworks for unit, UI/instrumented tests, and shared tests.