Skip to content

Spring Boot example (minimal CRUD service)

This example demonstrates the minimal SpringBoot target platform as generated by JoinedWorkz — including:

  • API layer (DTOs, API interface, controller)
  • domain layer (domain types)
  • persistence (JPA entities, repositories)
  • data access service (decoupled persistence adapter)
  • mapping (via MapStruct)

It shows what a fully generated baseline looks like before adding custom handlers or manually implemented services.

1. Repository and download

The complete example is available in the GitLab repository:

https://gitlab.com/joinedworkz/joinedworkz-examples/-/tree/main

Module: example-spring-boot

It contains both:

  • the CMN model defining API & domain types
  • the generated Spring Boot application

2. Project structure

After generation you will find the following packages:

PackagePurpose
entityJPA entities (storage model)
repositorySpring Data repositories
dasDataAccessService layer (XxxDataAccessService)
dtoAPI request/response DTOs
mapperMapStruct mapper interfaces & implementations
apiAPI interface (controller contract)
controllerREST controllers

This layout follows the conventions from:

SpringBoot target platform design

3. Running the example

Requirements:

  • Java 21+
  • Maven 3.8+

Build & run:

sh
mvn clean install
mvn spring-boot:run

Service listens on port 8080

OpenAPI UI (if enabled):
http://localhost:8080/swagger-ui.html

4. Request flow

A typical request flows through:

  1. Controller receives request
  2. MapStruct maps API DTO → domain type
  3. DataAccessService interacts with repository
  4. JPA entities → data objects
  5. MapStruct maps domain type → API DTO
  6. Response returned

5. Example model (simplified)

cmn
type<entity> Customer {
    internalId**: Id
    firstName*:   Name
    lastName*:    Name
    email:        String(255)
}

type CustomerView {
    ...Customer exclude internalId
}

resource /customers as CustomerView[] by internalId {
    query()
    create() consumes=CustomerView
    read readCustomer()
    update()
    delete()
}

6. Extending the example

Typical next steps:

  • implement custom handlers
  • add domain services
  • introduce additional API views
  • route layers to separate Maven modules
  • add gateways for external systems

For deeper information:

  • SpringBoot target platform design
  • SpringBoot profile & canonical modeling
  • Spring Boot facility