A production-ready Flutter monorepo architecture featuring clean architecture, modular design, and enterprise-grade tooling.
- Monorepo Architecture - Managed with Melos for efficient multi-package development
- Multi-App Support - Two apps (Member & Admin) sharing common packages
- Multi-Flavor Builds - Dev, Test, and Production environments with flutter_flavorizr
- Clean Architecture - Separation of concerns with feature modules and shared libraries
- State Management - Riverpod for reactive and testable state management
- Type-Safe Routing - go_router with code generation
- Internationalization - easy_localization with nested JSON override strategy
- Dynamic Forms - JSON schema-based form generation with reactive_forms
- CI/CD Ready - Fastlane integration for iOS and Android
anng_source/
├── apps/
│ ├── admin/ # Admin application
│ └── member/ # Member application
├── packages/
│ ├── libraries/ # Shared libraries
│ │ ├── core/ # Utilities, constants, extensions
│ │ ├── design_system/ # UI components, themes, colors
│ │ ├── dynamic_forms/ # JSON schema form generation
│ │ ├── foundation/ # Shared data and domain layers
│ │ ├── localization/ # i18n utilities
│ │ ├── navigation/ # Routing utilities
│ │ ├── network/ # Dio client and interceptors
│ │ └── storage/ # Local and secure storage
│ └── modules/ # Feature modules
│ ├── auth/ # Authentication module
│ ├── demo/ # Demo module
│ ├── main/ # Main/Dashboard module
│ ├── profile/ # Profile module
│ └── setting/ # Settings module
├── bricks/ # Mason bricks for code generation
├── docs/ # Documentation
└── scripts/ # Utility scripts
# Install Melos globally
dart pub global activate melos
# Install FVM (if not installed)
dart pub global activate fvm
# Use the correct Flutter version
fvm install
# Bootstrap the monorepo
melos bootstrap# Run Member app (dev flavor)
melos member:dev
# Run Admin app (dev flavor)
melos admin:dev
# Run with specific flavor
melos member:test
melos member:prod
melos admin:test
melos admin:prod| Script | Description |
|---|---|
melos bootstrap |
Install dependencies for all packages |
melos analyze |
Run flutter analyze in all packages |
melos format |
Format all packages |
melos test |
Run tests in all packages |
melos clean |
Clean all packages |
melos get |
Get dependencies for all packages |
melos build_runner |
Run build_runner in all packages |
melos l10n:generate |
Generate LocaleKeys for all modules |
melos member:dev |
Run member app in dev mode |
melos member:test |
Run member app in test mode |
melos member:prod |
Run member app in prod mode |
melos admin:dev |
Run admin app in dev mode |
melos admin:test |
Run admin app in test mode |
melos admin:prod |
Run admin app in prod mode |
Each app in the apps/ directory is a standalone Flutter application that composes feature modules:
- Member App: Uses
authandmain_module - Admin App: Uses
auth,main_module,profile, andsetting
Shared packages in packages/libraries/ provide cross-cutting concerns:
- core: Common utilities, extensions, and constants
- design_system: Theming, colors, typography, and reusable UI components
- network: HTTP client setup with Dio and interceptors
- storage: Local storage (Sembast) and secure storage
- navigation: Router configuration and navigation utilities
- localization: i18n setup and utilities
- foundation: Shared domain models and data layer abstractions
- dynamic_forms: Generate forms from JSON schema
Feature modules in packages/modules/ encapsulate vertical slices of functionality:
- Each module contains its own pages, routes, and localization
- Modules are independent and can be composed into different apps
- Routes are type-safe using
go_router_builder
Localization files are located in each module's assets/l10n/ directory:
packages/modules/auth/assets/l10n/
├── en.json
└── vi.json
Generate locale keys:
melos l10n:generateEach app supports three flavors configured with flutter_flavorizr:
| Flavor | Bundle ID Pattern | Description |
|---|---|---|
dev |
com.anng.{app}.dev |
Development environment |
test |
com.anng.{app}.test |
Testing/Staging environment |
prod |
com.anng.{app} |
Production environment |
Environment variables are loaded from assets/env.{flavor} files.
Use Mason to generate new feature modules:
# Navigate to project root
mason make module --name my_feature
# Then add the module to your app's pubspec.yamlWhen adding dependencies to a package:
- Add to the package's
pubspec.yaml - Run
melos bootstrapto update all packages
# Run all tests
melos test
# Run tests for a specific package
cd packages/modules/auth
fvm flutter test# Build APK (Android)
cd apps/member
fvm flutter build apk --flavor prod -t lib/main_prod.dart
# Build IPA (iOS)
cd apps/member
fvm flutter build ipa --flavor prod -t lib/main_prod.dartFor more detailed documentation, see the docs folder:
| Document | Description |
|---|---|
| Architecture | Detailed architecture overview and design decisions |
| Implementation Plan | Step-by-step implementation guide |
| Task | Project tasks and requirements |
| Walkthrough | Codebase walkthrough and explanations |
This project is licensed under the MIT License.
Built with ❤️ using Flutter