How theemomo/flutter-e-commerce-app works
Project type and purpose
• This is a cross-platform (Android, iOS, Web, Linux, macOS, Windows) e-commerce client built in Flutter.
• It uses Firebase for authentication and Firestore for persistent data (products, cart, favorites, users).
Key architectural layers (from top to bottom)
A. Platform Shells
• Android (MainActivity.kt)
• iOS (AppDelegate.swift)
• Web (index.html + Flutter Web loader)
• Desktop (linux/main.cc, macos/AppDelegate.swift, windows/main.cpp)
B. Flutter Engine & Dart VM
• Embeds Dart code on each platform
C. Presentation Layer (lib/views)
• Pages (e.g., home_page, cart_page, product_details_page)
• Widgets (reusable UI components)
D. State Management Layer (lib/view_models)
• Cubits (AuthCubit, HomeCubit, CartCubit, etc.)
• States (AuthState, HomeState, etc.)
E. Domain / Service Layer (lib/services + lib/utils)
• Service classes (AuthServicesImpl, FirestoreServices, CartServicesImpl, etc.)
• Utility helpers (api_paths.dart, app_router.dart)
F. Data Models (lib/models)
• DTOs/models (ProductItemModel, CartItemModel, PromoCodeModel, UserData, etc.)
G. External Backend (Firebase)
• Firebase Authentication
• Cloud Firestore (collections: products, cart, favorites, users)
Relationships & Data Flow
• UI Widgets emit user events →
• Corresponding Cubit handles event →
• Cubit calls a Service method →
• Service interacts with Firebase SDK →
• Firebase returns data →
• Service maps raw data to Models →
• Cubit emits new State →
• UI rebuilds based on updated State.
Architectural Patterns & Design Principles
• BLoC/Cubit Pattern: clear separation of presentation and business logic.
• Clean Architecture: UI → State → Services → Data → External.
• Single Responsibility: each Cubit and Service has one job.
• Modular Structure: Models ↔ Services ↔ Cubits ↔ Views.
Technologies & Frameworks
• Flutter & Dart
• flutter_bloc (Cubit) for state management
• firebase_auth, cloud_firestore for back-end
• flutter_carousel_widget, cached_network_image, equatable, fluttertoast
• A title (“Flutter E-Commerce App Architecture”) and a brief footnote listing the BLoC + Clean Services pattern.