How ramonsantospinto/app_delivery works
Purpose and Entry Points
Vakinha Burguer is a Flutter/Dart mobile food-delivery client: users authenticate, browse products, configure an order, choose payment, and submit it to a REST backend. Runtime startup is lib/main.dart, which launches the application shell in lib/app/dw_delivery_app.dart. Android embeds Flutter through android/app/src/main/kotlin/br/com/academiadoflutter/vakinhaburguer/dw_delivery_app/MainActivity.kt.
Application Composition and Navigation
The app is organized by feature pages, each generally owning its page, controller, state, and router. The flow begins at splash, then routes into authentication or the delivery experience:
• lib/app/pages/splash/splash_page.dart
• lib/app/pages/auth/login/login_router.dart
• lib/app/pages/home/home_router.dart
• lib/app/pages/order/order_router.dart
Feature routers are the navigation boundary between screens; controllers coordinate screen events and repository calls.
Dependency and Global Runtime Layer
Application-wide bindings and shared runtime services are assembled in lib/app/core/provider/application_binding.dart. Shared widget context is exposed by lib/app/core/global/global.context.dart. UI state uses a mix of Provider/BLoC-related packages and generated state artifacts, visible in feature state files such as:
• lib/app/pages/auth/login/login_state.dart
• lib/app/pages/home/home_state2.dart
• lib/app/pages/order/order_state.dart
The generated *.g.dart files indicate code-generated state/matching support.
Network, Environment, and Authentication Boundary
HTTP communication is centralized on a custom Dio client at lib/app/core/rest_client/custom_dio.dart; authentication headers/token behavior is separated into lib/app/core/rest_client/interceptors/auth_interceptor.dart. Backend configuration is sourced through lib/app/core/config/env/env.dart, with .env supplying environment values. Repository-specific failures and authorization failures are represented by:
• lib/app/core/exceptions/repository_exception.dart
• lib/app/core/exceptions/unauthorized_exception.dart
The documented backend is json_rest_server; requests should remain behind repositories rather than page/controllers.
Domain Repositories and Models
Repositories define the client-side API boundary for authentication, catalog retrieval, and order submission, with abstract contracts plus Dio-backed implementations:
• lib/app/repositories/auth/auth_repository.dart
• lib/app/repositories/auth/auth_repository_impl.dart
• lib/app/repositories/products/products_repository_impl.dart
• lib/app/repositories/order/order_repository_impl.dart
Core entities are AuthModel, ProductModel, and PaymentTypeModel under lib/app/models/. Order payload assembly is explicitly represented by lib/app/dto/order_dto.dart and lib/app/dto/order_product_dto.dart, separating backend request shape from UI/domain models.
Customer and Ordering Flow
Authentication controllers handle login/registration and hand off to the product catalog:
• lib/app/pages/auth/login/login_controller.dart
• lib/app/pages/auth/register/register_controller.dart
• lib/app/pages/home/home_controller.dart
Home renders product selection and shopping-bag state through lib/app/pages/home/home_page.dart and lib/app/pages/home/widgets/shopping_bag_widget.dart. Product detail adjusts a selected product before order composition in lib/app/pages/product_detail/product_detail_controller.dart. The order controller builds the delivery/payment request and drives confirmation:
• lib/app/pages/order/order_controller.dart
• lib/app/pages/order/order_page.dart
• lib/app/pages/order/order_completed_page.dart
Presentation System and Platform Assets
Shared theming, reusable delivery controls, loading, and user-message behavior live below lib/app/core/ui/, notably lib/app/core/ui/theme/theme_config.dart, lib/app/core/ui/widgets/delivery_button.dart, and lib/app/core/ui/base_state/base_state.dart. Flutter assets include fonts and images under assets/; Android Gradle and manifest files provide the mobile packaging layer under android/app/.
Main entry points: home_controller.dart Catalog & bag · order_controller.dart Checkout & confirmation · custom_dio.dart REST client · splash_page.dart Feature navigation
Components 18
Runtime & platform
- Android host · Embeds the Flutter runtime.
android/app/src/main/kotlin/br/com/academiadoflutter/vakinhaburguer/dw_delivery_app/MainActivity.kt - Flutter startup
lib/main.dart - Application shell
lib/app/dw_delivery_app.dart
Feature presentation
- Feature navigation · Routes splash, authentication, catalog, and ordering screens.
lib/app/pages/splash/splash_page.dart - Authentication · Login and registration hand off to the catalog.
lib/app/pages/auth/login/login_controller.dart - Catalog & bag · Displays products and maintains shopping-bag selection.
lib/app/pages/home/home_controller.dart - Product configuration · Adjusts the selected product before ordering.
lib/app/pages/product_detail/product_detail_controller.dart - Checkout & confirmation · Builds and submits delivery and payment requests.
lib/app/pages/order/order_controller.dart - UI state & shared UI · Provider/BLoC state, theme, controls, loading, and messages.
lib/app/core/ui/base_state/base_state.dart
Application services
- Application binding · Registers application-wide dependencies.
lib/app/core/provider/application_binding.dart
Data & backend boundary
- Auth repository
lib/app/repositories/auth/auth_repository_impl.dart - Products repository
lib/app/repositories/products/products_repository_impl.dart - Order repository
lib/app/repositories/order/order_repository_impl.dart - Order payloads · Separates order request shape from UI models.
lib/app/dto/order_dto.dart - Domain models · Authentication, product, and payment entities.
- REST client · Central HTTP boundary with authentication interception.
lib/app/core/rest_client/custom_dio.dart - Environment config
lib/app/core/config/env/env.dart - json_rest_server
Connections 29
- Android host → Flutter startup: hosts Flutter
- Flutter startup → Application shell: launches
- Application shell → Application binding: initializes
- Application shell → Feature navigation: starts flow
- Application binding → Auth repository: provides
- Application binding → Products repository: provides
- Application binding → Order repository: provides
- Feature navigation → Authentication: routes to
- Feature navigation → Catalog & bag: routes to
- Feature navigation → Checkout & confirmation: routes to
- Authentication → Auth repository: authenticates
- Authentication → Catalog & bag: on success
- Catalog & bag → Products repository: loads products
- Catalog & bag → Product configuration: selects product
- Product configuration → Checkout & confirmation: adds configured item
- Catalog & bag → Checkout & confirmation: checks out bag
- Checkout & confirmation → Order payloads: assembles request
- Checkout & confirmation → Order repository: submits order
- Auth repository → Domain models: maps auth
- Products repository → Domain models: maps catalog
- Order repository → Order payloads: sends payload
- Auth repository → REST client: uses
- Products repository → REST client: uses
- Order repository → REST client: uses
- Environment config → REST client: configures
- REST client → json_rest_server: REST requests
- UI state & shared UI → Authentication: supports screens
- UI state & shared UI → Catalog & bag: supports screens
- UI state & shared UI → Checkout & confirmation: supports screens