
Case Study
A full-stack e-commerce mobile app with AI-powered visual search, Stripe payment integration, and a scalable clean architecture — spanning 30,000+ lines of Dart across 10 feature modules.
E-commerce product discovery suffers from a fundamental gap: users often know what they want visually but lack the vocabulary to search for it. Traditional text-based search fails when a shopper sees a jacket on the street and wants to find something similar online. Building a production-grade e-commerce app means solving multiple hard problems simultaneously — AI-powered visual search that actually works, a checkout flow that handles Stripe PaymentIntents with idempotency and ephemeral keys, real-time cart synchronization across devices, and a scalable architecture that can grow from 10 to 100 feature modules without collapsing under its own weight.
ECometa is a full-stack e-commerce mobile application that delivers a complete shopping experience — from product discovery through AI-powered visual search, to secure checkout with Stripe payment processing. Users can photograph clothing and the Clarifai AI model extracts tags to match against the product catalog using a multi-strategy search algorithm. The app integrates 6 backend services (Firebase Auth, Cloud Firestore, Supabase Storage, Stripe, Clarifai AI, and a NestJS payment API) into a cohesive, maintainable codebase built with Flutter and Clean Architecture. The checkout flow is a 10-step orchestration covering PaymentIntent creation, PaymentSheet presentation, idempotency keys, and deterministic order IDs.
Organized as a feature-first Clean Architecture codebase with 10 feature modules. Every feature follows a strict 3-layer separation: data (datasources, models, repositories), domain (entities, repositories, usecases, services), and presentation (controller/bloc, views, widgets). The core module provides shared infrastructure — constants, error hierarchy (8 typed Failure classes), themes, responsive system, GoRouter with 7 animated transitions, services (Firebase, Supabase, Firestore, CurrentUser), and 13 reusable widgets. Auth uses BLoC for complex event-driven flows; all other features use Riverpod with FamilyAsyncNotifier for reactive data streams and cursor-based pagination. The checkout module is the largest at 89 files, orchestrating a 10-step flow across Stripe, Firestore, and ephemeral key management.
Users photograph clothing which gets uploaded to Supabase Storage, then analyzed by Clarifai's apparel classification model with a confidence threshold of ≥0.8. Extracted tags are normalized to match Firestore's tag format, then matched against the product catalog using a 3-tier strategy: direct tag match first, individual tag fallback if no results, and broad category fallback as a last resort. This ensures users always get relevant results even when the AI tags don't perfectly align with catalog data.
The checkout flow coordinates 10 sequential steps across multiple services: creating a deterministic OrderEntity with idempotency keys, building a Stripe PaymentIntent via the NestJS backend, retrieving or creating a Stripe Customer, loading saved cards and identifying the default, loading the default shipping address, creating an ephemeral key for saved card access, initializing the PaymentSheet, presenting it to the user, saving the order to Firestore only after successful payment, and clearing the cart. Each step has rollback protection and failure handling.
Auth flows use BLoC because they involve complex event-driven logic: distinct states (initial → loading → success/error), form validation events, social auth error recovery, and one-off navigation side effects. All other features use Riverpod because they need reactive data streams, family providers with parameters, computed states, dependency injection between providers, and AsyncNotifier for cursor-based pagination. The choice is use-case driven, not convention-driven.
All data layer operations are wrapped in handleRepositoryExceptions<T>() which catches and maps platform exceptions to typed Failure classes: StripeException → StripeFailure, FirebaseAuthException → FirebaseFailure, FirebaseException → FirestoreFailure, DioException → ServerFailure, SocketException → SocketFailure, and more. All repository methods return Either<Failure, T> using dartz, enabling functional error handling throughout the domain and presentation layers.
Product listings use Firestore cursor-based pagination instead of offset-based, which remains performant as catalogs grow. FamilyAsyncNotifier provides reactive state per query parameters (category, sort, filter), with automatic cursor tracking, loading states, and error handling. Infinite scroll triggers the next page load, and pull-to-refresh resets the cursor.