Skip to main content

Interactive Spring Boot CRUD CLI

Project description

🌱 SpringGen

SpringGen is an interactive CLI tool that generates ready-to-run Spring Boot CRUD boilerplate code — complete with Entities, Repositories, Services, and Controllers — using configurable templates.


🚀 Features

✅ Interactive CLI (no arguments needed)
✅ Supports pagination and sorting (configurable defaults)
✅ Uses YAML config stored under ~/.springgen/config.yml
✅ Generates clean, Lombok-based classes with constructor injection
Jinja2-powered templates (easy to customize)
✅ Auto-detects jakarta.persistence or javax.persistence ✅ Configurable primary key type & generation strategy (global + per entity) ⭐ ✅ Single-folder package mode for compact architectures ✅ Live config editing via CLI or editor ✅ Works cross-platform (Linux / macOS / Windows)


🧩 Installation

pip install springgen

Requires Python ≥ 3.8

⚙️ Usage Simply run:

springgen

You’ll be prompted for entity names and which layers to generate:

Enter entity names (comma-separated): Product, Category
Do you want to generate Repository layer for all entities? [y/n]: y
Do you want to generate Service layer (interface + impl) for all entities? [y/n]: y
Do you want to generate Controller layer for all entities? [y/n]: y

SpringGen will generate:

src/main/java/com/example/demo/
 ├─ model/
    └─ Product.java
 ├─ repository/
    └─ ProductRepository.java
 ├─ service/
    ├─ ProductService.java
    └─ impl/ProductServiceImpl.java
 └─ controller/
     └─ ProductController.java

⚙️ Configuration SpringGen stores configuration at:

~/.springgen/config.yml

🧾 Default Config

base_package: com.example.demo
persistence_package: auto    # auto | jakarta.persistence | javax.persistence
features:
  pagination_and_sorting: true
api:
  defaultPageSize: 10
  defaultSort: id,asc
folders:
  entity: model
  repository: repository
  service: service
  controller: controller
entity:
  primary_key:
    name: id
    type: Long
    strategy: IDENTITY

Edit interactively

springgen --config

Open in your editor

springgen --edit-config

Change settings via CLI

springgen --set api.defaultPageSize=25
springgen --set features.pagination_and_sorting=false

🧠 Example Generated Code ✅ Entity

@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Product {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
}```

 Repository
```java
@Repository
public interface ProductRepository extends JpaRepository<Product, Long> {}

✅ Service (with pagination)

public interface ProductService {
    Product getById(Long id);
    Product save(Product obj);
    Product update(Product obj);
    Page<Product> getPage(Pageable pageable);
    void delete(Long id);
}```

 Controller
```java
@RestController
@RequestMapping("/products")
@RequiredArgsConstructor
public class ProductController {

    private final ProductService service;

    @GetMapping
    public ResponseEntity<?> getAll(
        @PageableDefault(page = 0, size = 10, sort = "id", direction = Sort.Direction.ASC)
        Pageable pageable) {
        Page<Product> page = service.getPage(pageable);
        return ResponseEntity.ok(page);
    }

    // other CRUD methods...
}

🧰 Advanced 📦 Single-folder mode Put everything inside one package:

springgen --single-folder common

🧩 Developer Info

👨‍💻 Author

Ajoy Deb Nath

🔗 GitHub: Ajoy-1704001

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

springgen-1.0.2.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

springgen-1.0.2-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file springgen-1.0.2.tar.gz.

File metadata

  • Download URL: springgen-1.0.2.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for springgen-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9866a8c06a30e520ce1afedab8692efa8f6f38ded061271ac4106179f0fdf47b
MD5 8f664408ea6b8a7e99a63593a3d3f26c
BLAKE2b-256 d94f592dcea22955f2b60507594319f1a8b0a4468e4925e351933bdcb3781437

See more details on using hashes here.

File details

Details for the file springgen-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: springgen-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for springgen-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3c695df9c01dd66f18ada9d6bb7f00d5baef4280712818598a39d9621d500c1f
MD5 d30d6bfa6d011e0848585433ea50014a
BLAKE2b-256 6f635db373d162e8888e7f8a42a82ee0e1fca8875e824a81b97289e16eb761ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page