How warehouse-usal/smartwarehouse works
Purpose and Runtime
Smart Warehouse is a Flutter client organized as a Melos monorepo. It supports authenticated warehouse ordering: browse a catalog, maintain a cart, create orders, track order status/notifications, and manage a profile. The Flutter shell targets Android, iOS, web, Linux, macOS, and Windows; the substantive application is Dart packages under packages/.
Entry and composition points:
• lib/main.dart
• lib/application/application.dart
• lib/config/ioc_manager.dart
Bootstrap, Dependency Injection, and Shared Contracts
Startup initializes the application and its dependency graph, then feature builders supply implementations and presentation state. core defines cross-feature app/environment and use-case contracts; commons adapts platform and infrastructure concerns.
Key boundaries:
• lib/config/ioc_manager.dart
• packages/core/lib/core.dart
• packages/commons/lib/helpers/injector/get_it_injector.dart
Shared infrastructure includes Dio HTTP, auth/logging interceptors, Hive and shared-preferences persistence, permissions, image selection, and Beamer navigation:
• packages/commons/lib/helpers/http/dio_http_helper.dart
• packages/commons/lib/helpers/persistence_helper/hive_persistence_helper.dart
• packages/commons/lib/helpers/http/interceptors/auth_interceptor.dart
Application Navigation and Session Gates
The app shell uses Beamer-based navigation. Authentication guards separate unauthenticated login access from protected application routes; core session/login use cases coordinate transitions. The bottom-navigation feature provides the primary authenticated workspace scaffold.
• lib/application/navigation/beamer_config_helper.dart
• lib/application/navigation/guards/auth/authenticated_guard.dart
• packages/core/lib/src/navigation/routes.dart
• packages/features/bottom_navigation_bar/lib/src/presentation/components/bottom_navigation_scaffold.dart
Control flow: app startup → route resolution → auth guard → login or protected shell → tab/feature pages.
Authentication and Token Lifecycle
Login is a layered feature: UI cubits submit credentials through a repository; remote DTOs map to domain tokens/user data; auth state and local repositories persist session material. A separate token repository and the shared HTTP auth interceptor form the request-authentication boundary.
• packages/features/login/lib/src/presentation/bloc/login/login_cubit.dart
• packages/features/login/lib/src/data/repositories/remote_login_repository.dart
• packages/features/auth/lib/src/presentation/bloc/auth_cubit.dart
• packages/features/repositories/token_repository/lib/src/data/repositories/local_token_repository.dart
Catalog and Cart
Catalog presents searchable/filterable, paginated products. Repositories isolate mock versus remote sources; DTO mappers convert API payloads to domain product models. Cart is intentionally in-memory state, managed by a cubit and reused as the source for order creation.
• packages/features/catalog/lib/src/presentation/bloc/catalog_cubit.dart
• packages/features/catalog/lib/src/data/repositories/remote_catalog_repository.dart
• packages/features/catalog/lib/src/data/mappers/products_page_mapper.dart
• packages/features/cart/lib/src/data/repositories/in_memory_cart_repository.dart
• packages/features/cart/lib/src/presentation/bloc/cart_cubit.dart
Order Creation and Tracking
Order creation converts cart/domain items to request DTOs and calls a remote or mock order repository; local history storage exists as an auxiliary persistence boundary. Tracking independently retrieves order lists/details and models WebSocket order events for live notifications/status changes.
• packages/features/orders/lib/src/presentation/bloc/create_order_cubit.dart
• packages/features/orders/lib/src/data/repositories/remote_order_repository.dart
• packages/features/order_tracking/lib/src/data/repositories/remote_order_tracking_repository.dart
• packages/features/order_tracking/lib/src/presentation/bloc/order_notification_cubit.dart
• packages/features/order_tracking/lib/src/data/dtos/ws_order_event_dto.dart
Profile, UI System, and Platform Delivery
Profile fetches/maps user, address, and order-summary data behind a repository. All features consume the reusable design system for themed controls, layouts, and navigation visuals. Flutter host projects package the Dart app for each target, with Android/iOS native entry activities/delegates.
• packages/features/profile/lib/src/data/repositories/remote_profile_repository.dart
• packages/design_system/lib/theme/themes/smartwarehouse/smart_warehouse_theme.dart
• packages/design_system/lib/design_system.dart
• android/app/src/main/kotlin/com/smartwarehouse/smart_warehouse/MainActivity.kt
• ios/Runner/AppDelegate.swift
Main entry points: bottom_navigation_scaffold.dart Protected workspace · main.dart Flutter entrypoint · ioc_manager.dart DI manager · authenticated_guard.dart Authenticated guard
Components 20
Bootstrap
- Flutter entrypoint
lib/main.dart - Application composition
lib/application/application.dart - DI manager
lib/config/ioc_manager.dart
App Shell
- Beamer routes
lib/application/navigation/beamer_config_helper.dart - Authenticated guard
lib/application/navigation/guards/auth/authenticated_guard.dart - Protected workspace
packages/features/bottom_navigation_bar/lib/src/presentation/components/bottom_navigation_scaffold.dart
Shared Platform
- Core contracts · Defines app, environment, navigation, and use-case contracts.
packages/core/lib/core.dart - Platform infrastructure · Provides HTTP, persistence, permissions, and platform helpers.
packages/commons/lib/helpers/injector/get_it_injector.dart - Dio HTTP client
packages/commons/lib/helpers/http/dio_http_helper.dart - Design system
packages/design_system/lib/design_system.dart
Feature Packages
- Login flow · Submits credentials and maps remote session data.
packages/features/login/lib/src/presentation/bloc/login/login_cubit.dart - Session state
packages/features/auth/lib/src/presentation/bloc/auth_cubit.dart - Token storage
packages/features/repositories/token_repository/lib/src/data/repositories/local_token_repository.dart - Catalog · Searches, filters, and paginates products.
packages/features/catalog/lib/src/presentation/bloc/catalog_cubit.dart - Cart · Maintains orderable items in memory.
packages/features/cart/lib/src/presentation/bloc/cart_cubit.dart - Order creation
packages/features/orders/lib/src/presentation/bloc/create_order_cubit.dart - Order tracking · Processes live order status events.
packages/features/order_tracking/lib/src/presentation/bloc/order_notification_cubit.dart - Profile · Fetches user, address, and order summaries.
packages/features/profile/lib/src/data/repositories/remote_profile_repository.dart
Platform Delivery
- Flutter host projects · Packages the Flutter app for supported platforms.
android/app/src/main/kotlin/com/smartwarehouse/smart_warehouse/MainActivity.kt
Other components
- Warehouse API · Supplies authentication, catalog, profile, and order data.
Connections 26
- Flutter host projects → Flutter entrypoint: launches
- Flutter entrypoint → Application composition: starts
- Flutter entrypoint → DI manager: initializes
- DI manager → Core contracts: binds contracts
- DI manager → Platform infrastructure: registers adapters
- Platform infrastructure → Dio HTTP client: provides
- Application composition → Beamer routes: configures
- Beamer routes → Authenticated guard: protects routes
- Authenticated guard → Login flow: unauthenticated
- Authenticated guard → Protected workspace: authenticated
- Login flow → Session state: establishes session
- Session state → Token storage: persists session
- Token storage → Dio HTTP client: supplies auth token
- Protected workspace → Catalog: hosts tab
- Protected workspace → Cart: hosts tab
- Protected workspace → Order creation: hosts tab
- Protected workspace → Order tracking: hosts tab
- Protected workspace → Profile: hosts tab
- Catalog → Cart: adds products
- Cart → Order creation: supplies order items
- Login flow → Warehouse API: authenticates
- Catalog → Warehouse API: loads products
- Order creation → Warehouse API: creates order
- Order tracking → Warehouse API: loads and receives events
- Profile → Warehouse API: loads profile
- Design system → Protected workspace: styles UI