Skip to content

g-enius/Fun-Android

Repository files navigation

Fun - Android Demo App

CI

A modern Android application demonstrating clean architecture (MVVM), Jetpack Compose, multi-module design, and best practices for scalable Android development. Android counterpart of the Fun iOS app.

Screenshots

Home Detail Profile Settings
Home Detail Profile Settings

Tech Stack

Category Technology
Language Kotlin 2.1.10
UI Framework Jetpack Compose (Material 3)
Reactive & Concurrency Kotlin Coroutines, StateFlow
Architecture MVVM + Navigation Compose
Dependency Injection Manual (ViewModelFactory)
Build System Gradle 8.13, Version Catalog
Minimum SDK API 26 (Android 8.0)
Target SDK API 35 (Android 15)
Testing JUnit 5, MockK, Turbine

Module Structure

Fun-Android/
├── app/                        # Application entry point, DI wiring
├── model/                      # Data models (Item, UserProfile, etc.)
├── platform/
│   ├── ui-components/          # Theme, shared composables, ViewModelFactory
│   └── navigation/             # NavGraph, bottom tab navigation
├── services/
│   ├── network/                # Network service interface + mock implementation
│   ├── favorites/              # Favorites service (SharedPreferences-backed)
│   ├── search/                 # Search service (delegates to network)
│   └── ai/                     # AI summary service
└── features/
    ├── login/                  # Login screen
    ├── home/                   # Home tab (item list + favorites)
    ├── search/                 # Search (debounced query)
    ├── items/                  # Items tab (filtered items)
    ├── profile/                # Profile screen (via top-bar icon)
    ├── profile-detail/         # Profile detail screen
    ├── detail/                 # Item detail screen
    └── settings/               # Settings tab (feature toggles)

16 modules total. All modules except app are Android library modules.

Dependency Hierarchy:

app → navigation → features/* → services/* → model
         └──────→ ui-components ──────────────┘

Key Patterns

MVVM + Navigation Compose

  • ViewModel: Business logic, StateFlow-based state management
  • Screen: Composable that creates ViewModel, collects state
  • Content: Pure UI composable (stateless, previewable)
  • Navigation: Single NavHost with bottom tab screen + detail routes

Manual Dependency Injection

Services are created lazily in MainActivity and passed through the composable tree via function parameters. No framework (Hilt/Koin/Dagger) needed for a demo app.

// MainActivity.kt
private val networkService by lazy { DefaultNetworkService(simulateErrors = appSettings.simulateErrorsEnabled) }
private val favoritesService by lazy { DefaultFavoritesService(sharedPreferences) }
private val searchService by lazy { DefaultSearchService(networkService) }
private val aiService by lazy { DefaultAiService() }

Screen/Content Split

Every feature follows the same pattern for testability and preview support:

// Screen.kt - ViewModel creation + state collection
@Composable
fun HomeScreen(networkService: NetworkService, ...) {
    val viewModel: HomeViewModel = viewModel(factory = viewModelFactory { ... })
    val state by viewModel.state.collectAsStateWithLifecycle()
    HomeContent(state = state, onRefresh = viewModel::onRefresh, ...)
}

// Content.kt - Pure UI, no ViewModel dependency
@Composable
internal fun HomeContent(state: HomeState, onRefresh: () -> Unit, ...) { ... }

Atomic State Updates

All ViewModels use MutableStateFlow.update {} for thread-safe, atomic state mutations:

_state.update { current ->
    current.copy(items = current.items.map { ... })
}

Features

  • 3-Tab Navigation: Home, Items, Settings (Profile via top-bar icon)
  • Detail Screens: Item detail with favorite toggle, profile detail with back navigation
  • Reactive Favorites: SharedPreferences-backed, observed via StateFlow across all screens
  • Feature Toggles: Runtime flags that control app behavior (featured carousel, error simulation, AI summary)
  • AI Summary: On-device summarisation on item detail screen
  • Material 3 Theming: Dynamic color support, light/dark mode
  • Error Handling: Loading/error/content states with retry support
  • Pull-to-Refresh: On applicable screens

Navigation

NavHost
├── "main" → MainTabScreen (3 tabs)
│   ├── Tab 0: HomeScreen (profile icon → ProfileScreen)
│   ├── Tab 1: ItemsScreen
│   └── Tab 2: SettingsScreen
├── "detail/{itemId}" → DetailScreen
└── "profile/{userId}" → ProfileDetailScreen

Testing

  • Unit Tests: JUnit 5 + MockK + Coroutines Test
  • 53 tests across 7 ViewModels
  • Coroutine testing: StandardTestDispatcher + advanceUntilIdle
./gradlew test

Getting Started

Requirements

  • Android Studio Ladybug (2025.3.1+)
  • JDK 17+
  • Android SDK 35

Installation

git clone https://github.com/g-enius/Fun-Android.git
cd Fun-Android

Running

  1. Open project in Android Studio
  2. Sync Gradle
  3. Select app configuration
  4. Choose emulator or device
  5. Run (Shift + F10)

Build from Command Line

./gradlew assembleDebug
./gradlew installDebug    # install on connected device/emulator
./gradlew test            # run unit tests

AI-Assisted Development

This project demonstrates AI-assisted Android development using Claude Code.

Architecture and patterns designed by developer. Claude assisted with:

  • Full project scaffolding (16 modules)
  • Feature implementation
  • Code review (5-agent parallel review)
  • Bug fixes (atomic StateFlow, nav safety, padding)
  • Test coverage

Commits with AI assistance include Co-Authored-By: Claude attribution.


MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages