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 assets folder and generates a type-safe Assets class.
  • Localization Sync: Synchronize language constants, lists, and files with the lang command.
  • Gemini Localization: Automatically translates localization files using Gemini AI with the translate command.
  • 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:

  1. Compile the executable:

    dart build cli
    
  2. Move the binary to your local bin directory:

    mkdir -p ~/bin
    mv build/bundle/bin/getxcli ~/bin/
    
  3. Ensure ~/bin is 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 ~/.zshrc with ~/.bash_profile)

  4. 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 between getx (default) or go (GoRouter).
  • -s, --storage: Choose between SP (SharedPreferences - default) or GS (GetStorage).
  • -f, --firebaseop: Generate firebase_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.dart and lang command.

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 to en).

Requirements:

  • Support language file lib/core/constants/support_language.dart must be configured.
  • Gemini CLI installed and GEMINI_API_KEY configured.

6. Utility Commands

  • Refresh Project: Runs flutter clean and flutter 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!