Skip to content

Add CLI Command for Generating Backend & Frontend Resources #1

@nathangtg

Description

@nathangtg

Feature Request: Automated Backend and Frontend Resource Generation CLI

Overview

Implement a CLI command to automate the generation of backend (Spring Boot) and frontend (Angular) components for a given entity.

CLI Commands

Proposed Commands

  • npx jgc generate backend <Entity> → Generates backend resources
  • npx jgc generate frontend <Entity> → Generates frontend resources
  • npx jgc generate full <Entity> → Generates both backend & frontend
  • npx jgc generate backend <Entity> --only model,repository → Selective backend generation

Generation Specifications

Backend Generation

  • Copy template Spring Boot project
  • Replace {{Entity}} placeholders with the entity name
  • Generate the following resources:
    • Controller
    • Model
    • Repository
    • Service
    • Service Implementation

Frontend Generation

  • Copy Angular template files
  • Replace {{Entity}} placeholders
  • Generate the following resources:
    • Angular Service
    • Model
    • Component

Project Structure After Generation

project-root/
├── generated-backend/
│   ├── src/main/java/com/example/app/
│   │   ├── controller/UserController.java
│   │   ├── model/User.java
│   │   ├── repository/UserRepository.java
│   │   ├── service/UserService.java
│   │   ├── service/impl/UserServiceImpl.java
│
├── generated-frontend/
│   ├── src/app/
│   │   ├── services/user.service.ts
│   │   ├── models/user.model.ts
│   │   ├── components/user-list/user-list.component.ts

Implementation Details

Project Structure

  1. CLI Entry Point: bin/jgc.js
  2. Backend Generator: lib/backend-generator.js
  3. Frontend Generator: lib/frontend-generator.js
  4. Templates Directory: templates/
    • springboot-template/
    • angular-template/

Open Questions and Considerations

Configuration and Extensibility

  • Implement .env for configurations
  • Explore support for NestJS alongside Spring Boot
  • Investigate database migration support (Flyway/Liquibase)

Contributing Guidelines

  1. Fork the repository
  2. Implement backend/frontend generation as specified
  3. Submit a pull request with comprehensive documentation

Additional Notes

This feature aims to streamline the process of creating consistent backend and frontend resources, reducing boilerplate code and improving development efficiency.

TODO

  • Design template replacement mechanism
  • Create robust CLI parsing
  • Implement selective generation logic
  • Add comprehensive error handling
  • Write unit and integration tests

Potential Future Enhancements

  • Support for additional frameworks
  • More granular generation options
  • Interactive CLI prompts for configuration

Impact

✨ Reduced boilerplate code
✨ Consistent resource generation
✨ Improved developer productivity

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions