{"id":51105388,"url":"https://github.com/bariskokulu/CRUDGen","last_synced_at":"2026-07-09T19:00:54.792Z","repository":{"id":361229549,"uuid":"1092001372","full_name":"bariskokulu/CRUDGen","owner":"bariskokulu","description":"Compile-time annotation processor for Spring Boot. Generates predictable REST APIs, DTOs, JSON Patch endpoints, and N+1 safe JPA repositories without runtime reflection.","archived":false,"fork":false,"pushed_at":"2026-06-10T22:11:39.000Z","size":231,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-11T00:08:38.968Z","etag":null,"topics":["annotation-processor","boilerplate","code-generator","dto","java","jpa","json-patch","mapstruct","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bariskokulu.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2025-11-07T20:53:27.000Z","updated_at":"2026-06-10T22:11:44.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bariskokulu/CRUDGen","commit_stats":null,"previous_names":["bariskokulu/crudgen"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bariskokulu/CRUDGen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bariskokulu%2FCRUDGen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bariskokulu%2FCRUDGen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bariskokulu%2FCRUDGen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bariskokulu%2FCRUDGen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bariskokulu","download_url":"https://codeload.github.com/bariskokulu/CRUDGen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bariskokulu%2FCRUDGen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35309828,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-09T02:00:07.329Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["annotation-processor","boilerplate","code-generator","dto","java","jpa","json-patch","mapstruct","spring-boot"],"created_at":"2026-06-24T14:00:22.743Z","updated_at":"2026-07-09T19:00:54.774Z","avatar_url":"https://github.com/bariskokulu.png","language":"Java","funding_links":[],"categories":["Projects"],"sub_categories":["Code Generators"],"readme":"# CrudGen\n\nCompile-time annotation processor for Spring Boot 3 and 4. Annotate a JPA/Mongo entity or a use-case class; CrudGen generates repositories, services, REST controllers, immutable DTOs, and MapStruct mappers.\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.bariskokulu/crudgen.svg)](https://central.sonatype.com/artifact/io.github.bariskokulu/crudgen)\n\n## Features\n\n- **Compile-time generation** — The processor runs in the `javac` annotation-processing round and emits plain `.java` sources. No runtime bytecode weaving, no reflection-based code paths in generated controllers or services.\n- **N+1-safe JPA reads** — When `RepoType.JPA` is used and the Read DTO includes `relation=true` fields, generated repositories expose `@EntityGraph` read methods; services call them on `get` / `getAll` / `getPaged`. Relation binding stays out of MapStruct mappers.\n- **JSON Patch updates** — With `\"Update\"` in `dtos`, generated controllers expose `PATCH /{id}` and `PATCH /batch` consuming `application/json-patch+json`, applying patches via zjsonpatch and validating the merged DTO.\n- **Configurable surface per type** — `dtos`, `controllerPath`, `service`, `extend*` / `custom*`, and `@EndpointGen` control which layers and endpoints are generated. Empty `controllerPath` skips controller, DTOs, and mapper; `customRepo` / `customService` / `customController` swap in your implementations.\n\n## Quick comparison (before / after)\n\n### Before — annotated entity only\n\n```java\n@Entity\n@CrudGen(\n    controllerPath = \"/api/widgets\",\n    dtos = { \"Read\", \"Create\" },\n    securityService = false,\n    lifecycleHooks = false,\n    openApi = false,\n    logging = false\n)\npublic class Widget {\n    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private Long id;\n\n    @DTOField(dto = \"Read\")\n    @DTOField(dto = \"Create\")\n    @NotBlank @Size(max = 200)\n    private String name;\n}\n```\n\n### After — one `compileJava` pass\n\n```\ncom.example.app/\n├── WidgetRepository.java      # JpaRepository (+ @FindBy / @FindAllBy when declared)\n├── WidgetService.java         # @Service, @Transactional mutations\n├── WidgetController.java      # @RestController under controllerPath\n├── WidgetReadDTO.java         # immutable; Bean Validation mirrored from entity fields\n├── WidgetCreateDTO.java\n├── WidgetMapper.java          # MapStruct @Mapper(componentModel = \"spring\")\n└── WidgetMapperImpl.java      # MapStruct annotation-processor output\n```\n\nRepresentative generated code:\n\n```java\n@Repository\npublic interface WidgetRepository extends JpaRepository\u003cWidget, Long\u003e, JpaSpecificationExecutor\u003cWidget\u003e {}\n\n@Service\npublic class WidgetService {\n  public Widget get(Long id) { return repo.findById(id).orElse(null); }\n  @Transactional public Widget create(Widget entity) { return repo.save(entity); }\n}\n\n@RestController\n@RequestMapping(\"/api/widgets\")\npublic class WidgetController {\n  @GetMapping(\"/{id}\")\n  public ResponseEntity\u003cWidgetReadDTO\u003e get(@PathVariable Long id) {\n    Widget entity = service.get(id);\n    if (entity == null) throw new ResponseStatusException(NOT_FOUND, \"Entity with id \" + id + \" not found.\");\n    return ResponseEntity.ok(mapper.get(entity));\n  }\n  @PostMapping(\"/\")\n  public ResponseEntity\u003cWidgetReadDTO\u003e create(@Valid @RequestBody WidgetCreateDTO dto) { /* ... */ }\n}\n\n@Mapper(componentModel = \"spring\")\npublic interface WidgetMapper {\n  WidgetReadDTO get(Widget entity);\n  Widget create(WidgetCreateDTO dto);\n}\n\npublic class WidgetReadDTO {\n  @NotBlank @Size(max = 200)\n  private final String name;\n  @JsonCreator\n  public WidgetReadDTO(@JsonProperty(\"name\") String name) { this.name = name; }\n}\n```\n\n**Coordinates:** `io.github.bariskokulu:crudgen:1.1.1`  \n**Bytecode:** Java 17 (your app JDK and Spring Boot version are independent).\n\n## What the library does\n\n| Area | Annotations |\n|------|-------------|\n| Entity CRUD | `@CrudGen` on a class with `@Id` |\n| DTOs + validation mirror | `@DTOField` + `dtos = {Read, Create, Update}` |\n| Field queries | `@FindBy`, `@FindAllBy` |\n| JSON Patch updates | `\"Update\"` in `dtos` + zjsonpatch on compile classpath |\n| FK relations in API | `@DTOField(relation = true)` + `{Entity}RelationApplier` |\n| Persistence backends | `RepoType.JPA`, `MONGO`, `PLAIN` |\n| Custom / extended layers | `customRepo`, `customService`, `customController`, `extend*` |\n| Use-case HTTP | `@EndpointGen` + `@Endpoint` |\n| Cross-cutting | `CrudGenSecurityService`, `EntityLifecycleCallbacks` (optional) |\n\n## Install\n\n**Gradle (Kotlin DSL)**\n\n```kotlin\ndependencies {\n    compileOnly(\"io.github.bariskokulu:crudgen:1.1.1\")\n    annotationProcessor(\"org.projectlombok:lombok:1.18.42\")           // if used\n    annotationProcessor(\"org.mapstruct:mapstruct-processor:1.5.5.Final\") // Boot 4: 1.6.3\n    annotationProcessor(\"io.github.bariskokulu:crudgen:1.1.1\")\n}\n```\n\n**Maven** — `provided` dependency + `annotationProcessorPaths`: **Lombok → MapStruct → CrudGen**.\n\n## Minimal usage\n\n```java\n@Entity\n@CrudGen(\n    controllerPath = \"/api/widgets\",\n    dtos = { \"Read\", \"Create\" },\n    securityService = false,\n    lifecycleHooks = false,\n    openApi = false,\n    logging = false\n)\npublic class Widget {\n    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private Long id;\n\n    @DTOField(dto = \"Read\")\n    @DTOField(dto = \"Create\")\n    @NotBlank\n    private String name;\n}\n```\n\nGenerates repository, service, controller, Read/Create DTOs, and mapper. Step-by-step recipes: [docs/EXAMPLES.md](docs/EXAMPLES.md).\n\n## Documentation\n\n| Doc | Content |\n|-----|---------|\n| [docs/EXAMPLES.md](docs/EXAMPLES.md) | Minimal → full usage (inline code) |\n| [docs/ANNOTATIONS.md](docs/ANNOTATIONS.md) | Every annotation parameter |\n| [docs/DECISION-TREE.md](docs/DECISION-TREE.md) | What gets generated and when |\n| [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md) | Build and runtime failures |\n\nAgent skills (Cursor + Claude): `.cursor/skills/crudgen/SKILL.md` and `.claude/skills/crudgen/SKILL.md` — keep identical when the processor changes.\n\n## Requirements\n\n**Your application**\n\n- Java **17+** for compiling against the processor; runtime JDK is your choice.\n- Spring Boot **3.2+** or **4.0+** with Web MVC and (for entities) Spring Data JPA or Mongo, or `RepoType.PLAIN` with your repository implementation.\n- **MapStruct** `1.5.5.Final` (Boot 3) or `1.6.3` (Boot 4) when `controllerPath` is set.\n- **JSON Patch** only if `Update` is in `dtos`: zjsonpatch `0.4.x` (Jackson 2) or `0.6.2+` (Jackson 3).\n- Bean Validation: processor mirrors `javax.validation` or `jakarta.validation` from your compile classpath.\n\n| Stack | Web starter | MapStruct | zjsonpatch (Update DTO) |\n|-------|-------------|-----------|-------------------------|\n| Boot 3 | `spring-boot-starter-web` | 1.5.5.Final | `com.flipkart.zjsonpatch:zjsonpatch:0.4.16` |\n| Boot 4 | `spring-boot-starter-webmvc` | 1.6.3 | `io.github.vishwakarma:zjsonpatch:0.6.2` |\n\n## Security and lifecycle (optional)\n\nDefaults: `securityService = true`, `lifecycleHooks = true`. The processor may emit:\n\n- `com.bariskokulu.crudgen.security.CrudGenSecurityService`\n- `com.bariskokulu.crudgen.lifecycle.EntityLifecycleCallbacks\u003cT\u003e`\n\nImplement in your application, or set both flags to `false` on **every** `@CrudGen` / `@EndpointGen` type so the interfaces are not generated.\n\n## License\n\nApache License 2.0 — [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbariskokulu%2FCRUDGen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbariskokulu%2FCRUDGen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbariskokulu%2FCRUDGen/lists"}