Skip to content

BugraDemiral/SpaceXApp

Repository files navigation

SpaceXApp

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.


📊 Architecture Overview

Presentation (Compose UI + ViewModel) <-- StateFlow --> Domain (UseCases + Models) <---> Data (DTOs + Repositories + Retrofit)

The project is structured around Clean Architecture with the following layers:

1. Domain Layer

  • Contains business logic and app-specific models.
  • Exposes interfaces (LaunchRepository) and use cases (GetUpcomingLaunchesUseCase, GetLaunchDetailsUseCase).

2. Data Layer

  • 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.

3. Presentation Layer

  • Built with Jetpack Compose.
  • Implements MVI (Model-View-Intent) using a LaunchViewModel, LaunchIntent, and LaunchState.
  • UI screens: LaunchListScreen and LaunchDetailScreen

4. Core Layer

  • Contains common modules such as NetworkModule (DI setup for Retrofit, OkHttp, and repositories).

🛠️ How It Works

  1. LaunchListScreen

    • On app start, LaunchIntent.LoadLaunches is dispatched.
    • LaunchViewModel handles the intent and invokes GetUpcomingLaunchesUseCase.
    • The result is displayed in a LazyColumn list.
  2. Navigation

    • Tapping a launch item navigates to LaunchDetailScreen via NavController.
  3. LaunchDetailScreen

    • Dispatches LaunchIntent.LoadDetails(launchId).
    • Launch details are fetched and displayed including a patch image via Coil.

💪 Tech Stack

  • Jetpack Compose for UI
  • Kotlin + Coroutines + Flow
  • Retrofit + OkHttp for networking
  • Hilt for dependency injection
  • MockK for unit testing
  • Coil for image loading

Secure Practices

  • FLAG_SECURE used to prevent screenshots in production
  • Logging is disabled in release builds

📊 Libraries Used

  • androidx.compose.* – Jetpack Compose UI toolkit
  • androidx.navigation:navigation-compose – Navigation with Compose
  • androidx.lifecycle:lifecycle-viewmodel-compose – ViewModel integration
  • org.jetbrains.kotlinx:kotlinx-coroutines-core – Coroutines support
  • org.jetbrains.kotlinx:kotlinx-coroutines-android – Main dispatcher
  • androidx.hilt:hilt-navigation-compose – Navigation injection
  • com.google.dagger:hilt-android – DI framework
  • com.squareup.retrofit2:retrofit – HTTP client
  • com.squareup.okhttp3:okhttp – HTTP networking
  • io.coil-kt:coil-compose – Async image loading
  • io.mockk:mockk – Mocking for unit tests
  • app.cash.turbine:turbine – Flow testing

✅ Test Coverage

  • ViewModel unit tests using runTest, flowOf, and coEvery
  • Clean separation of concerns makes the app easy to test

⚡ Getting Started

  1. Clone the repo
  2. Open in Android Studio (Electric Eel or later)
  3. Ensure Gradle sync succeeds
  4. Run the app on device/emulator

Build Instructions

./gradlew clean build
./gradlew test

Run Tests

./gradlew testDebugUnitTest

🌐 API Reference

  • Base URL: https://api.spacexdata.com/v4/
  • Endpoints:
    • /launches/upcoming
    • /launches/{id}

🚀 Future Improvements

  • Pagination for launches
  • Pull-to-refresh
  • Offline caching
  • Rocket details screen

👤 Author

Built by M. Bugra Demiral, powered by Kotlin ✨


🎯 License

[MIT License] - feel free to use and improve!

About

A SpaceX launch explorer using Jetpack Compose and Clean Architecture

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages