pg- spring-db
Open Studio
User Guides & Docs

How to Use pg-spring-db

A comprehensive manual on designing tables, reverse-engineering SQL DDL scripts, validating schema rules, and generating bootable Spring Boot backends.

1. Design Database Tables Visually

Open the Workspace Studio. By default, the designer loads an E-Commerce system template containing users, products, and orders. You can modify these tables or create new ones:

  • GUI Designer Tab: Select tables, edit their names, assign colors, add/delete columns, and define data types (e.g. UUID, VARCHAR(255), NUMERIC, etc.).
  • Define Relationships: Toggle FK on a column to specify foreign key parameters (e.g. user_id references table users column id). The ERD canvas draws the connectives dynamically.
  • Raw JSON Tab: You can edit the database schema configuration in raw JSON format. Minify or format JSON automatically.

2. Reverse-Engineer Existing Schemas

If you already have a database schema, you can import it in seconds:

  1. Click the SQL Import tab in the Left Editor panel.
  2. Paste your raw PostgreSQL CREATE TABLE statements, primary key declarations, indices, and foreign key relations.
  3. Click Parse & Load into Studio. The parser will rebuild the tables and draw the visual ERD layout on the canvas.

3. Database Schema Integrity Checks

The designer includes a client-side PostgreSQL Schema Linter that runs in real time as you make changes. Navigate to the Linter tab in the right-column sidebar:

  • Database Health Score: Gauges layout quality on a scale of 0 to 100.
  • Missing Primary Keys: Warns when a table does not declare a unique key identifier.
  • Missing FK Indexes: PostgreSQL does not index foreign keys by default, leading to slow table joins and row locks. The linter flags unindexed FKs.
  • Reserved Keywords: Warns when column names overlap with SQL keywords (e.g., USER, ORDER, TABLE).

4. Spring Boot CRUD Code Generation

Select the **Spring Boot** tab on the right sidebar. The tool parses the active schema and compiles clean, production-grade Spring Boot components:

Note: Code generation mapping respects column nullability (Bean Validations), data types, and primary-foreign key relationships.

  • JPA Entities: Generates Hibernate class representations complete with Lombok annotations (@Getter, @Setter, @Builder) and correct @ManyToOne / @OneToMany mapping declarations.
  • Request / Response DTOs: Generates data transfer objects containing validation rules like @NotBlank or @Size limits.
  • JpaRepository: Interface files extending Spring Data JPA repositories.
  • CRUD Service layer: Service interfaces and implementations containing paginated fetch, save, update, and delete logics.
  • REST Controllers: REST controller endpoints exposing full CRUD endpoints, CORS setups, and validation bindings.

5. Export Bootable Project ZIPs

Once you have verified the design:

  1. Click **Export Spring Boot Project (.ZIP)** inside the Spring Boot tab.
  2. The tool packages all generated Java classes, application configuration files (application.yml), and database migrations into a structured maven project layout.
  3. Extract the zip file, configure your local PostgreSQL database url, and run mvn spring-boot:run to boot up the complete API backend in seconds.