How ashishtrucksup/trucksup_flutter_monorepo works
1. Repository shape
- This is a Flutter monorepo/workspace, not a single app project.
- The workspace is split into:
- apps/Trucksup for the runnable mobile app
- packages/core for cross-cutting infrastructure and shared primitives
- packages/shared for shared domain abstractions
- packages/features/* for independently packaged features
- bricks/* for code generation templates
2. Top-level dependency boundary
- The architecture is centered on a modular clean-architecture style.
- The app shell depends on reusable packages, while feature packages are meant to stay isolated from each other.
- packages/core is the main platform layer; packages/features/splash is an example vertical feature module.
3. App shell responsibilities
- apps/Trucksup/lib/main.dart and bootstrap.dart are the entry points for runtime startup.
- app.dart wires the Flutter app together.
- app/config, app/di, and app/router define the shell-level composition:
- environment/flavor selection
- dependency injection
- route configuration
- navigator observation
4. Environment and flavor system
- The app supports dev, staging, and prod flavors.
- Flavor selection is driven by --dart-define=FLAVOR=....
- Flavor-specific configuration lives in lib/app/config/flavor/src/env/*.
- This configuration layer likely feeds startup values into the core services and API endpoints, making environment choice a first-class architectural concern.
5. Core package as platform layer
- packages/core is the shared platform package and is intentionally split into public API and internal implementation:
- core_api exposes contracts and interfaces
- src/core_* contains the actual implementations
- This separation suggests other packages should depend on abstractions, not concrete internals.
6. Core data subsystem
- core_data contains the infrastructure for app data access:
- network client and HTTP configuration
- interceptors for auth, logging, error handling, retry
- cache and memory cache management
- local storage services and local user repository
- background sync, retry policy, and sync queue
- This is the boundary where remote API calls, local persistence, and offline/retry behavior converge.
7. Core domain subsystem
- core_domain provides reusable business-side primitives:
- failure types such as network, cache, validation, unauthorized
- result/either abstractions for success/failure handling
- base use case classes and pagination helpers
- common validators
- This layer keeps business logic independent from Flutter, network, or storage details.
8. Core services subsystem
- core_services contains app-wide capabilities that are not feature-specific:
- analytics and Firebase analytics integration
- crash reporting via Crashlytics
- remote feature flags
- logging and debug overlays
- notifications and push handling
- permissions
- payment gateway abstractions and Razorpay integration
- authentication/session service
- webview bridge/service
- These services are consumed by the app shell and features through shared contracts.
9. Core UI and utility subsystem
- core_ui packages global UI concerns:
- themes, typography, color palette
- responsive layouts and spacing
- localization and language control
- framework-level progress/loading UI
- core_utils provides shared constants, regex patterns, enums, extensions, formatting helpers, debounce/throttle/retry utilities, and default Firebase options.
- These packages support consistency across all features and reduce duplication.
10. Shared package
- packages/shared holds domain concepts that cross feature boundaries.
- The current tree shows user-domain localization and a shared domain entrypoint.
- This package likely acts as a neutral place for models or abstractions needed by multiple feature modules without pulling in feature-specific code.
11. Feature module pattern
- packages/features/splash demonstrates the feature-package structure:
- API layer: splash_api
- data/state model: splash_state.dart
- presentation: bindings, controller, screen, widget
- The presence of bindings and controllers indicates GetX-based feature composition and state management.
- Each feature is expected to own its UI, state, and feature-specific logic while relying on core/shared packages for shared capabilities.
12. Startup data flow
- Typical runtime flow is:
1. App starts in Flutter entrypoint.
2. Bootstrap chooses flavor/configuration.
3. Dependency injection registers core services and feature dependencies.
4. Router resolves the initial route.
5. Feature modules render UI and call into core data/services as needed.
- This makes startup composition centralized, while feature execution remains modular.
13. Routing and navigation
- Routing is centralized in app/router.
- The repository includes a custom navigator observer, suggesting navigation events are monitored for analytics, logging, or debugging.
- Features likely expose route contracts through their API packages rather than hard-coding navigation dependencies.
14. Platform-specific native layer
- apps/Trucksup/android and apps/Trucksup/ios are standard Flutter host projects.
- Firebase is already configured on both platforms via google-services.json and GoogleService-Info.plist.
- The native layer mainly serves as the platform bootstrap for Flutter and Firebase, not as a separate business logic layer.
15. Code generation and repo tooling
- Melos orchestrates the monorepo, and Mason generates feature/core boilerplate from bricks.
- The bricks/core_module and bricks/feature_module templates mirror the workspace structure, which is important for keeping package boundaries consistent as the repo grows.
Main entry points: pubspec.yaml Monorepo · main.dart Bootstrap · service_injection.dart DI · core_api.dart Core API
Components 21
Workspace
Monorepo root and orchestration
- Monorepo · Melos-managed Flutter monorepo root
pubspec.yaml - Android Host · Android Flutter shell and Firebase config
apps/Trucksup/android - iOS Host · iOS Flutter shell and Firebase config
apps/Trucksup/ios
App Shell
Runnable Flutter application composition
- Bootstrap · Flutter startup and bootstrapping entrypoints
apps/Trucksup/lib/main.dart - App Shell · Top-level app widget wiring
apps/Trucksup/lib/app/app.dart - Config · App-level configuration and flavor plumbing
apps/Trucksup/lib/app/config/app_config.dart - Flavors · Dev, staging, and prod flavor resolution
apps/Trucksup/lib/app/config/flavor/src/flavor_config_service.dart - DI · Registers app and feature dependencies
apps/Trucksup/lib/app/di/service_injection.dart - Router · Central route map and navigation observation
apps/Trucksup/lib/app/router/app_router.dart
Core Platform
Shared platform layer split into API and implementations
- Core API · Public contracts and interfaces for other packages
packages/core/lib/core_api/core_api.dart - Data Layer · Network, cache, storage, and sync infrastructure
packages/core/lib/src/core_data/core_data.dart - Domain Primitives · Failures, results, use cases, and validators
packages/core/lib/src/core_domain/core_domain.dart - Services · Analytics, crashlytics, flags, notifications, payments, auth, webview
packages/core/lib/src/core_services/core_services.dart - Core UI · Themes, layouts, localization, and framework UI helpers
packages/core/lib/src/core_ui/core_ui.dart - Utils · Constants, extensions, formatters, and helper utilities
packages/core/lib/src/core_utils/core_utils.dart
Feature Modules
Independently packaged feature areas
- Splash API · Public route contract for the splash feature
packages/features/splash/lib/splash_api/splash_api.dart - Splash State · Splash feature state model
packages/features/splash/lib/src/data/state_model/splash_state.dart - Splash UI · Bindings, controller, screen, and widget composition
packages/features/splash/lib/src/presentation/views/splash_screen.dart
Shared Domain
Cross-feature domain abstractions
- Shared Domain · Shared user-domain abstractions and localization
packages/shared/lib/shared_domain.dart
Connections 26
- Monorepo → Melos: orchestrates · Workspace tasks are coordinated through Melos
- Monorepo → Bricks: scaffolds · Code generation templates mirror the package structure
- Monorepo → Bootstrap: contains · The runnable app lives in the Trucksup workspace app
- Monorepo → Core API: contains · Core platform package is part of the monorepo
- Monorepo → Shared Domain: contains · Shared abstractions are packaged separately
- Monorepo → Splash API: contains · Feature packages are independently published modules
- Monorepo → Android Host: hosts · Native platform shells support Flutter runtime startup
- Monorepo → iOS Host: hosts · Native platform shells support Flutter runtime startup
- Bootstrap → Config: bootstraps · Startup selects environment and app configuration
- Bootstrap → DI: initializes · Bootstrap wires dependency injection before UI starts
- Bootstrap → Router: starts · Initial navigation is resolved through the router
- Bootstrap → App Shell: launches · Entry points hand off into the app widget tree
- Config → Flavors: selects · Flavor service resolves dev, staging, and prod config
- App Shell → Core UI: uses · Global theming, localization, and layout utilities power the shell
- App Shell → Services: consumes · Shell-level capabilities like analytics and notifications are injected
- DI → Core API: binds · Dependency injection prefers public contracts
- DI → Services: registers · App-wide services are assembled in the composition root
- DI → Data Layer: registers · Data infrastructure is wired into runtime services
- Router → Splash API: routes · Feature route contracts are resolved centrally
- Splash API → Splash UI: drives · Feature contract connects to the feature UI flow
- Splash UI → Splash State: models · Presentation state stays local to the feature
- Core API → Domain Primitives: depends on · Contracts build on shared domain primitives
- Data Layer → Domain Primitives: returns · Repositories and network operations surface domain failures and results
- Services → Core API: implements · Services satisfy shared interfaces and contracts
- Core UI → Utils: reuses · UI layer consumes shared constants and helpers
- Shared Domain → Domain Primitives: aligns with · Shared domain concepts remain compatible with core result and failure types