Spring Boot backend generator: schema to REST API

Auxen, by Auxen Prime, generates a Spring Boot (Java) backend from your database schema or a plain-English description. The output is an ordinary Spring Boot project that you download and own. Build and run it with Maven.

What you get

The table is read from a real generated project (184 files for the example schema). The last column is the file in that project.

AreaWhat is generatedWhere in the project
REST APICreate, read, update and delete endpoints for each entity, under /api/<entity>src/main/java/com/example/app/controller/CustomerController.java
AuthenticationRegistration and login with JWT in this example. The builder also offers OAuth2, Session, API Key, Basic Auth and OpenID Connect.src/main/java/com/example/app/controller/AuthController.java
RBACRole and permission tables, and a permission check on the protected routessrc/main/java/com/example/app/security/RbacPermissionEvaluator.java
MigrationsAn initial migration for the schemasrc/main/resources/db/migration/V1__initial_schema.sql
Tests17 test files in the example (unit and integration)src/test/java/com/example/app/service/CustomerServiceTest.java
DockerfileBuilds the image and runs the app as a non-root user (uid 10001)Dockerfile
docker-composeRuns the app with a PostgreSQL database beside itdocker-compose.yml
CI pipelineA GitHub Actions workflow, when you choose it.github/workflows/ci.yml
API descriptionAn OpenAPI description of the APIsrc/main/java/com/example/app/config/SwaggerConfig.java
Health checkA health endpointsrc/main/java/com/example/app/controller/HealthController.java
ConfigurationAn .env.example listing the settings.env.example

The example it was generated from

Entities Customer and Invoice, with Invoice many-to-one Customer, on PostgreSQL, JWT with RBAC. Options: unit tests, integration tests, Docker, GitHub Actions pipeline and migrations. Auxen adds the authentication tables (users, roles, permissions, sessions and others) around them.

Folder layout, with file counts
.github/workflows/  1 file
.mvn/wrapper/  1 file
docs/  2 files
src/  171 files
src/main/  154 files
src/test/  17 files
(project root)  9 files

Real excerpts

A generated controller src/main/java/com/example/app/controller/CustomerController.java
@RestController
@RequestMapping("/api/customer")
@RequiredArgsConstructor
public class CustomerController {

    private final CustomerService customerService;

    private static final java.util.Set<String> SORTABLE_FIELDS = java.util.Set.of(
        "customerId",
        "customerName",
        "customerEmail",
        "customerBirthday",
        "customerActive",
        "customerGender",
The RBAC check src/main/java/com/example/app/security/RbacPermissionEvaluator.java
@Component
@RequiredArgsConstructor
public class RbacPermissionEvaluator implements PermissionEvaluator {

    private final UserRepository userRepository;
    private final UserRoleRepository userRoleRepository;
    private final RolePermissionRepository rolePermissionRepository;
    private final PermissionRepository permissionRepository;

    @Override
    public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) {
        if (authentication == null || permission == null) {
The first migration, for Customer src/main/resources/db/migration/V1__initial_schema.sql
CREATE TABLE IF NOT EXISTS "customer" (
    customer_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    customer_name VARCHAR(255) NOT NULL,
    customer_email VARCHAR(255) UNIQUE NOT NULL,
    customer_birthday DATE,
    customer_active BOOLEAN NOT NULL,
    customer_gender VARCHAR(255) NOT NULL,
    customer_notes TEXT,
    customer_created_at TIMESTAMP NOT NULL
);
The Dockerfile Dockerfile
FROM maven:3.9-eclipse-temurin-17 AS build
WORKDIR /app
COPY pom.xml .
COPY src ./src
# maven.test.skip, not skipTests: the image needs only the app, so test sources
# are not compiled either (as the Kotlin image's `gradle build -x test`).
RUN mvn -q -Dmaven.test.skip=true package

FROM eclipse-temurin:17-jre
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar
# Run as an unprivileged user (uid and gid 10001) that owns /app.
RUN groupadd --system --gid 10001 app && useradd --system --no-create-home --gid app --uid 10001 app && chown -R app:app /app
USER 10001:10001
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
A generated test src/test/java/com/example/app/service/CustomerServiceTest.java
@ExtendWith(MockitoExtension.class)
class CustomerServiceTest {

    @Mock
    private CustomerRepository customerRepository;

    @Mock
    private CustomerMapper customerMapper;

    @InjectMocks
    private CustomerService customerService;

What it is built on

Read from the generated manifest: Spring Boot (pom.xml), Spring Data JPA (pom.xml), Spring Security (pom.xml), JJWT (pom.xml), springdoc OpenAPI (pom.xml).

Databases

Spring Boot generates for PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle and Amazon Redshift. It does not generate for MongoDB.

How the generator is tested

These checks live in the Auxen repository and run against the generators themselves. They are listed here as what they do, not as a guarantee about every schema you might write.

  • Generation test (npm run test:gen): generates this stack for several example schemas, then compiles the result with Maven.
  • Runtime test (npm run test:runtime): starts the generated application, connects it to a real database, registers a user, logs in, then creates and lists records over HTTP.
  • Security scan: the generated project, including its Dockerfile and CI files, is scanned with Trivy for vulnerabilities, secrets and misconfiguration. The check fails on any secret, and on any high or critical finding that has a fix.
  • Docker build test (npm run test:docker, run on demand): builds each stack's own Dockerfile.

Running and deploying it

Build and run it with Maven. You download the project and deploy it wherever you run software. Auxen does not deploy the generated backend for you yet. It has a hosted sandbox where you can run the code and try its API before you download it.

Review the code before it carries real traffic, as you would any code you did not write. The terms of service say the same: generated code is provided as is, and you are responsible for reviewing, testing and securing it.

More

Auxen is made by Auxen Prime Technologies Limited and lives at auxenprime.com. It is not affiliated with other companies that use the name Auxen.