How nahid1126/book-orbit works
1. What this repo is:
Book Orbit is a single-module Android app built in Kotlin with Jetpack Compose. Architecturally it is organized like a clean/MVVM app inside the app module rather than split into multiple Gradle modules.
2. Top-level layer separation:
The codebase is divided into ui, domain, data, and core. ui owns Compose screens and ViewModels, domain defines repository contracts, data contains the concrete implementations and storage/network adapters, and core holds cross-cutting helpers such as results, logging, enums, constants, and exception utilities.
3. Application bootstrap and DI:
BookOrbit.kt is the app entry point, and dependency wiring is centralized in Koin modules under data/di (AppModule, FirebaseModule, RepositoryModule, ViewModelModule). This is the composition root that connects ViewModels to repository implementations and external services.
4. Presentation layer shape:
The UI is split by feature under ui/presentation: welcome, home, books, book details, gems, profile, and main. Each feature typically has a Compose screen plus a ViewModel, which means state is pushed into the UI via observable state rather than managed directly in composables.
5. Navigation boundaries:
Navigation is handled with Jetpack Compose Navigation in ui/navigation. There are separate navigation graphs for the welcome flow and the main app flow, which implies a gate between onboarding/authentication and the authenticated/book-browsing experience. Destinations.kt centralizes route definitions and type-safe argument passing.
6. Key user flows:
The app appears to start in a splash/welcome path (WelcomeActivity, SplashScreen, LoginScreen) and then transition into the main app (MainActivity, NavGraph). The main experience includes browsing books, opening book details, viewing PDFs, managing gems, checking purchase history, and visiting profile/legal screens.
7. Domain and data contracts:
The domain/repository package defines the repository interfaces for auth, books, gems, and billing. The concrete implementations live in data/repository, which keeps the UI and ViewModels insulated from Firebase, local storage, or billing SDK details.
8. External service integrations:
Firebase is an important backend dependency, evidenced by google-services.json and FirebaseModule. The app also integrates Google Play Billing through BillingRepositoryImpl, supporting gem purchases as a monetization path.
9. Data persistence and models:
Local state/persistence is handled through data/local/AppPreference and type converters. Remote-facing data shapes are defined in data/remote/dto for books, gems, and gem transactions, suggesting the app maps backend or cloud data into app-facing models through repository logic.
10. State and concurrency model:
The app uses Kotlin Coroutines and StateFlow for async work and UI state updates. This makes the data flow one-directional: user actions in Compose screens trigger ViewModel logic, which calls repositories, then emits new state back to the UI.
11. Shared UI and error handling:
Common Compose components such as dialogs, typography helpers, and bullet text live under ui/presentation/component. Shared runtime helpers in core/utils and core/utils/exception standardize result handling and exception translation across features.
12. Architecture diagram summary:
A useful diagram would show: Compose screens at the top, ViewModels beneath them, repository interfaces in the domain layer, repository implementations in the data layer, and then Firebase/local preference/Play Billing as external adapters. The app has two main navigation branches: welcome/auth and authenticated main app, with gems/billing acting as a side business flow connected to the content access experience.
Main entry points: NavGraph.kt Nav graph · di DI modules · BookOrbit.kt BookOrbit · repository Repos
Components 24
App
Android app module and entrypoints
- BookOrbit · Application bootstrap and DI initialization
app/src/main/java/com/nahid/book_orbit/BookOrbit.kt
UI
Compose presentation and navigation
- Welcome · Entry activity for splash and login flow
app/src/main/java/com/nahid/book_orbit/ui/presentation/welcome/WelcomeActivity.kt - Main · Host activity for the authenticated app
app/src/main/java/com/nahid/book_orbit/ui/presentation/main/MainActivity.kt - Nav graph · Main app navigation shell
app/src/main/java/com/nahid/book_orbit/ui/navigation/NavGraph.kt - Welcome graph · Onboarding and login navigation flow
app/src/main/java/com/nahid/book_orbit/ui/navigation/WelcomeNavGraph.kt - Destinations · Central route and argument definitions
app/src/main/java/com/nahid/book_orbit/ui/navigation/Destinations.kt - Login VM · State and actions for login
app/src/main/java/com/nahid/book_orbit/ui/presentation/welcome/login/LoginViewModel.kt - Home VM · State for the home dashboard
app/src/main/java/com/nahid/book_orbit/ui/presentation/home/HomeScreenViewModel.kt - Book VM · State and actions for book details
app/src/main/java/com/nahid/book_orbit/ui/presentation/book_details/BookDetailsViewModel.kt - Gems VM · State for gems and history
app/src/main/java/com/nahid/book_orbit/ui/presentation/gams/GemsViewModel.kt - Billing VM · Purchase flow orchestration
app/src/main/java/com/nahid/book_orbit/ui/presentation/gams/BillingViewModel.kt - Main VM · Shared app-level state
app/src/main/java/com/nahid/book_orbit/ui/presentation/main/MainViewModel.kt - Compose UI · Feature screens, shared components, and theme
app/src/main/java/com/nahid/book_orbit/ui/presentation
Domain
Repository contracts
- Auth repo · Authentication repository interface
app/src/main/java/com/nahid/book_orbit/domain/repository/AuthRepository.kt - Book repo · Book access repository interface
app/src/main/java/com/nahid/book_orbit/domain/repository/BookRepository.kt - Gems repo · Gems balance and history interface
app/src/main/java/com/nahid/book_orbit/domain/repository/GemsRepository.kt - Billing repo · Billing and purchase repository interface
app/src/main/java/com/nahid/book_orbit/domain/repository/BillingRepository.kt
Data
Implementations, persistence, and adapters
- Repos · Concrete repository implementations
app/src/main/java/com/nahid/book_orbit/data/repository - DI modules · Composition root for app wiring
app/src/main/java/com/nahid/book_orbit/data/di - Prefs · App preference and type conversion layer
app/src/main/java/com/nahid/book_orbit/data/local/AppPreference.kt - DTOs · Remote-facing data shapes for books and gems
app/src/main/java/com/nahid/book_orbit/data/remote/dto
Core
Shared runtime helpers
- Core utils · Results, logging, constants, enums, and exceptions
app/src/main/java/com/nahid/book_orbit/core/utils
External
Third-party services
- Firebase · Cloud auth and data backend
- Play Billing · Google Play purchase SDK
Connections 28
- BookOrbit → DI modules: initializes · Application startup wires dependencies
- BookOrbit → Welcome: launches · Entry flow starts in welcome path
- BookOrbit → Main: hosts · Authenticated flow enters main activity
- Welcome → Welcome graph: uses · Welcome activity renders onboarding graph
- Main → Nav graph: uses · Main activity hosts app navigation
- Nav graph → Destinations: routes · Navigation graph consumes central route definitions
- Welcome graph → Destinations: routes · Welcome flow uses shared destinations
- Welcome graph → Login VM: binds · Login state is provided by ViewModel
- Nav graph → Home VM: binds · Home screen state comes from ViewModel
- Nav graph → Book VM: binds · Book details screen uses ViewModel
- Nav graph → Gems VM: binds · Gems and history screens use ViewModel
- Nav graph → Billing VM: binds · Purchase flow uses billing ViewModel
- Nav graph → Main VM: binds · Shared app state is owned by main ViewModel
- Login VM → Auth repo: depends on · Authentication logic is abstracted behind contract
- Home VM → Book repo: depends on · Book browsing reads through repository contract
- Book VM → Book repo: depends on · Book detail retrieval goes through contract
- Gems VM → Gems repo: depends on · Gems balance and history come from contract
- Billing VM → Billing repo: depends on · Purchase flow delegates to billing contract
- Main VM → Auth repo: depends on · App-level state may depend on auth status
- DI modules → Auth repo: provides · Koin binds contract to implementation
- DI modules → Book repo: provides · Koin binds contract to implementation
- DI modules → Gems repo: provides · Koin binds contract to implementation
- DI modules → Billing repo: provides · Koin binds contract to implementation
- Repos → Firebase: reads/writes · Repository implementations integrate with backend
- Repos → Prefs: persists · Repository implementations use local storage
- Repos → DTOs: maps · Repository implementations map remote data shapes
- Billing repo → Play Billing: adapts · Billing implementation wraps Google Play Billing
- Compose UI → Core utils: uses · Shared UI and runtime helpers support features