Modelizer
Intelligent Flutter & Dart Clean Architecture Model Generator & AST-Aware Updater for VS Code

Overview
Modelizer is an intelligent, bidirectional VS Code companion engineered specifically for Flutter and Dart developers practicing Clean Architecture.
Unlike traditional "one-way" code generator scripts that destroy user modifications upon re-run, Modelizer embeds a syntax-aware Dart Lexer, AST Parser, and surgical source patcher. It not only generates pristine Domain Entities and Data Models from JSON, but also intelligently modifies existing files whenever you add, edit, rename, or remove fields—preserving all comments, annotations, and custom business logic.
Key Features
- 🚀 Complete Clean Architecture Feature Generator: Right-click any folder in the Explorer or use Command Palette to scaffold an entire Flutter feature module: presentation (Screen with BLoC consumer, BLoC, Event, State), domain (Repository interface, UseCase stubs, Request/Response entities), and data (Remote Data Source, Repository Implementation, Request/Response models).
- ⚡ Instant Clean Architecture Model Generation: Generate paired pure Domain Entities (
UserEntity) and Data Models (UserModel) from JSON objects or arrays in seconds.
- 🔄 Intelligent AST-Aware Field Modification: Add, rename, edit, or delete fields in existing Dart files. Modelizer updates the field declaration, generative constructor,
fromJson, toJson, fromEntity, toEntity, copyWith, and equality methods simultaneously.
- 🛡️ Custom Logic & Comment Preservation: AST token range mapping guarantees hand-crafted helper methods, getters, doc-comments (
///), and annotations are never deleted or corrupted.
- 🧩 Project-Aware Dependency Detection: Detects
flutter_bloc, equatable, and workspace feature directories from pubspec.yaml, generating tailored, compatible starter code.
- 🔁 Entity-Model Drift Synchronization: Compares an Entity and Model, highlights missing or mismatched fields, and applies bi-directional synchronization.
- 🔍 Virtual Diff Previews: Review exact line-by-line diffs side-by-side using VS Code's native diff viewer before committing any file changes to disk.
- 🌐 100% Offline & Zero External Process Prerequisites: Embedded pure-TypeScript Dart Lexer & AST Parser executes immediately on macOS, Linux, and Windows with zero network requests and no mandatory SDK dependencies.
- 🎯 Native Dart Tooling Bridge: Automatically runs canonical
dart format and dart analyze when a local Dart SDK is detected.
Supported Workflows
┌────────────────────────────────────────────────────────┐
│ MODELIZER │
├──────────────────────────┬─────────────────────────────┤
│ 1. Feature & Model Gen │ 2. Existing File Evolution │
├──────────────────────────┼─────────────────────────────┤
│ • Generate Feature Module│ • Add Field │
│ • Generate from JSON │ • Edit Field │
│ • Generate Model Only │ • Rename Field │
│ • Generate Entity Only │ • Remove Field │
│ • Nested Models & Lists │ • Sync Entity & Model │
│ • Clean Architecture Pair│ • Regenerate Members │
│ • Type Inference Engine │ • Add Selection to Class │
└──────────────────────────┴─────────────────────────────┘
1. Generate Complete Feature Module (Workflow A)
- In the VS Code Explorer, right-click on any folder (e.g.
lib/features).
- Select Modelizer: Generate Feature Module (or run via Command Palette or Sidebar).
- Enter a human-readable feature name (e.g.
Order Tracking or User Profile).
- Select BLoC architecture settings:
[✓] Use custom BLoC settings (selected by default): Generates production Clean Architecture with a single Equatable state class (Status enum, copyWith, failure, and message), sealed event, use case execution with result.fold(...), and UI BlocConsumer. Automatically detects and imports project core package if present.
- If unchecked: Generates classic multi-class subclass states (
InitialState, LoadingState, SuccessState, FailureState).
- Modelizer creates the complete Clean Architecture folder tree and scaffolding:
<feature_name>/
├── presentation/
│ ├── screens/
│ │ └── <feature_name>_screen.dart
│ └── bloc/
│ ├── <feature_name>_event.dart
│ ├── <feature_name>_bloc.dart
│ └── <feature_name>_state.dart
├── domain/
│ ├── usecases/
│ │ └── fetch_<feature_name>_usecase.dart
│ ├── entities/
│ │ ├── request/
│ │ └── response/
│ └── repository/
│ └── <feature_name>_repository.dart
└── data/
├── model/
│ ├── request/
│ └── response/
├── repository/
│ └── <feature_name>_repository_impl.dart
└── data_sources/
└── <feature_name>_remote_data_source.dart
- Pre-existing files are automatically protected against accidental overwrites.
- The new feature screen opens immediately in your editor ready for development.
2. Generate from JSON (Workflow B)
- Open Command Palette (
Cmd+Shift+P / Ctrl+Shift+P).
- Run
Modelizer: Generate From JSON.
- Paste a JSON object or array.
- Enter base class name (e.g.
User).
- Choose target:
Entity & Model Pair (Clean Architecture)
Data Model Only
Domain Entity Only
- Preview the proposed files in the side-by-side Diff Viewer.
- Click Apply Changes.
2. Add Field to Existing Model / Entity (Workflow B)
- Open any existing Dart entity or model file.
- Run
Modelizer: Add Field (or right-click in editor).
- Enter field name (e.g.,
phoneNumber), type (String?), and JSON key (phone_number).
- If a counterpart file exists (e.g.,
user_entity.dart for user_model.dart), choose Update both Model and Entity.
- Modelizer surgically updates:
- Field declarations
- Primary constructor (
required this... / super...)
factory Model.fromJson(...)
Map<String, dynamic> toJson()
factory Model.fromEntity(...)
Entity toEntity()
copyWith(...)
props or operator == / hashCode
- Preview diff and apply changes.
3. Rename Field (Workflow C)
- Run
Modelizer: Rename Field.
- Select target field from QuickPick.
- Enter new name and choose whether to update the JSON key mapping.
- References across constructor, JSON methods, and entity converters update safely.
4. Remove Field (Workflow D)
- Run
Modelizer: Remove Field.
- Select field to delete.
- The field and its references across all methods are removed cleanly.
5. Synchronize Entity and Model (Workflow E)
- Run
Modelizer: Sync Entity and Model.
- Modelizer identifies structural discrepancies and displays an interactive checklist.
- Select fields to synchronize and apply.
6. Regenerate Members (Workflow F)
- Run
Modelizer: Regenerate Members.
- Select specific methods to rebuild (
fromJson, toJson, copyWith, etc.).
- Custom helper methods remain intact.
Code Generation Example
Generated Domain Entity (lib/features/user/domain/entities/user_entity.dart)
class UserEntity {
final int id;
final String name;
final String? bio;
const UserEntity({
required this.id,
required this.name,
this.bio,
});
UserEntity copyWith({
int? id,
String? name,
String? bio,
}) {
return UserEntity(
id: id ?? this.id,
name: name ?? this.name,
bio: bio ?? this.bio,
);
}
}
Generated Data Model (lib/features/user/data/models/user_model.dart)
import '../../domain/entities/user_entity.dart';
class UserModel extends UserEntity {
const UserModel({
required super.id,
required super.name,
super.bio,
});
factory UserModel.fromJson(Map<String, dynamic> json) {
return UserModel(
id: (json['id'] as num).toInt(),
name: json['name'] as String,
bio: json['bio'] as String?,
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'bio': bio,
};
}
factory UserModel.fromEntity(UserEntity entity) {
return UserModel(
id: entity.id,
name: entity.name,
bio: entity.bio,
);
}
UserEntity toEntity() {
return UserEntity(
id: id,
name: name,
bio: bio,
);
}
UserModel copyWith({
int? id,
String? name,
String? bio,
}) {
return UserModel(
id: id ?? this.id,
name: name ?? this.name,
bio: bio ?? this.bio,
);
}
}
Configuration Settings
Configure via VS Code Settings (Cmd+, / Ctrl+,) search for Modelizer:
| Setting |
Type |
Default |
Description |
modelizer.featureModuleTemplate |
enum |
'cleanArchitectureBloc' |
Template used for generating Flutter feature modules. |
modelizer.useEquatableInBloc |
enum |
'auto' |
Extends Equatable in BLoC events/states: 'auto', 'always', or 'never'. |
modelizer.dateStrategy |
enum |
'iso8601' |
Date strategy: 'iso8601', 'timestamp', or 'string'. |
modelizer.equalityStrategy |
enum |
'plain' |
'plain' (Dart operator== & hashCode) or 'equatable'. |
modelizer.copyWithStrategy |
enum |
'standard' |
'standard' (clean idiomatic copyWith) or 'sentinel'. |
modelizer.formatWithDart |
boolean |
true |
Automatically run dart format when Dart SDK is available. |
modelizer.defaultModelSuffix |
string |
'Model' |
Suffix for generated data model classes. |
modelizer.defaultEntitySuffix |
string |
'Entity' |
Suffix for generated domain entity classes. |
Installation
From VS Code Marketplace
Search for Modelizer by Soham Kolhe in the Extensions view (Cmd+Shift+X / Ctrl+Shift+X), or install via terminal:
code --install-extension sohamkolhe.modelizer
From VSIX Package Directly
code --install-extension modelizer-1.0.1.vsix
Method 2: From VS Code Extensions View
- Open VS Code.
- Press
Cmd+Shift+X (macOS) or Ctrl+Shift+X (Windows/Linux) to open the Extensions view.
- Click the
... menu in the top right of the Extensions panel.
- Select Install from VSIX...
- Choose
modelizer-1.0.1.vsix.
Available Commands
Access all commands via Command Palette (Cmd+Shift+P on macOS / Ctrl+Shift+P on Windows/Linux) or the Modelizer Sidebar:
| Command |
Identifier |
Description |
| Generate Feature Module |
modelizer.generateFeatureModule |
Scaffolds complete Clean Architecture + BLoC feature structure |
| Focus Sidebar |
modelizer.openSidebar |
Opens the Modelizer Clean Architecture sidebar panel |
| Generate From JSON |
modelizer.generateFromJson |
Generate paired Entity and Model from raw JSON |
| Generate Entity |
modelizer.generateEntity |
Generate pure Domain Entity from JSON |
| Generate Model |
modelizer.generateModel |
Generate Data Model from JSON |
| Add Selected Fields to UI Entity |
modelizer.addToUiEntity |
Parses comma-separated selection and injects into UI Entity |
| Add Selected Fields to Entity or Model |
modelizer.addToEntityOrModel |
Parses selection and injects into Domain Entity or Model |
| Add Selected Fields to Class |
modelizer.addFieldsFromSelection |
Adds comma-separated fields to any targeted class |
| Add Field |
modelizer.addField |
Add a single field to an existing Dart class via prompts |
| Edit Field |
modelizer.editField |
Update type, nullability, or default value of an existing field |
| Rename Field |
modelizer.renameField |
Rename a field and update constructor, copyWith, & JSON mappings |
| Remove Field |
modelizer.removeField |
Safely removes a field and all its references from a class |
| Sync Entity and Model |
modelizer.syncEntityAndModel |
Detects drift and synchronizes fields between Entity and Model |
| Regenerate Members |
modelizer.regenerateMembers |
Re-builds constructor, copyWith, and JSON serialization |
| Accept All Changes |
modelizer.acceptAll |
Accepts all proposed changes from the review queue |
| Reject All Changes |
modelizer.rejectAll |
Discards all proposed changes from the review queue |
Local Development Setup
Prerequisites:
- Node.js:
v20.x or higher
- npm:
v10.x or higher
- VS Code:
^1.85.0
# 1. Clone repository
git clone https://github.com/sohamkolhe9829/modelizer.git
cd modelizer
# 2. Switch to development branch
git checkout dev
# 3. Install dependencies
npm ci
# 4. Compile TypeScript in watch mode
npm run watch
# 5. Execute test suite
npm test
# 6. Package extension VSIX locally
npm run package
Press F5 in VS Code to open an Extension Development Host window and test live changes with full debugging capabilities.
Branch Strategy & Contributing
Modelizer follows a strict two-branch version control policy:
main: Protected branch containing only production-ready, release-tested code. Releases are published exclusively from main.
dev: Active integration branch for development. All feature and bugfix branches merge into dev.
For full details on Conventional Commits, Semantic Versioning, Pull Request guidelines, and release procedures, see VERSION_CONTROL_RULES.md.
Documentation Links
License
Released under the MIT License.
| |