A modern, scalable Android application template designed for collaborative development. Built with Clean Architecture, Jetpack Compose, and Offline-First principles, this project serves as a robust foundation for browsing movies and managing a watchlist using the TMDB API.
Movies DB is an Android application built with Kotlin and Jetpack Compose. It implements the 'Single Source of Truth' principle using Hilt, Retrofit, and Room, ensuring consistent data flow from the repository to the UI.
The application follows the recommended Clean Architecture guide by Google, separating concerns into three distinct layers:
graph TD
UI["UI Layer<br/>(Compose + ViewModel)"] --> Domain["Domain Layer<br/>(UseCases + Models)"]
Domain --> Data["Data Layer<br/>(Repository Implementation)"]
Data --> Remote["Remote Source<br/>(Retrofit + TMDB API)"]
Data --> Local["Local Source<br/>(Room Database)"]
- UI Layer: Handles user interaction and displays data using Jetpack Compose.
- Domain Layer: Contains pure Kotlin business logic and defines the data contracts (Repositories).
- Data Layer: Orchestrates data fetching, managing the decision to load from the local cache or the network.
- π¬ Browse Movies: Discover popular, top-rated, and upcoming movies.
- β€οΈ Watchlist: Save movies locally to a favorites list.
- π Detail View: Deep dive into movie synopsis, release dates, and cast.
- π± Adaptive UI: Built with Material3 to look great on all device sizes.
- Offline Support: Uses Room to cache data, allowing the user to see their watchlist without an internet connection.
- Dependency Injection: Fully modularized with Hilt for testability and scalability.
- Reactive Data Flow: Built entirely on Kotlin Coroutines and Flow.
- Modern Navigation: Type-safe navigation with Jetpack Navigation Compose.
- Language: Kotlin (v2.0.21)
- UI Toolkit: Jetpack Compose (Material3)
- Dependency Injection: Hilt
- Networking: Retrofit + OkHttp (DNS over HTTPS support)
- Serialization: Gson
- Database: Room (SQLite)
- Image Loading: Coil
- Build System: Gradle with Version Catalogs (
libs.versions.toml)
Follow these steps to set up your local development environment.
- Android Studio: Koala/Ladybug (2024.1) or newer.
- Java Development Kit (JDK): Version 17 or higher.
- TMDB Account: You need an API key from The Movie Database.
- Get your Key: Log in to TMDB and generate an API Key in your account settings.
- Configure Local Properties:
Create a file named
local.propertiesin the root directory (if it doesn't exist) and add:Note: The app will fail to build or fetch data if this key is missing.sdk.dir=/path/to/your/android/sdk API_KEY="your_actual_tmdb_api_key_here"
Open the project in Android Studio and sync Gradle. Then, use the following commands or the IDE buttons:
# Clean the project
./gradlew clean
# Build the Debug APK
./gradlew assembleDebug
# Run Unit Tests
./gradlew testDebugUnitTest
# Run Instrumented (UI) Tests
./gradlew connectedDebugAndroidTestWe follow a strict separation of concerns. Here is where everything lives:
com.example.movies_db
βββ di <-- Dependency Injection Modules (How to create Retrofit/Room)
βββ data
β βββ local <-- Room Database files (DAO, Entities)
β βββ remote <-- Retrofit files (ApiService, DTOs)
β βββ repository <-- The bridge between Data and UI
βββ domain
β βββ model <-- Pure data classes (Movie, User)
β βββ repository <-- Interface definitions (What data we need)
β βββ usecase <-- Specific business logic units
βββ network
β βββ DnsClient.kt <-- DNS and Network Interceptors
βββ ui
β βββ theme <-- Colors, Type, Shapes
β βββ components <-- REUSABLE widgets (MovieCard, TopBar)
β βββ navigation <-- NavHost and Screen Routes
β βββ screens <-- FULL PAGES (HomeScreen, DetailScreen)
βββ TeamApp.kt <-- The Hilt Application Class
This project is set up as a foundation. Here is how you contribute features:
- Define Domain: Create the Model and Repository Interface in
domain/. - Implement Data: Create the DTOs in
data/remoteand Entities indata/local. Implement the Repository indata/repository. - Create UI: Build the Screen in
ui/screensand ViewModel. - Register Route: Add the new screen to
ui/navigation/AppNavigation.kt. - Inject: Provide any necessary dependencies in
di/modules.
We use Room for local storage.
- Entities: defined in
data/local/MovieEntity.kt. - DAOs: defined in
data/local/MovieDao.kt. - Migrations: If you modify an Entity, update the database version in
MovieDatabase.ktand provide a migration strategy.
The project uses a standard local.properties file for secret management.
| Variable | Description | Required |
|---|---|---|
API_KEY |
Your TMDB v3 API Key | β Yes |
sdk.dir |
Path to Android SDK | β Yes |
We welcome contributions from the team!
- Fork the repository (or create a branch if internal).
- Create a Feature Branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'Add amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.