The Movie App
A Jetpack Compose client for the TMDB API: browse, debounced search, favorites, Firebase auth, and offline caching.
Native movie browser powered by the TMDB API
The Movie App is a modern Android application built with Jetpack Compose that leverages the TMDB API to showcase popular, now playing, and top-rated movies. It adds Firebase email/password authentication, a persistent Favorites watchlist, personalized recommendations, and cached reads with a stale fallback on top of a clean Material 3 design with DataStore-backed preferences.
Single Activity
All navigation handled within one MainActivity using Navigation Compose.
Manual DI
Repositories (Movie, Preferences, Watchlist, Auth) and services are provisioned by MovieApplication and injected into ViewModels via factories.
This app demonstrates a full client-server Android workflow: fetching real movie data from the TMDB REST API, rendering it with a reactive Compose UI, and persisting user preferences with DataStore — all wrapped in a clean MVVM architecture with type-safe navigation.
Core Features
- Browse Popular, Now Playing, and Top Rated sections, plus single-category grids with infinite scroll
- "Because you like X" recommendations derived from your favorite genre
- Debounced live search with pagination
- Movie details with pull-to-refresh, offline fallback, and a favorite heart toggle with snackbar confirmations
- Persistent Favorites/Watchlist tab
- Firebase Email/Password auth — your signup name becomes your in-app display name
- Profile overview with Settings in the top bar; Settings edits name, bio, and genre picked from the official TMDB list
- Offline support (HTTP disk cache + in-memory cache with stale fallback), pull-to-refresh, and specific error messages with retry
Caching, identity, and where state lives
The Movie App is a client for someone else's API. Its useful engineering is in how it reduces repeated network work, handles a failed request, and keeps a small watchlist without adding a server.
Two cache layers with different jobs
- Context
- TMDB responses are slow and the app should still show something when the network drops.
- Choice
- OkHttp keeps a 10 MB disk cache in cacheDir. MovieRepository keeps a five-minute in-memory TTL cache for first pages and detail responses and falls back to stale cached data on failure.
- Trade-off
- Cached reads are fast and survive transient failures, but only page one is cached in memory, deeper pages always hit the network, and the memory cache is lost on process death.
The API key is attached in an interceptor
- Context
- TMDB authenticates requests with an API key and the client must not leak it into release logs.
- Choice
- An OkHttp interceptor appends api_key from BuildConfig. The logging interceptor runs at BASIC in debug and NONE in release.
- Trade-off
- The key stays out of logcat, but any key shipped in an APK can be extracted. A backend proxy would be the stronger boundary. Not implemented.
Watchlist is a JSON list in DataStore
- Context
- The watchlist is a small, user-local set of movies and does not need a server account.
- Choice
- WatchlistRepository serialises List<Movie> to JSON in Preferences DataStore and exposes it as a Flow, with toggle, remove, and clear operations.
- Trade-off
- No database schema or migration burden, but every toggle rewrites the whole list and the watchlist does not sync across devices.
Firebase Auth owns identity, DataStore owns profile fields
- Context
- The app needs sign-up, login, password reset, and a display name, plus editable profile text and a favourite genre.
- Choice
- AuthRepository wraps FirebaseAuth in a callbackFlow. Name, bio, favourite genre, and theme live in a separate DataStore-backed PreferencesRepository.
- Trade-off
- Auth state is reactive and profile edits stay local, but the two sources can disagree and there is no server-side profile record. Email verification and Google sign-in are roadmap items, not shipped.
TMDB responses and local profile state
The DTOs follow TMDB's response shape, while the watchlist and profile preferences are stored locally. Auth state is a separate reactive stream from Firebase.
| Entity | Important fields | Responsibility | Note |
|---|---|---|---|
| Movieserializable DTO | Fieldsid, title, overview, posterPath, backdropPath, releaseDate, voteAverage, voteCount, genreIds, originalLanguage, originalTitle, popularity | ResponsibilityList, search, and watchlist card data, with computed posterUrl and backdropUrl. | NoteThis is also the shape serialised into the DataStore watchlist. |
| MovieApiResponseserializable DTO | Fieldspage, results, totalPages, totalResults | ResponsibilityThe paginated envelope returned by TMDB list and search endpoints. | NoteOnly first-page results are kept in the in-memory cache. |
| MovieDetailserializable DTO | Fieldsid, title, overview, runtime, tagline, status, genres, releaseDate, voteAverage, posterPath, backdropPath | ResponsibilityDetail-screen data, including genre names and runtime. | NoteCached per movie ID for five minutes with a stale fallback. |
| Genreserializable DTO | Fieldsid, name | ResponsibilityGenre labels on a movie detail response and the favourite-genre selector. | NoteThe app also maps genre names to TMDB IDs for recommendations. |
| AuthState / AuthUserruntime state | FieldsLoading, SignedOut, SignedIn(user: uid, displayName, email, photoUrl) | ResponsibilityReactive Firebase session state consumed by the profile and auth screens. | NoteProduced from a FirebaseAuth AuthStateListener wrapped in callbackFlow. |
| UserPreferencesDataStore | FieldsthemeMode, defaultCategory, displayName, bio, favoriteGenre | ResponsibilityLocal appearance and profile preferences. | NoteSeparate from the Firebase user record. |