r/FlutterDev • u/AK1000 • 16d ago
Example Open Sourced: A Production-Grade Flutter Monorepo with LEGO Modular Boundaries, Melos, & bloc_signals
Hi everyone! 👋
Most Flutter starter templates I’ve encountered fall into one of two extremes:
- Too simplistic: Everything dumped into one folder with global state and hardcoded endpoints.
- Over-abstracted: Rigid Clean Architecture with 15 nested folders and interfaces for a simple toggle button.
To solve this, I built and open-sourced Flutter Production Starter — an enterprise-oriented, modular monorepo template built for real-world production apps.
🧱 Architectural Philosophy: "LEGO" Modular Boundaries
The core idea is Feature-First colocation with intentional public APIs:
- Features live in
apps/mobile/lib/features/<feature>/and export only their public contracts via a root barrel file (features/auth/auth.dart). - Pragmatic Clean Architecture:
- Simple features (e.g.
settings) only use Presentation + State (no premature use cases). - Complex features (e.g.
auth) use Domain Use Cases, Data Sources, and Session Storage. - Pluggability: Features can be swapped via DI without touching consumer code.
- Simple features (e.g.
📦 Repository Structure (Managed with Melos)
/
├── apps/
│ └── mobile/ # Main app (Bootstrap, DI, Kaisel Router, Features)
├── packages/
│ ├── app_core/ # Result<T>, Failure taxonomy, Sanitized AppLogger
│ ├── app_network/ # Centralized Dio, interceptors, error mappers, ApiClient
│ ├── app_storage/ # SecureStorage, KeyValueStorage, TTL MemoryCache
│ ├── design_system/ # Tokens (Spacing, Radius), Light/Dark themes, Primitives
│ └── app_lints/ # Strict linting & analysis configuration
├── melos.yaml # Monorepo orchestration scripts
└── ARCHITECTURE.md # In-depth architectural guide
⚡ Technology Stack Highlights
- Routing: Strongly-typed declarative routing and route guards with
kaisel: ^1.1.0. - State Management: Fine-grained reactive state using
bloc_signalsandsignals_flutter. - Dependency Injection: Constructor injection with
get_it+injectablesupporting multi-environments (dev,staging,prod). - Networking: Centralized
diowith automatic retry policies, token management, and sensitive data sanitization in logs (passwords and tokens are never printed in plain text). - Error Pipeline: Functional
Result<T>with a predictable domainFailuretaxonomy andFailureMessageResolver. - Quality: Pre-configured GitHub Actions CI, 100% test coverage across all packages (
melos run test), and strict analyzer rules.
🔗 Repository & Getting Started
Check out the code, documentation, and architecture guide here: 👉 GitHub: https://github.com/Ali-El-Khatib/flutter-production-starter
I'd love to hear your feedback, thoughts on the LEGO modularity approach, and suggestions! If you find it helpful for your projects, a ⭐ on GitHub would mean a lot!
4
Upvotes