Skip to content

Marvel at the sheer scale of the Universe with this Compose Multiplatform app. Featuring Clean Architecture, MVI and a custom paging solution.

License

Notifications You must be signed in to change notification settings

1sao/Space-Cards-Multiplatform

Repository files navigation

Space Cards Multiplatform

Marvel at the sheer scale of the Universe with the convenience of your favorite doomscrolling app. Built with Compose Multiplatform, powered by Astrobin.

feed_mobile.mp4
liked_mobile.mp4

Feed Liked

🚀 Features

  • Fancy Tinder-like UI
  • Offline-first approach
  • Flexible and scalable implementation of Clean Architecture with minimal boilerplate
  • Custom paging solution (because Paging3 is not great!)
  • Custom MVI-focused ViewModel (the default one is fine — I just wanted to try building my own!)
  • Full Android support, basic desktop support (usable but lacks desktop-specific interactions)

🔍 Overview

Architecture

It's an implementation of Clean Architecture, modularized by feature. The project is divided into feature (UI) and component (domain, data, data source) modules. ViewModels can be injected with repository interfaces located in the domain directly, avoiding useless use case wrappers around repository methods when they are not necessary.

Sources:

MVI

A custom MviViewModel ensures all work is paused when the app is in the background, preventing unnecessary battery drain when polling for geolocation data, remote data sources, etc.

Paging

The first rule about Paging3: dont use Paging3

(C) Multiple users on Reddit, aka unexpectedly the only place to offer info on Paging3 beyond the limited official doc.

I've built a custom paging solution that supports multiple data sources, offline mode, real-time updates, and both key- and page-based paging. It still has some TODOs, and I wouldn’t claim it's completely fail-safe, but it should handle most cases you throw at it. For me, it's vastly more manageable than Paging3.

This solution is available as a separate module, pager, in the project. Feel free to copy and tweak it to your liking, or use it as inspiration for your own implementation.

Exception handling

Errors that we expect and should handle are represented as a sealed interface hierarchy, wrapped at the data source level. Other modules are exception-free.

Sources:

Testing

I got lazy, so no tests!

I have opinions on testing though. Kotest allows for more readable and concise tests, but historically, its runner has always had issues with Android. To my dismay, this still holds true even for multiplatform modules targeting Android as one of the platforms, so I’d avoid it for now. Instead, I would use Junit5 with just Kotest Assertions.

I would prioritize testing ViewModels with faked data, so that a test encompasses a ViewModel, a UseCase, a Repository, and potentially even a data source — depending on how you mock them. (For example, using a manually pre-populated in-memory database for SQLDelight and MockEngine for Ktor Client.) I would consider sprinkling in some screenshot tests. Everything else should ideally be tested via automated UI tests with no mocks at all.

Sources:

🛠️ Tech Stack

⚙️ Development Setup

Code style

This project uses ktlint, integrated via the spotless gradle plugin, and a custom code style. Installing the ktlint extension for your IDE is the easiest way to use ktlint. Optionally, you can enable the pre-commit git hook ( ~/spotless/pre-commit). Installation instructions are inside the file.

API keys

Get your Astrobin API key and secret here and paste them into ~/.secrets.properties:

ASTROBIN_API_KEY=[...]
ASTROBIN_API_SECRET=[...]

💙 Special Thanks

  • Astrobin for serving as the backend for this app
  • Denis Brandi for awesome articles on Clean Architecture
  • Quantum fluctuations for originating the large-scale structure of the Universe by introducing a non-uniformity in energy distribution during cosmic inflation

📝 License

Distributed under the MIT License. See LICENSE for more information.

About

Marvel at the sheer scale of the Universe with this Compose Multiplatform app. Featuring Clean Architecture, MVI and a custom paging solution.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages