Skip to content

🧺 Android laundry service app built with Kotlin, Jetpack Compose & Material 3. Features Clean Architecture, Room Database, Hilt DI, M-PESA payment simulation, dark mode, and comprehensive error handling. Portfolio project demonstrating modern Android development best practices.

Notifications You must be signed in to change notification settings

muchaisam/Cleansafi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧺 CleanSafi - Modern Android Laundry Service App

Android Kotlin Jetpack Compose Material Design

A production-ready, feature-rich Android application showcasing modern app development practices

Features β€’ Architecture β€’ Tech Stack β€’ Screenshots β€’ Installation


πŸ“± Overview

CleanSafi is a fully functional laundry service application built with 100% Kotlin and Jetpack Compose. This portfolio project demonstrates enterprise-level Android development, featuring Clean Architecture, dependency injection, local persistence, M-PESA payment simulation, and a polished Material 3 UI with dark mode support.

🎯 Project Highlights

  • βœ… Production-Ready - 95% complete with error handling, offline support, and accessibility features
  • πŸ—οΈ Clean Architecture - Separation of concerns with Domain, Data, and Presentation layers
  • 🎨 Modern UI/UX - Material 3 design system with dynamic theming and smooth animations
  • πŸ’‰ Dependency Injection - Hilt for scalable and testable code
  • πŸ’Ύ Local Database - Room for robust offline-first functionality
  • πŸ”„ Reactive Programming - Kotlin Coroutines + Flow for asynchronous operations
  • πŸ“± M-PESA Integration - Payment flow simulation with realistic order progression

✨ Features

Core Functionality

  • πŸ” Authentication - User registration and login with validation
  • 🧺 Place Orders - Select laundry items, service types (Wash/Iron/Both), and schedule pickup
  • πŸ›’ Smart Cart - Dynamic pricing, item suggestions, and swipe-to-delete
  • πŸ’³ Payment Flow - M-PESA simulation with phone number validation (254XXXXXXXXX format)
  • πŸ“¦ Order Tracking - Real-time status updates with 8-stage progression system
  • πŸ“œ Order History - Complete order timeline with filter and search
  • πŸ‘€ User Profile - Statistics, theme toggle, and settings management

Production Features

  • 🌐 Network Monitoring - Real-time connectivity detection with offline indicators
  • ⚠️ Error Handling - Comprehensive error states with retry mechanisms
  • 🎭 Empty States - Contextual empty views for better UX
  • β™Ώ Accessibility - Content descriptions and proper semantic structure
  • πŸŒ“ Dark Mode - Persistent theme switching with Material 3 dynamic colors
  • βœ… Form Validation - Client-side validation for all user inputs
  • πŸ“³ Haptic Feedback - Tactile responses for user interactions
  • ✨ Animations - Smooth transitions, shimmer loading, and confetti celebrations
  • 🎬 Onboarding - 4-page introduction flow for first-time users
  • πŸ”” Runtime Permissions - Proper notification permission handling (Android 13+)

πŸ›οΈ Architecture

CleanSafi follows Clean Architecture principles with MVVM pattern for maintainability and testability:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 Presentation Layer                   β”‚
β”‚  (UI - Jetpack Compose + ViewModels + StateFlow)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Domain Layer                        β”‚
β”‚     (Business Logic - Models + Repositories)         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Data Layer                         β”‚
β”‚  (Room Database + Repository Implementations)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Package Structure

com.cleansafi/
β”œβ”€β”€ presentation/          # UI Layer (Compose Screens + ViewModels)
β”‚   β”œβ”€β”€ splash/
β”‚   β”œβ”€β”€ onboarding/
β”‚   β”œβ”€β”€ auth/             # Login & Signup
β”‚   β”œβ”€β”€ home/             # Dashboard
β”‚   β”œβ”€β”€ order/placeorder/ # Order creation
β”‚   β”œβ”€β”€ cart/             # Shopping cart
β”‚   β”œβ”€β”€ checkout/         # Order scheduling
β”‚   β”œβ”€β”€ payment/          # M-PESA simulation
β”‚   β”œβ”€β”€ orders/           # Order history
β”‚   β”œβ”€β”€ profile/          # User profile
β”‚   └── navigation/       # Navigation graph
β”œβ”€β”€ domain/               # Business Logic
β”‚   β”œβ”€β”€ model/            # Domain models
β”‚   └── repository/       # Repository interfaces
β”œβ”€β”€ data/                 # Data Layer
β”‚   β”œβ”€β”€ local/            # Room Database
β”‚   β”‚   β”œβ”€β”€ dao/          # Data Access Objects
β”‚   β”‚   β”œβ”€β”€ entity/       # Database entities
β”‚   β”‚   └── CleanSafiDatabase.kt
β”‚   └── repository/       # Repository implementations
└── core/                 # Shared Infrastructure
    β”œβ”€β”€ di/               # Hilt modules
    β”œβ”€β”€ theme/            # Material 3 theme
    β”œβ”€β”€ ui/               # Reusable components
    β”œβ”€β”€ error/            # Error handling
    β”œβ”€β”€ network/          # Connectivity monitoring
    β”œβ”€β”€ validation/       # Form validators
    └── util/             # Utilities

πŸ› οΈ Tech Stack

Core Technologies

  • Language: Kotlin 1.9.21
  • UI Framework: Jetpack Compose (BOM 2023.10.01)
  • Design System: Material 3
  • Min SDK: 26 (Android 8.0) | Target SDK: 34 (Android 14)

Architecture Components

  • ViewModel - UI state management
  • Navigation Compose - Type-safe screen navigation
  • Hilt 2.50 - Dependency injection
  • Room 2.6.1 - Local database with SQLite
  • Coroutines + Flow - Asynchronous operations
  • StateFlow - Reactive state management
  • WorkManager 2.9.0 - Background tasks

Development Tools

  • KSP - Kotlin Symbol Processing for annotation processing
  • Gradle Version Catalogs - Dependency management
  • Material Icons Extended - Comprehensive icon set

Key Dependencies

// Compose & UI
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.material:material-icons-extended")

// Architecture
implementation("com.google.dagger:hilt-android:2.50")
implementation("androidx.hilt:hilt-navigation-compose:1.1.0")
implementation("androidx.room:room-ktx:2.6.1")

// Lifecycle & Navigation
implementation("androidx.navigation:navigation-compose:2.7.6")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")

πŸ“Έ Screenshots

Home & Place Order

Cart & Checkout

M-PESA Payment Flow

Orders & Profile


πŸš€ Installation

Prerequisites

  • Android Studio: Hedgehog (2023.1.1) or later
  • JDK: 17 or higher
  • Android SDK: API Level 34
  • Gradle: 8.2+ (included via wrapper)

Setup Instructions

  1. Clone the repository

    git clone https://github.com/muchaisam/Cleansafi.git
    cd Cleansafi
  2. Open in Android Studio

    • Open Android Studio
    • Select "Open an Existing Project"
    • Navigate to the cloned directory
  3. Sync Gradle

    • Android Studio will automatically sync Gradle
    • Wait for dependencies to download
  4. Run the app

    ./gradlew assembleDebug  # Build debug APK
    ./gradlew installDebug   # Install on connected device

    Or use the ▢️ Run button in Android Studio

Build Variants

./gradlew assembleDebug     # Debug build
./gradlew assembleRelease   # Release build (requires signing)
./gradlew test              # Run unit tests
./gradlew clean build       # Clean build

πŸ’‘ Usage Guide

Test Credentials

For demo purposes, you can use any credentials to sign up/login:

  • Email: Any valid email format (e.g., demo@cleansafi.com)
  • Password: Minimum 6 characters
  • Phone: 10-digit number (e.g., 0712345678)

M-PESA Simulation

When making a payment:

  • Use format: 254XXXXXXXXX (e.g., 254712345678)
  • Payment is simulated - no real money transactions
  • Order progresses through realistic stages automatically

Demo Mode (Hidden Feature)

Long-press the app logo on the Home screen to enable Demo Mode:

  • Speeds up order progression from minutes to seconds
  • Perfect for showcasing the full order lifecycle quickly
  • Great for demos and portfolio presentations

🎯 Key Features Deep Dive

1. Smart Pricing System

enum class ServiceType {
    WASH_ONLY,      // Base price
    IRON_ONLY,      // -20% from wash price  
    WASH_AND_IRON   // +25% from wash price
}

// Dynamic pricing per item type
LaundryItemType.TOPS       // KSh 40-50
LaundryItemType.TROUSERS   // KSh 50-60
LaundryItemType.BEDSHEETS  // KSh 60-70
LaundryItemType.OTHERS     // KSh 70-80

2. Order Status Progression

PENDING β†’ CONFIRMED β†’ PICKED_UP β†’ PROCESSING β†’ 
READY β†’ OUT_FOR_DELIVERY β†’ DELIVERED β†’ COMPLETED

Each stage includes:

  • Timestamp tracking
  • Status history
  • Email notifications (simulated)
  • Real-time UI updates

3. Offline-First Architecture with Room Database

All data is persisted locally using Room database, making the app fully functional without an internet connection:

// Room Database with multiple DAOs for complete offline functionality
@Database(
    entities = [UserEntity, OrderEntity, OrderItemEntity, CartItemEntity, PaymentEntity],
    version = 1
)
abstract class CleanSafiDatabase : RoomDatabase() {
    abstract fun userDao(): UserDao
    abstract fun orderDao(): OrderDao
    abstract fun cartDao(): CartDao
    abstract fun paymentDao(): PaymentDao
}

What works offline:

  • βœ… User registration and login (credentials stored locally)
  • βœ… Browse services and add items to cart
  • βœ… Place orders and schedule pickups
  • βœ… View complete order history with status timeline
  • βœ… Track spending statistics (Profile & Orders screens)
  • βœ… M-PESA payment simulation
  • βœ… Theme preferences persist across sessions

Why this matters:

  • πŸš€ Instant app startup - No network calls needed
  • πŸ“± Works in low-connectivity areas - Critical for Kenya/Africa markets
  • πŸ’Ύ Data never lost - SQLite persistence survives app kills
  • πŸ”„ Reactive UI updates - Flow-based observation of database changes

4. Error Handling Strategy

sealed class AppError {
    data class NetworkError(val message: String)
    data class DatabaseError(val message: String)
    data class ValidationError(val message: String)
    data class UnknownError(val throwable: Throwable)
}

Every screen includes:

  • βœ… Loading states with shimmer effects
  • ⚠️ Error states with retry functionality
  • πŸ“­ Empty states with actionable guidance

πŸ”§ Configuration

Customizing Pricing

Edit PricingCalculator.kt:

object PricingCalculator {
    fun calculateItemPrice(
        itemType: LaundryItemType,
        serviceType: ServiceType
    ): Int {
        // Modify base prices here
        val basePrice = when (itemType) {
            LaundryItemType.TOPS -> 40
            LaundryItemType.TROUSERS -> 50
            // ...
        }
        // Adjust multipliers as needed
    }
}

Theme Customization

Modify Color.kt and Theme.kt in core/theme/:

val md_theme_light_primary = Color(0xFF006C4C)
val md_theme_dark_primary = Color(0xFF6FDBAC)
// Full Material 3 color scheme

πŸ“Š Database Schema

Core Tables

  1. UserEntity - User accounts
  2. OrderEntity - Orders with status and scheduling
  3. OrderItemEntity - Individual items per order
  4. CartItemEntity - Temporary shopping cart
  5. PaymentEntity - Payment records with transaction IDs
  6. OrderStatusHistoryEntity - Complete status timeline

Relationships

User (1) ──→ (N) Orders
Order (1) ──→ (N) OrderItems
Order (1) ──→ (1) Payment
Order (1) ──→ (N) StatusHistory

πŸ§ͺ Testing

Run Tests

./gradlew test                    # Unit tests
./gradlew connectedAndroidTest    # Instrumented tests
./gradlew testDebugUnitTest      # Debug unit tests only

Test Coverage

  • ViewModel logic testing
  • Repository pattern testing
  • Database migration testing
  • Validation logic testing

πŸ“ˆ Performance Optimizations

  • βœ… Lazy column for efficient list rendering
  • βœ… Remember and derivedStateOf for composition optimization
  • βœ… Database indexes on frequently queried columns
  • βœ… Flow-based reactive updates (no unnecessary recompositions)
  • βœ… Image loading optimization
  • βœ… Minimal overdraw with proper layout hierarchy

πŸ” Security Considerations

Current Implementation (Demo)

  • ⚠️ Passwords stored in plain text (Room database)
  • ⚠️ No server-side authentication
  • ⚠️ Simulated payment system

Production Recommendations

  • πŸ”’ Implement password hashing (BCrypt/Argon2)
  • πŸ”’ Add JWT/OAuth authentication
  • πŸ”’ Integrate real M-PESA/payment gateway
  • πŸ”’ Enable ProGuard/R8 obfuscation
  • πŸ”’ Add SSL pinning for network requests
  • πŸ”’ Implement biometric authentication

🚧 Roadmap

Phase 1: Core Features βœ… (Complete)

  • User authentication
  • Order placement and management
  • Cart functionality
  • Payment simulation
  • Order tracking
  • Profile management

Phase 2: Production Readiness βœ… (Complete)

  • Error handling system
  • Offline support
  • Empty states
  • Network monitoring
  • Form validation
  • Accessibility features

Phase 3: Enhancements πŸš€ (Future)

  • Backend API integration
  • Real M-PESA Daraja API
  • Push notifications (FCM)
  • Order rating and reviews
  • Promo codes and discounts
  • Multiple delivery addresses
  • In-app chat support
  • Analytics integration

Phase 4: Advanced Features πŸ’Ž (Future)

  • Multi-language support (i18n)
  • Wear OS companion app
  • Widget for quick order status
  • Share order receipts
  • Subscription plans
  • AI-powered laundry tips

🀝 Contributing

This is a portfolio project, but feedback and suggestions are welcome!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘¨β€πŸ’» Developer

Sam Muchai


πŸ™ Acknowledgments

  • Material Design 3 - Design system and components
  • Google Codelabs - Android development best practices
  • Android Developer Documentation - Official guides and references
  • Stack Overflow Community - Problem-solving assistance

πŸ“ž Support

For questions or support:


⭐ If you find this project useful, please consider giving it a star!

Built with ❀️ using Kotlin and Jetpack Compose

About

🧺 Android laundry service app built with Kotlin, Jetpack Compose & Material 3. Features Clean Architecture, Room Database, Hilt DI, M-PESA payment simulation, dark mode, and comprehensive error handling. Portfolio project demonstrating modern Android development best practices.

Topics

Resources

Stars

Watchers

Forks

Languages