Skip to content

alfayedoficial/FastCodeGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FastCodeGen - Kotlin Code Generator Plugin

Version IntelliJ Plugin Kotlin

FastCodeGen is a powerful IntelliJ IDEA / Android Studio plugin that accelerates Kotlin development by automatically generating boilerplate code for ViewModels, Repositories, Compose Screens, and complete features following clean architecture principles.


🎯 What's New in Version 1.0.6

🎨 Screen Generation (NEW!)

  • Jetpack Compose Screen Generation - Automatically create complete Compose screens
  • Navigation Integration - Built-in support for multiple navigation types:
    • None - Simple screen without navigation
    • Simple - Using composableRoute for standard navigation
    • Type-Safe - Using composableSafeType with @Serializable
  • Navigation Parameters - Define and inject navigation parameters automatically
  • ViewModel Integration - Auto-wire ViewModels with state collection

βš™οΈ Enhanced Settings System

  • Browse & Auto-Detect - Click πŸ“ to browse files and auto-detect package paths
  • Dynamic Imports - All imports are now based on your configuration
  • Navigation Utilities - Configure composableRoute and composableSafeType paths
  • Validation - Settings are validated before code generation

πŸ—οΈ Architecture Improvements

  • Modular Panel System - Clean separation of UI components
  • Generation Manager - Centralized business logic
  • 80% Code Reduction - Main dialog simplified from 800+ to ~150 lines
  • StringUtils - Built-in utilities for case conversion

πŸ”§ Feature Enhancements

  • Include Load Method - Optional load() method for ViewModel initialization
  • Optional Repository Methods - Methods, parameters, and return types can be empty
  • Improved Validation - Better error messages and validation
  • Enhanced UX - Settings button in dialog, help menu, documentation access

πŸ“‹ Features

Code Generation Types

1. ViewModel State

Generate complete ViewModel with:

  • State sealed class (Idle, Loading, Success, Error)
  • Event sealed class (optional)
  • UIState data class (optional, with Refreshable support)
  • Intent sealed class
  • ViewModel class with proper configuration
  • Optional load() method for initialization

2. Repository

Generate repository with:

  • Repository interface with custom methods
  • Repository implementation with HttpClient support (optional)
  • Flow-based async operations
  • Fully optional methods, parameters, and return types

3. Compose Screen (NEW!)

Generate Jetpack Compose screen with:

  • Complete Composable function structure
  • Navigation parameter support (Simple or Type-Safe)
  • Optional ViewModel integration with state collection
  • Navigation back support
  • LaunchedEffect for initialization
  • State handling (Loading, Success, Error, Idle)

4. Full Feature

Generate complete feature including:

  • Compose Screen (optional)
  • ViewModel State components (optional)
  • Repository components (optional)
  • Organized folder structure
  • Proper imports and dependencies

Configuration Options

  • βœ… Generate Screen - Create Jetpack Compose screen
  • βœ… Generate ViewModel - Include ViewModel State files
  • βœ… Generate Repository - Include Repository files
  • βœ… Enable Events - Add event handling to ViewModel
  • βœ… Enable Refresh - Add refresh capability
  • βœ… Enable UIState - Include UI state management
  • βœ… Include Load Method - Add initialization method to ViewModel
  • βœ… Navigation Type - Choose navigation approach (None/Simple/Type-Safe)
  • βœ… Navigation Parameters - Define parameters for type-safe navigation
  • βœ… Use Cases - Specify use case dependencies
  • βœ… HTTP Client - Include Ktor HttpClient in repository
  • βœ… Custom Methods - Define repository methods with optional params and return types

πŸš€ Quick Start

First-Time Setup

  1. Install the Plugin

    • Open Settings β†’ Plugins β†’ Marketplace
    • Search for "FastCodeGen"
    • Click Install and restart IDE
  2. Configure Settings (One-time setup)

    • Right-click on any package β†’ New β†’ FastCodeGen
    • Click βš™οΈ Settings button
    • Configure all required paths:
      • Click πŸ“ next to each field
      • Browse to your base class file (e.g., AppViewModel.kt)
      • Plugin auto-detects the full package path
    • Click OK to save
  3. Start Generating!

    • Right-click on target package
    • Select New β†’ FastCodeGen
    • Choose generation type and configure options

