How endorodrigo/factus-reto works
This repository is a cross-platform Flutter app named factus_retos, built around a layered architecture with clear separation between UI, state management, domain models, and service/integration code.
1. Platform shell
- The app targets Android, iOS, web, Windows, macOS, and Linux using the standard Flutter platform runners.
- The platform folders are mostly generated wrappers; the real application logic lives under lib/.
- Android includes google-services.json, which indicates Firebase is configured natively on that platform.
2. App entry and initialization
- lib/main.dart is the runtime entry point.
- lib/firebase_options.dart suggests Firebase is initialized through FlutterFire-generated configuration.
- lib/config/theme/app_theme.dart centralizes visual styling for the app.
3. Presentation layer
- lib/presentation/views contains the screens: splash, login/register, home, product detail, cart, orders, order detail, profile, admin dashboard, admin products, and product form.
- This is the primary UI surface and appears to cover both customer and admin experiences in the same app.
- Views are organized by feature rather than by generic widget type.
4. State management and feature controllers
- lib/presentation/controllers contains GetX-style controllers and bindings, based on the *controller.dart and *binding.dart naming pattern.
- Controllers exist for auth, home, cart, orders, order detail, profile, splash, and admin/product management.
- Bindings such as admin_binding.dart, profile_binding.dart, and product_form_binding.dart indicate dependency injection is scoped per route/feature.
5. Navigation and route boundaries
- lib/core/routes/app_pages.dart and app_routes.dart centralize route definitions.
- lib/core/middlewares/auth_middleware.dart and admin_middleware.dart enforce access control at the routing layer.
- This makes navigation a major architectural boundary: authenticated user flows, guest flows, and admin-only flows are separated before a screen is entered.
6. Domain layer
- lib/domain/entities defines core business objects such as ProductEntity, OrderEntity, and UserEntity.
- lib/domain/repositories/auth_repository.dart defines at least one repository contract, indicating the app follows a dependency-inversion pattern where controllers depend on abstractions, not concrete services.
7. Data layer
- lib/data/models contains persisted/transport representations for cart items, orders, products, and users.
- These models likely bridge between Firestore/Firebase records and the domain entities used by the UI and controllers.
- The presence of both entity and model types suggests mapping between app business concepts and stored data format.
8. Core services and infrastructure access
- lib/core/utils holds service wrappers for auth_service.dart, firestore_service.dart, product_service.dart, order_service.dart, and stripe_service.dart.
- These are the main integration points to external systems:
- Firebase Authentication for login/register/session state
- Cloud Firestore for app data persistence
- Stripe for payment processing
- This layer is the technical backend of the Flutter app.
9. Error handling
- lib/core/errors/exceptions.dart and failures.dart define a failure/exceptions boundary.
- This suggests the app normalizes low-level service errors into app-level failure types before they reach the UI.
10. Primary business flows
- The customer flow appears to be: splash → auth → home/product browsing → product detail → cart → order creation → order history/detail → profile.
- The admin flow appears to be: auth/middleware check → admin dashboard → product management → product form.
- Orders and products are the central business entities connecting most screens and services.
11. Authentication and role-based access
- auth_controller.dart, auth_service.dart, and auth_middleware.dart together manage sign-in/sign-up, session gating, and route protection.
- admin_middleware.dart indicates role-based authorization, likely distinguishing administrative users from regular users.
- This is one of the key architectural control points in the app.
12. Assets and presentation resources
- assets/images stores app imagery.
- Native splash/launch assets exist in each platform folder, while Flutter-side visual theming is centralized in app_theme.dart.
- These resources support the UI but do not drive business logic.
13. Platform-specific configuration
- firebase.json plus the Firebase config in Android and FlutterFire-generated options indicate the app is wired to Firebase services across platforms.
- The repository includes normal Flutter desktop/web scaffolding, so the architecture is multi-target but still centered on the same shared Dart codebase.
14. Testing and quality
- test/widget_test.dart exists as the default Flutter widget test entry point.
- analysis_options.yaml indicates static analysis/linting is enabled to keep the codebase consistent.
Overall, this is a Flutter client application with a layered, feature-oriented structure: route-driven presentation on top, GetX-style controllers/bindings for state and dependency management, domain entities and repositories for business structure, and core service wrappers around Firebase/Firestore/Stripe integrations.
Main entry points: app_pages.dart Routes · firestore_service.dart Services · main.dart main.dart · orders_view.dart Orders
Components 20
Platforms
Flutter host shells and platform-specific wiring.
- Firebase config · FlutterFire options and native Firebase wiring
lib/firebase_options.dart
App Core
Bootstrap, configuration, routing, and shared infrastructure.
- main.dart · App startup and dependency bootstrap
lib/main.dart - App theme · Centralized styling and visual system
lib/config/theme/app_theme.dart - Routes · Route table and app-level navigation boundaries
lib/core/routes/app_pages.dart - Auth guards · Authentication and admin access control
lib/core/middlewares/auth_middleware.dart - Services · Firebase, Firestore, payments, and backend access
lib/core/utils/firestore_service.dart - Failures · Exceptions and failure normalization
lib/core/errors/failures.dart
Presentation
Screens, controllers, and route-scoped bindings.
- Splash · Startup screen and session handoff
lib/presentation/views/splash_view.dart - Auth flow · Login and registration experience
lib/presentation/views/login_view.dart - Home · Primary browsing and product entry point
lib/presentation/views/home_view.dart - Product detail · Single product inspection and actions
lib/presentation/views/product_detail_view.dart - Cart · Checkout basket and purchase preparation
lib/presentation/views/cart_view.dart - Orders · Order history and order inspection
lib/presentation/views/orders_view.dart - Profile · User account and profile management
lib/presentation/views/profile_view.dart - Admin dashboard · Admin landing page and management hub
lib/presentation/views/admin_dashboard_view.dart - Admin products · Product administration and catalog maintenance
lib/presentation/views/admin_products_view.dart - Product form · Create and edit product records
lib/presentation/views/product_form_view.dart
Domain
Business entities and repository contracts.
Data
Transport and persistence models.
- Data models · Firestore-oriented representations of app data
lib/data/models/product_model.dart
Connections 27
- main.dart → App theme: uses · Applies shared styling at startup
- main.dart → Routes: boots · Installs route-driven app structure
- main.dart → Firebase config: initializes · Configures Firebase for the client app
- Routes → Auth guards: protects · Applies authentication and admin gating
- Routes → Splash: opens · Entry screen for startup flow
- Routes → Auth flow: opens · Guest authentication flow
- Routes → Home: opens · Main customer browsing flow
- Routes → Admin dashboard: opens · Admin-only control surface
- Routes → Cart: opens · Checkout and purchase flow
- Routes → Orders: opens · Order history flow
- Routes → Profile: opens · Account management flow
- Routes → Product detail: opens · Product detail flow
- Routes → Admin products: opens · Admin catalog management
- Routes → Product form: opens · Product create/edit flow
- Splash → Services: checks session · Reads auth/session state from backend services
- Auth flow → Services: authenticates · Uses auth and persistence integrations
- Home → Entities: consumes · Works with core product and user domain objects
- Cart → Data models: persists · Stores cart/order data through transport models
- Orders → Data models: loads · Reads stored order records
- Profile → Auth repo: depends on · Relies on repository contract for user auth state
- Services → Firebase config: wraps · Bridges to Firebase/Firestore/Stripe infrastructure
- Services → Failures: normalizes · Converts low-level failures into app-level errors
- Data models → Entities: maps to · Transforms persisted records into domain objects
- Admin dashboard → Admin products: navigates · Admin hub routes to product management
- Admin products → Product form: edits · Opens product creation/editing form
- Product detail → Cart: adds to · Sends selected products into purchase flow
- Orders → Product detail: drills into · Allows inspection of order-related product details