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!