This guide helps you structure your project in a scalable and maintainable way.
Dependency Injection modules.
- Declare all injected classes using Hilt.
- Use
AppModulefor general app-wide dependencies. - Create feature-specific modules like
NetworkModule,StorageModule, etc.
User interface components.
- All screens, composables, and fragments go here.
- Organize screens into folders by feature (e.g.,
login/,home/). - Screen files should be suffixed with
Screen, e.g.LoginScreen.kt.
All network-related logic.
ApiService.kt– Retrofit API interfaceAuthInterceptor.kt,LoggingInterceptor.kt- Optional:
ApiClient.ktif you're not using Hilt modules
State and logic for each screen.
- All
ViewModelclasses go here - Use Hilt for injection
- Name format:
HomeViewModel.kt,LoginViewModel.kt
Everything related to data management.
- Contains repository interfaces and implementations
- Suffix with
Repository, e.g.,UserRepository.kt - Should be the only layer accessing both local + remote data
- Contains local data sources like
DataStore,SharedPreferences, or Room DAOs
- DTOs, entities, and model classes used across the app
Navigation structure and route definitions.
Route.kt– all route constantsAppNavHost.kt– root navigation host- Feature-specific graphs like
HomeNavGraph.kt,AuthNavGraph.kt
Generic helper classes.
- Extensions
- Mappers
- Other utilities that don’t fit in other categories
- 📝 Avoid hardcoded strings – Use
strings.xmland access them viastringResource(R.string.some_text) - 🧼 Don’t access
ApiServiceorDataStoredirectly in ViewModels – Use a Repository instead for clean separation of concerns. - use Enums for constants like
Status,Type, etc, avoid STRINGS, INTS, etc.