GetX Clean Architecture CLI
A powerful CLI tool for scaffolding and managing Flutter projects with GetX and Clean Architecture. This tool helps you maintain a scalable project structure, automate repetitive tasks, and enforce best practices.
🚀 Features
- Project Initialization: Sets up the core structure (Network, Theme, Style) and Dependency Injection. Automatically configures Flavors, Firebase placeholders, and localization settings with folder-named barrel files for streamlined imports.
- Feature Generation: Automatically creates Clean Architecture layers (
data,domain,presentation,bindings) and registers them in the routing system automatically. - Asset Generation: Scans your
assetsfolder and generates a type-safeAssetsclass. - Localization Sync: Synchronize language constants, lists, and files with the
langcommand. - Gemini Localization: Automatically translates localization files using Gemini AI with the
translatecommand. - Utilities: Shortcuts for common tasks like project refresh, git branching, and running specific flavors.
- Router Support: Full support for both GetX Router and GoRouter. GetX is always included for state management.
🛠 Installation & Usage
Global Installation (macOS)
To run the CLI globally as getxcli on macOS, follow these steps:
-
Compile the executable:
dart build cli -
Move the binary to your local bin directory:
mkdir -p ~/bin mv build/bundle/bin/getxcli ~/bin/ -
Ensure
~/binis in your PATH: Run this command to automatically add the path to your shell configuration (for Zsh):echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc source ~/.zshrc(If using Bash, replace
~/.zshrcwith~/.bash_profile) -
Verify installation:
getxcli --help
Run from Source
If you don't want to install it globally, you can run it directly:
dart run bin/getxcli.dart <command>
Uninstall
To remove the global installation:
rm ~/bin/getxcli
📚 Commands
1. Initialize Project
Sets up the foundation of your Clean Architecture project.
getxcli init [project_name] --router <getx|go> --storage <SP|GS> --firebaseop
Options:
-r, --router: Choose betweengetx(default) orgo(GoRouter).-s, --storage: Choose betweenSP(SharedPreferences - default) orGS(GetStorage).-f, --firebaseop: Generatefirebase_options.dart(opt-in).
What it does:
- Checks for Flutter and Git environment.
- Creates
lib/core/structure (network, theme, bindings, services, etc.) with folder-named barrel files. - Sets up Flavorizr for dev/prod environments.
- Configures Firebase placeholders and optional options file.
- Initializes Localization architecture with
support_language.dartandlangcommand.
2. Create Feature
Generates a full feature module with all necessary files.
getxcli create <feature_name> --router <getx|go>
Aliases: create:feature, cf
Example:
getxcli create login --router getx
Generated Structure (lib/features/login/):
bindings/: Dependencies for the feature.data/: Data Sources, Models, and Repository implementations.domain/: Entities, Repository interfaces, and Usecases.presentation/: Controllers, Pages, and local Widgets.login.dart: Barrel file exporting public components.
3. Generate Assets
Auto-generates static constants for your assets.
getxcli gen
Alias: generate:assets
Input: assets/images/logo.png
Output (lib/common/utils/assets.dart):
class Assets {
static const String logoPng = 'assets/images/logo.png';
}
4. Language Management
Synchronizes language constants and generates missing translation files based on your supported locales.
getxcli lang
5. Translate Localizations
Automatically translates your localization files using Gemini AI.
getxcli translate --source <lang_code>
Options:
-s, --source: Specify the source language (defaults toen).
Requirements:
- Support language file
lib/core/constants/support_language.dartmust be configured. - Gemini CLI installed and
GEMINI_API_KEYconfigured.
6. Utility Commands
- Refresh Project: Runs
flutter cleanandflutter pub get.getxcli rf # Full command: getxcli refresh - Git Branch: Shortcut to create and switch to a new branch.
getxcli gb <branch_name> # Full command: getxcli branch - Run Flavor: Shortcut to run a specific flavor.
getxcli run <flavor_name> # Full command: getxcli run:flavor
📂 Project Structure
The CLI enforces a Feature-First Clean Architecture:
lib/
├── app.dart # Main App widget configuration
├── main.dart # Entry point with service initialization
├── core/ # Core Layer (Shared across app)
│ ├── bindings/ # DI bindings
│ ├── configs/ # App configs (flavor_config, etc)
│ ├── constants/ # App constants & localities
│ ├── controllers/ # Global controllers
│ ├── data/ # Core data implementations
│ ├── domain/ # Core domain entities/interfaces
│ ├── errors/ # Global error handling
│ ├── routes/ # App Router (AppPages, AppRoutes)
│ ├── services/ # Core services (Storage, API)
│ ├── theme/ # Theme system (MColors, MTheme)
│ ├── translations/ # Multi-language support
│ ├── utils/ # Global utilities
│ └── widgets/ # Shared UI components
└── features/ # Feature Modules
├── auth/ # Example feature module
│ ├── bindings/
│ ├── data/
│ ├── domain/
│ ├── presentation/
│ └── auth.dart # Feature barrel file
└── features.dart # Global features barrel file
🤝 Contributing
Feel free to fork and submit PRs to improve the templates or add new commands!