πŸ“¦ Installation

From JetBrains Marketplace

  1. Open Settings/Preferences β†’ Plugins
  2. Search for "FastCodeGen"
  3. Click Install
  4. Restart IDE

Manual Installation

  1. Download the plugin .zip from releases
  2. Settings/Preferences β†’ Plugins β†’ βš™οΈ β†’ Install Plugin from Disk
  3. Select the downloaded file
  4. Restart IDE

🎯 Usage Guide

Generating a Complete Feature

Example: Create a Login Feature with Screen, ViewModel, and Repository

  1. Right-click on your feature package
  2. Select New β†’ FastCodeGen
  3. Select Full Feature
  4. Click Next β†’
  5. Configure:
    Feature Name: Login
    
    Generation Options:
    βœ… Generate Screen
    βœ… Generate ViewModel
    βœ… Generate Repository
    
    Screen Configuration:
    βœ… Has Navigation Back
    Navigation Type: Type-Safe
    Parameters:
      - email: String
      - fromSignup: Boolean
    
    ViewModel Configuration:
    βœ… Enable Events
    βœ… Enable Refresh
    βœ… Enable UIState
    βœ… Include Load Method
    Use Cases: AuthenticationUseCase
    
    Repository Configuration:
    βœ… Needs HttpClient
    Methods:
      - login(email: String, password: String) β†’ Flow<User>
      - validateSession() β†’ Flow<Boolean>
    
  6. Click Generate

Generated Structure:

login/
β”œβ”€β”€ ui/
β”‚   └── LoginScreen.kt
β”œβ”€β”€ viewmodel/
β”‚   β”œβ”€β”€ state/
β”‚   β”‚   β”œβ”€β”€ LoginState.kt
β”‚   β”‚   β”œβ”€β”€ LoginEvent.kt
β”‚   β”‚   β”œβ”€β”€ LoginUIState.kt
β”‚   β”‚   └── LoginIntent.kt
β”‚   └── LoginViewModel.kt
β”œβ”€β”€ domain/
β”‚   └── repo/
β”‚       └── LoginRepo.kt
└── data/
    └── repo/
        └── LoginRepoImpl.kt

Generating Individual Components

Screen Only

Generation Type: Screen
Feature Name: Profile
βœ… Has Navigation Back
Navigation Type: Simple

ViewModel Only

Generation Type: ViewModel State
Feature Name: Dashboard
βœ… Enable Events
βœ… Include Load Method
Use Cases: GetStatsUseCase

Repository Only

Generation Type: Repository
Feature Name: User
βœ… Needs HttpClient
Methods:
  - getUser(id: String) β†’ Flow<User>
  - updateProfile(user: User) β†’ Flow<Unit>

πŸ”§ Requirements

  • IntelliJ IDEA 2024.2+ or Android Studio Koala+
  • Kotlin plugin enabled
  • Kotlin project with standard source structure
  • Base classes configured in settings
  • Jetpack Compose (optional, for screen generation)
  • Navigation Compose (optional, for navigation features)

βš™οΈ Settings Configuration

Required Base Classes

Configure the full package paths for:

Setting Description Example
AppViewModel Your base ViewModel class com.myapp.core.viewmodel.AppViewModel
ViewModelConfig Configuration class com.myapp.core.viewmodel.ViewModelConfig
BaseState Base state interface com.myapp.core.viewmodel.BaseState
BaseEvent Base event interface com.myapp.core.viewmodel.BaseEvent
BaseUIState Base UI state interface com.myapp.core.viewmodel.BaseUIState
Refreshable Refreshable interface com.myapp.core.viewmodel.Refreshable
BaseIntent Base intent interface com.myapp.core.viewmodel.BaseIntent

Required Navigation Utilities

Setting Description Example
composableRoute Function for simple navigation com.myapp.core.utilities.composableRoute
composableSafeType Function for type-safe navigation com.myapp.core.utilities.composableSafeType

