Technical Architecture & System Design

Clean Architecture, reactive state management, and scalable monetization powering ShelfChef.

Architecture Overview

ShelfChef follows Clean Architecture principles combined with MVVM. The system is designed to isolate business logic from UI and external services, ensuring scalability, maintainability, and long-term extensibility.

Layer Responsibilities

Dependency Direction

Dependencies flow inward. The Domain layer defines interfaces. The Data layer implements them. The Presentation layer depends only on Domain abstractions. This prevents framework or API coupling from leaking into business logic.

System Architecture Diagram

Presentation Layer (Compose UI + ViewModels) Domain Layer (Models + Use Cases + FeatureGateManager) Data Layer (Repositories)

This layered design isolates business rules, simplifies testing, and enables portability to additional platforms such as web or React Native.

State Management Architecture

ShelfChef uses Kotlin Coroutines and StateFlow to implement reactive, lifecycle-aware state management within MVVM.

The architecture enforces unidirectional data flow: user events move upward to ViewModels, and state flows downward to the UI. This ensures predictable rendering and reduces inconsistent UI states.

Error Handling Strategy

Network Resilience

AI Fallback Strategy

Recipe parsing first attempts structured Schema.org extraction. If unavailable, GPT-4o-mini processes raw HTML. If AI fails, users receive clear actionable feedback.

Subscription Consistency

RevenueCat entitlement state acts as the single source of truth. No feature is unlocked based solely on local flags.

RevenueCat Integration Deep Dive

RevenueCat powers subscription management, entitlement validation, cross-device synchronization, and restore functionality.

Entitlement Model

A single entitlement, "ShelfChef Pro", governs premium access.

Subscription Event Lifecycle

  1. User selects subscription package.
  2. RevenueCat validates receipt and updates entitlement.
  3. FeatureGateManager observes entitlement change.
  4. Premium features unlock instantly via reactive state updates.

Restore Flow

Restore purchases triggers RevenueCat backend sync, refreshing entitlement state without requiring app restart.

Identity Mapping

Firebase UID is passed to RevenueCat logIn(). This ensures subscription persistence across devices. Logout resets identity to anonymous.

Why This Architecture Enables Monetization

Monetization is integrated at the Domain layer through a centralized FeatureGateManager rather than enforced only at the UI layer.

This ensures monetization remains stable, secure, and scalable as new features and pricing experiments are introduced.

Tech Stack