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.
| Area | What is generated | Where in the project |
|---|---|---|
| REST API | Create, read, update and delete endpoints for each entity, under /api/<entity> | src/main/java/com/example/app/controller/CustomerController.java |
| Authentication | Registration 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 |
| RBAC | Role and permission tables, and a permission check on the protected routes | src/main/java/com/example/app/security/RbacPermissionEvaluator.java |
| Migrations | An initial migration for the schema | src/main/resources/db/migration/V1__initial_schema.sql |
| Tests | 17 test files in the example (unit and integration) | src/test/java/com/example/app/service/CustomerServiceTest.java |
| Dockerfile | Builds the image and runs the app as a non-root user (uid 10001) | Dockerfile |
| docker-compose | Runs the app with a PostgreSQL database beside it | docker-compose.yml |
| CI pipeline | A GitHub Actions workflow, when you choose it | .github/workflows/ci.yml |
| API description | An OpenAPI description of the API | src/main/java/com/example/app/config/SwaggerConfig.java |
| Health check | A health endpoint | src/main/java/com/example/app/controller/HealthController.java |
| Configuration | An .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.
.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 filesReal excerpts
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",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) {src/main/resources/db/migration/V1__initial_schema.sqlCREATE 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
);DockerfileFROM 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"]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
- Backend generator How Auxen works across all stacks.
- Schema to REST API The example schema and the generated routes.
- Pricing Free to use, with paid plans for credits and the sandbox.
- User guide Step by step, from schema to download.
- Kotlin Spring Boot generator Kotlin output.
- NestJS generator TypeScript output.
- FastAPI generator Python output.
- Django REST Framework generator Python output.
- Laravel generator PHP output.
- .NET (ASP.NET Core) generator C# output.
- Go Gin generator Go output.
- Express.js generator TypeScript or JavaScript output.
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.