Optional Settings

Setting Description Example
Koin Module Dependency injection module org.koin.core.module.Module

πŸ’‘ Code Examples

Generated Screen with Type-Safe Navigation

package com.myapp.profile.ui

import androidx.compose.runtime.*
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.myapp.profile.viewmodel.ProfileIntent
import com.myapp.profile.viewmodel.ProfileViewModel
import com.myapp.profile.viewmodel.state.ProfileState
import org.koin.androidx.compose.koinViewModel

@Composable
fun ProfileScreen(
    userId: String,
    fromSettings: Boolean,
    navigationBack: () -> Unit,
    viewModel: ProfileViewModel = koinViewModel()
) {
    val state by viewModel.state.collectAsStateWithLifecycle()
    val uiState by viewModel.uiState.collectAsStateWithLifecycle()

    LaunchedEffect(Unit) {
        viewModel.handleIntent(ProfileIntent.LoadProfile(userId))
    }

    when (val currentState = state) {
        is ProfileState.Loading -> LoadingContent()
        is ProfileState.Success -> ProfileContent(
            data = currentState.data,
            uiState = uiState,
            onIntent = viewModel::handleIntent
        )
        is ProfileState.Error -> ErrorContent(
            message = currentState.message,
            onRetry = { viewModel.handleIntent(ProfileIntent.LoadProfile(userId)) }
        )
        ProfileState.Idle -> IdleContent()
    }
}

Generated ViewModel with Load Method

package com.myapp.login.viewmodel

import com.myapp.core.viewmodel.AppViewModel
import com.myapp.core.viewmodel.ViewModelConfig
import com.myapp.login.viewmodel.state.LoginIntent
import com.myapp.login.viewmodel.state.LoginState
import com.myapp.login.viewmodel.state.LoginEvent
import com.myapp.login.viewmodel.state.LoginUIState

class LoginViewModel(
    private val authenticationUseCase: AuthenticationUseCase
) : AppViewModel<LoginState, LoginEvent, LoginUIState, LoginIntent>(
    initialState = LoginState.Idle,
    initialUIState = LoginUIState(),
    config = ViewModelConfig(
        enableRefresh = true,
        enableEvents = true
    )
) {

    init {
        loadLogin()
    }

    override fun handleIntent(intent: LoginIntent) {
        when (intent) {
            is LoginIntent.ClearState -> setState(LoginState.Idle)
            is LoginIntent.LoadLogin -> loadLogin()
            is LoginIntent.RefreshRequest -> refreshRequest { loadLogin() }
        }
    }

    override fun createErrorState(message: String): LoginState {
        return LoginState.Error(message)
    }

    override fun createErrorEvent(message: String): LoginEvent {
        return LoginEvent.Error(message)
    }

    private fun loadLogin() {
        launch {
            setState(LoginState.Loading)
            // TODO: Implement
        }
    }
}

Generated Repository

// Interface
package com.myapp.user.domain.repo

import kotlinx.coroutines.flow.Flow

interface UserRepo {
    fun getUser(userId: String): Flow<User>
    fun updateUser(user: User): Flow<Unit>
    fun deleteUser(userId: String): Flow<Boolean>
}

// Implementation
package com.myapp.user.data.repo

import com.myapp.user.domain.repo.UserRepo
import io.ktor.client.HttpClient
import kotlinx.coroutines.flow.Flow

class UserRepoImpl(
    private val httpClient: HttpClient,
) : UserRepo {

    override fun getUser(userId: String): Flow<User> {
        TODO("Not yet implemented")
    }

    override fun updateUser(user: User): Flow<Unit> {
        TODO("Not yet implemented")
    }

    override fun deleteUser(userId: String): Flow<Boolean> {
        TODO("Not yet implemented")
    }
}

πŸ† Benefits

For Developers

  • ⚑ Save Time - Generate complete features in seconds
  • 🎯 Consistency - Follow best practices automatically
  • πŸ”§ Customizable - Adapt to your project structure
  • πŸ“¦ Clean Code - Well-organized, maintainable output
  • 🎨 Modern Stack - Built for Compose and modern Android

