How tbsten/android-project-template works
Main Components
• App Module: This is the main Android application module (found under the “app” directory) that contains the entry points such as MainActivity, AppNavHost, and MainApplication.
• UI Module: The “ui” folder is further divided into submodules like designSystem, feature (with multiple features such as example screens for counter, API post lists, and local Db user lists), and navigation. This layer is responsible for the presentation layer using Jetpack Compose.
• Domain Module: The “domain” folder contains business logic, use cases, and domain models. It is split into sub-modules like error handling and feature-specific business processes (e.g., posts, users).
• Data Module: The “data” directory is split into multiple submodules:
• API: Contains Retrofit, okhttp, and generated API interfaces using OpenAPI generator.
• Database: Uses Room; it includes the Room database classes, DAOs, and database schemas.
• Preferences: Contains the DataStore or other managed key-value stores for preferences.
• Example implementations for repository interfaces that link the data sources to the domain.
• Common Module: Contains cross-cutting utilities and common code used throughout the app (e.g., logging, lazy delegates).
• Build Logic: The “buildLogic” directory houses the customized Gradle scripts and plugins that standardize module configuration (e.g., AndroidLibraryModulePlugin, ComposeDsl, HiltPlugin) and enforce code quality with Ktlint, Detekt, and Roborazzi.
• Tools (Debug): The “tools/debug” module includes a debug menu and related UI components that facilitate in-app debugging.
Out the Interactions and Relationships
• UI Layer to Domain Layer:
• UI screens (Compose UIs, ViewModels) initiate user-driven actions.
• Each UI component (for example, the ExampleApiPostListScreen, ExampleCounterScreen, etc.) uses a ViewModel that triggers Use Cases from the domain layer.
• Domain Layer to Data Layer:
• The Use Cases in “domain” invoke repository interfaces. For example, the “GetPostsUseCase” and its implementation interact with the repositories provided by the “data” modules.
• The Data layer abstracts how data flows from persistence (Room in “data/database”), remote (Retrofit in “data/api”), or preferences (DataStore in “data/preferences”).
• External Dependencies & Frameworks:
• Use of Dagger Hilt for dependency injection across modules.
• Jetpack Compose supports declarative UI.
• Error handling from the domain/error module is integrated to provide consistent error states throughout the app.
• Build and Quality:
• BuildLogic and configuration scripts ensure consistent build behavior and module separation.
• CI integrations with Github Actions (as specified in the README and workflows) set up automated testing and validation.
• Debugging Support:
• The debug tool module under “tools/debug” integrates a debug menu that is dynamically available for troubleshooting during development builds.
Architectural Patterns and Technical Stack Highlights
• MVVM Architecture: The project has a clear separation between the presentation (UI/ViewModel), domain (use cases and business logic), and data (repository implementations) layers.
• Dependency Injection: Dagger Hilt manages dependencies throughout the application.
• Modularization: The project is split into clear modules (app, common, data, domain, ui) to facilitate separation of concerns and easier scalable development.
• Build Customization: Extensive use of Gradle scripts and custom DSLs under buildLogic, enforcing standards and project-wide configurations.
• External Libraries: Retrofit + OkHttp for HTTP, Room for local database management, and Jetpack Compose for the UI.