{"id":48341410,"url":"https://github.com/sanjeev2552/feature_gen_cli","last_synced_at":"2026-04-05T05:02:30.862Z","repository":{"id":341239983,"uuid":"1169408827","full_name":"sanjeev2552/feature_gen_cli","owner":"sanjeev2552","description":"A Dart CLI tool that generates clean-architecture feature modules for Flutter projects from a JSON schema.","archived":false,"fork":false,"pushed_at":"2026-03-31T15:44:27.000Z","size":127,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-31T16:06:20.921Z","etag":null,"topics":["clean-architecture","cli","code-generation"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/feature_gen_cli","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sanjeev2552.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-28T16:40:18.000Z","updated_at":"2026-03-31T15:43:16.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sanjeev2552/feature_gen_cli","commit_stats":null,"previous_names":["sanjeev2552/feature_gen"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/sanjeev2552/feature_gen_cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjeev2552%2Ffeature_gen_cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjeev2552%2Ffeature_gen_cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjeev2552%2Ffeature_gen_cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjeev2552%2Ffeature_gen_cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sanjeev2552","download_url":"https://codeload.github.com/sanjeev2552/feature_gen_cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanjeev2552%2Ffeature_gen_cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31424932,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T02:22:46.605Z","status":"ssl_error","status_checked_at":"2026-04-05T02:22:33.263Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-architecture","cli","code-generation"],"created_at":"2026-04-05T05:02:29.949Z","updated_at":"2026-04-05T05:02:30.857Z","avatar_url":"https://github.com/sanjeev2552.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Feature Gen\n\n[![pub package](https://img.shields.io/pub/v/feature_gen_cli.svg)](https://pub.dev/packages/feature_gen_cli) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![pub points](https://img.shields.io/pub/points/feature_gen_cli)](https://pub.dev/packages/feature_gen_cli/score)\n\nFeature Gen is a Dart CLI that scaffolds clean-architecture feature modules for Flutter projects from a JSON schema.\n\n## Quick Start\n\n**Requirements:** Dart SDK `\u003e=3.10.4`, a Flutter project with a valid `pubspec.yaml`, and `dart` on your PATH. Run the CLI from the Flutter project root so `pubspec.yaml` resolution works.\n\n```bash\n# 1. Install\ndart pub global activate feature_gen_cli\n\n# 2. Run\nfeature_gen_cli \u003cfeature_name\u003e \u003cschema.json\u003e\n# Example: feature_gen_cli user example/user_schema.json\n\n# Overwrite existing generated files (optional)\nfeature_gen_cli \u003cfeature_name\u003e \u003cschema.json\u003e --overwrite\n```\n\nFeature names should be lowercase `snake_case` (the generated folder is `lib/features/\u003cfeature_name\u003e/`).\n\n### CLI Options\n\n```bash\nfeature_gen_cli \u003cfeature_name\u003e \u003cschema.json\u003e -o   # overwrite existing generated files\nfeature_gen_cli --version                          # print package version\nfeature_gen_cli --help                             # show help\n```\n\n## Schema Reference\n\nThe schema is a single JSON file requiring three sections: `config`, `api.methods`, and `response`.\n\n### Single-Response (one entity for the whole feature)\n\n```json\n{\n  \"config\": { \"bloc\": true, \"riverpod\": false },\n  \"api\": {\n    \"methods\": {\n      \"getUser\":    {},\n      \"updateUser\": { \"body\": { \"name\": \"string\", \"email\": \"string\" } },\n      \"deleteUser\": { \"params\": { \"id\": \"int\" } }\n    }\n  },\n  \"response\": { \"id\": \"int\", \"name\": \"string\" }\n}\n```\n\n### Multi-Response (different entities per method)\n\nWhen different API methods return different types, define each response type by name and add a `\"response\"` key to each method that declares which type it returns.\n\n```json\n{\n  \"config\": { \"bloc\": true, \"riverpod\": false },\n  \"api\": {\n    \"methods\": {\n      \"getUser\":      { \"response\": \"user\" },\n      \"postSomeData\": { \"body\": { \"name\": \"string\", \"email\": \"string\" }, \"response\": \"token\" },\n      \"updateUser\":   { \"body\": { \"name\": \"string\" }, \"response\": \"user\" },\n      \"deleteUser\":   { \"params\": { \"id\": \"int\" } }\n    }\n  },\n  \"response\": {\n    \"user\":  { \"id\": 123, \"name\": \"string\", \"email\": \"string\" },\n    \"token\": { \"accessToken\": \"string\", \"refreshToken\": \"string\", \"tokenType\": \"string\" }\n  }\n}\n```\n\n**Multi-response rules:**\n\n- **Detection** — if all top-level values in `response` are objects, multi-response mode is activated automatically. No extra flag needed.\n- **Per-method binding** — set `\"response\": \"\u003ckey\u003e\"` on any method to link it to a named entity.\n- **List returns** — wrap the key in an array to return a list: `\"response\": [\"user\"]` → `Future\u003cList\u003cUserEntity\u003e\u003e`.\n- **Void methods** — omit `\"response\"` entirely and the method generates `Future\u003cvoid\u003e` across all layers.\n- **Backward compatible** — schemas with primitive values at the top level of `response` continue to work as single-response.\n\n### Common Options\n\n- **`config`**: Both keys (`bloc` and `riverpod`) are required; exactly one must be `true`.\n- **`api.methods`**: Define endpoints (camelCase). Optionally include `params`, `body`, or `query` to generate `UseCase` and param classes.\n- **`response`**: Define entity fields. Supported primitives: `\"string\"`, `\"int\"`, `\"double\"`, `\"bool\"`, `\"list\"`, `\"map\"`. Supports nested objects and arrays.\n\n**Naming Convention Note:** `snake_case` keys in your configuration JSON are automatically generated into `camelCase` variables for your data classes, ensuring code idiomacy. Serialization layers accurately map variables back to their exact original JSON keys using Freezed `@JsonKey` configurations and custom overrides automatically.\n\n## Generated Structure\n\nRunning the CLI produces a complete clean-architecture module in `lib/features/\u003cfeature_name\u003e/`:\n\n```\nlib/features/\u003cfeature\u003e/\n├── data/\n│   ├── datasources/   \u003cfeature\u003e_remote_datasource.dart\n│   ├── models/        \u003centity\u003e_model.dart          (one per entity in multi-response)\n│   └── repositories/  \u003cfeature\u003e_repository_impl.dart\n└── domain/\n    ├── entities/      \u003centity\u003e_entity.dart          (one per entity in multi-response)\n    ├── repositories/  \u003cfeature\u003e_repository.dart\n    └── usecases/      \u003cmethod\u003e_usecase.dart\n└── presentation/\n    ├── bloc/          \u003cfeature\u003e_bloc.dart, _event.dart, _state.dart\n    └── screen/        \u003cfeature\u003e_screen.dart\n```\n\nIn **multi-response mode**, the BLoC and Riverpod states get one typed success factory per method:\n\n```dart\n// generated user_state.dart\nconst factory UserState.getUserSuccess(UserEntity data) = _GetUserSuccessState;\nconst factory UserState.postSomeDataSuccess(TokenEntity data) = _PostSomeDataSuccessState;\nconst factory UserState.deleteUserSuccess() = _DeleteUserSuccessState;\n```\n\nThe CLI automatically adds missing dependencies, runs `build_runner`, and formats the generated code.\n\n## Overwrite Behavior\n\nBy default, the CLI only generates missing files and will not overwrite existing files. Use `--overwrite` (or `-o`) to force regeneration.\n\n## Troubleshooting\n\n- **Schema validation errors**: Ensure `config`, `api.methods`, and `response` exist, and that exactly one of `config.bloc` or `config.riverpod` is `true`.\n- **`build_runner` failed**: Re-run it manually: `dart run build_runner build -d`.\n\n## Support ❤️\n\nIf you find this package helpful, please consider giving it a like on [pub.dev](https://pub.dev/packages/feature_gen_cli) and adding a ⭐ star on [GitHub](https://github.com/sanjeev2552/feature_gen)! Your support is greatly appreciated.\n\n## Contributing\n\n- Install dependencies: `dart pub get`\n- Run tests: `dart test`\n- Format code: `dart format .`\n\nNote: The test suite is pure unit tests and avoids running external commands.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanjeev2552%2Ffeature_gen_cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsanjeev2552%2Ffeature_gen_cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanjeev2552%2Ffeature_gen_cli/lists"}