For Teams

  • πŸ“ Standardization - Same code structure across team
  • πŸ“š Onboarding - New developers start faster
  • πŸ”„ Productivity - Focus on business logic, not boilerplate
  • βœ… Quality - Reduce human error

πŸ› Troubleshooting

Settings Not Saved

Solution:

  • Ensure all required fields are filled
  • Click OK (not Cancel)
  • Restart IDE if needed

Generated Code Has Errors

Solution:

  • Verify settings paths are correct using βš™οΈ button
  • Check that base classes exist in your project
  • Ensure Kotlin plugin is enabled
  • For screens, verify Compose dependencies are added

Plugin Not Appearing

Solution:

  • Check minimum IDE version (2024.2+)
  • Verify Kotlin plugin is enabled
  • Try: File β†’ Invalidate Caches β†’ Restart

Screen Generation Issues

Solution:

  • Ensure Jetpack Compose dependencies are in build.gradle
  • Verify navigation utilities paths in settings
  • Check that composableRoute or composableSafeType exist

Navigation Not Working

Solution:

  • For Simple navigation: Configure composableRoute path
  • For Type-Safe navigation: Configure composableSafeType path
  • Ensure navigation utility functions match your project structure

πŸ“š Documentation

Access comprehensive documentation from the plugin:

  • πŸ“– README - This getting started guide
  • πŸ“š User Guide - Detailed tutorials and examples
  • ⚑ Quick Reference - Cheat sheet for quick lookup
  • πŸ”§ Implementation Steps - Setup instructions
  • πŸ“Š Plugin Summary - Feature overview
  • πŸ“‘ Complete Index - All documentation

Click the πŸ“š Help button in the dialog to access these resources.


πŸ“ Changelog

Version 1.0.6 (November 2025)

🎨 Major Features

  • ✨ Screen Generation - Full Jetpack Compose screen generation with navigation
  • 🧭 Navigation Integration - Support for None, Simple, and Type-Safe navigation
  • πŸ”’ Type-Safe Navigation - Automatic parameter injection with @Serializable
  • 🎯 ViewModel Integration - Auto-wire ViewModels with screens

πŸ—οΈ Architecture & Refactoring

  • 🎨 Refactored UI into modular panel system
  • πŸ”§ Introduced GenerationManager for centralized logic
  • πŸ“¦ 80% code reduction in main dialog (800+ β†’ ~150 lines)
  • πŸ› οΈ Added StringUtils utility (toCamelCase, toPascalCase, toSnakeCase)

βš™οΈ Settings & Configuration

  • ✨ Comprehensive settings dialog with browse buttons
  • πŸ“ Auto-detect package paths from selected files
  • πŸ”§ Dynamic imports based on user configuration
  • 🧭 Navigation utilities configuration
  • βœ… Settings validation before generation
  • πŸ”§ Fixed file chooser implementation

πŸ”§ Enhanced Features

  • βœ… Include Load Method - Optional initialization in ViewModels
  • πŸ“ Optional repository methods (fully supports empty methods)
  • 🎨 Enhanced FeatureGenerator with optional Screen creation
  • πŸ”„ Improved parameter injection in screen generation
  • πŸ“š Enhanced documentation system
  • βš™οΈ Settings button in main dialog
  • πŸ” Better validation and error messages

πŸ› Bug Fixes

  • Fixed file chooser behavior in settings dialog
  • Improved path detection and validation
  • Enhanced error handling in generation process

Version 1.0.0 (October 2025)

  • πŸŽ‰ Initial release
  • ViewModel State generation
  • Repository generation
  • Full Feature generation
  • K2 Compiler Support

🀝 Contributing

Found a bug or have a feature request?


πŸ“„ License

Copyright Β© 2024-2025 Ali Al-Shahat Ali


πŸ”— Links


Made with ❀️ by Ali Al-Shahat Ali

Accelerate your Kotlin development with FastCodeGen

⭐ Star us on GitHub | πŸ’¬ Join the Discussion | πŸ› Report Issues

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages