How bizz84/flutter-firebase-masterclass works
Main components
• Frontend Flutter App: Represented by the "ecommerce_app/lib" directory. This includes multiple platforms (Android, iOS, macOS, Web) with their native subdirectories and the shared Dart code for business logic, UI, state management, and routing.
• Feature Modules: Within lib/src/features, each folder (e.g., authentication, cart, checkout, orders, products, reviews, and products_admin) should be modeled as separate components. Each of these modules is further divided into presentation, application layer, data layer, and domain entities.
• Backend Services:
• Firebase – This includes Firestore, Firebase Authentication, Firestore rules, and indexes (see ecommerce_app/firestore.indexes.json and firestore.rules).
• Firebase Cloud Functions – Found in the "ecommerce_app/functions" folder, these functions (admin.ts, index.ts, stripe.ts, etc.) offer server-side logic and integrations.
• External Integrations:
• Stripe – Integrated via an environment (.env) file and exposed through generated code (env.g.dart). This handles payment processing.
• Additional Firebase setup files (e.g., firebase_options.dart) that configure the app.
• Testing Infrastructure: Highlight the “test” folder that includes integration tests, unit tests for each feature, and golden tests.
• Deployment/CI: Indicate that GitHub workflows (in .github/workflows) are used to run tests and CI/CD pipelines.
Relationships and interactions
• The Flutter App (client) communicates with Firebase (authentication, database, cloud functions) using the Firebase SDK.
• Feature modules interact internally using controllers and services (e.g., for sign-in, product listings, cart management, checkout processing).
• Cloud Functions provide a layer between the client and external services like Stripe. For instance, when a checkout is initiated, the client calls a cloud function which in turn interacts with Stripe’s API.
• Data flows from user interactions in the frontend (e.g., add to cart, sign in) to updates in Firestore, and vice versa.
• Build-time generated files (using build_runner) facilitate dependency injection and ensure that generated *.g.dart files are synchronized with their respective modules.
Architectural Patterns and Design Principles
• Modular Architecture: Each feature (authentication, cart, etc.) is encapsulated into its own module with clear separation of concerns.
• Layered/DLL Architecture: Separating domain, data, application (business logic), and presentation layers leads to a more maintainable codebase.
• Cross-Platform Development: Emphasize that the frontend is a Flutter project targeting multiple platforms (Android, iOS, macOS, web).
• CI/CD Integration: The existence of .github workflows indicates automated testing and deployment practices.
• External Service Abstraction: Notice the provision for environment-specific configurations (via Envied for Stripe and flutterfire CLI for Firebase) that ensure secure and scalable integration.