SpaceXApp is a modern Android application built using Jetpack Compose and Clean Architecture. It fetches upcoming space launches from the SpaceX API and displays launch details in a clean, user-friendly interface.
Presentation (Compose UI + ViewModel) <-- StateFlow --> Domain (UseCases + Models) <---> Data (DTOs + Repositories + Retrofit)
The project is structured around Clean Architecture with the following layers:
- Contains business logic and app-specific models.
- Exposes interfaces (
LaunchRepository
) and use cases (GetUpcomingLaunchesUseCase
,GetLaunchDetailsUseCase
).
- Implements the domain layer contracts.
- Fetches data via Retrofit from the SpaceX API.
- Uses DTOs (
LaunchDto
,LinksDto
,PatchDto
) and mappers to transform API responses into domain models.
- Built with Jetpack Compose.
- Implements MVI (Model-View-Intent) using a
LaunchViewModel
,LaunchIntent
, andLaunchState
. - UI screens:
LaunchListScreen
andLaunchDetailScreen
- Contains common modules such as
NetworkModule
(DI setup for Retrofit, OkHttp, and repositories).
-
LaunchListScreen
- On app start,
LaunchIntent.LoadLaunches
is dispatched. LaunchViewModel
handles the intent and invokesGetUpcomingLaunchesUseCase
.- The result is displayed in a
LazyColumn
list.
- On app start,
-
Navigation
- Tapping a launch item navigates to
LaunchDetailScreen
viaNavController
.
- Tapping a launch item navigates to
-
LaunchDetailScreen
- Dispatches
LaunchIntent.LoadDetails(launchId)
. - Launch details are fetched and displayed including a patch image via Coil.
- Dispatches
- Jetpack Compose for UI
- Kotlin + Coroutines + Flow
- Retrofit + OkHttp for networking
- Hilt for dependency injection
- MockK for unit testing
- Coil for image loading
- FLAG_SECURE used to prevent screenshots in production
- Logging is disabled in release builds
androidx.compose.*
– Jetpack Compose UI toolkitandroidx.navigation:navigation-compose
– Navigation with Composeandroidx.lifecycle:lifecycle-viewmodel-compose
– ViewModel integrationorg.jetbrains.kotlinx:kotlinx-coroutines-core
– Coroutines supportorg.jetbrains.kotlinx:kotlinx-coroutines-android
– Main dispatcherandroidx.hilt:hilt-navigation-compose
– Navigation injectioncom.google.dagger:hilt-android
– DI frameworkcom.squareup.retrofit2:retrofit
– HTTP clientcom.squareup.okhttp3:okhttp
– HTTP networkingio.coil-kt:coil-compose
– Async image loadingio.mockk:mockk
– Mocking for unit testsapp.cash.turbine:turbine
– Flow testing
- ViewModel unit tests using
runTest
,flowOf
, andcoEvery
- Clean separation of concerns makes the app easy to test
- Clone the repo
- Open in Android Studio (Electric Eel or later)
- Ensure Gradle sync succeeds
- Run the app on device/emulator
./gradlew clean build
./gradlew test
./gradlew testDebugUnitTest
- Base URL:
https://api.spacexdata.com/v4/
- Endpoints:
/launches/upcoming
/launches/{id}
- Pagination for launches
- Pull-to-refresh
- Offline caching
- Rocket details screen
Built by M. Bugra Demiral, powered by Kotlin ✨
[MIT License] - feel free to use and improve!