apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: service-spring-boot
  title: Java — Spring Boot (production-grade)
  description: |
    Production-grade JVM service with starters, auto-configuration,
    Actuator (metrics/health), Spring Data integrations, and broad
    enterprise conventions (Java or Kotlin source). GraalVM native
    image is GA — opt in when cold-start and memory budgets justify
    the build-time cost.
  tags:
    - java
    - service
    - spring-boot
  links:
    - url: https://docs.spring.io/spring-boot/
      title: Spring Boot
    - url: https://docs.gradle.org/current/userguide/kotlin_dsl.html
      title: Gradle Kotlin DSL primer
    - url: https://kotlinlang.org/docs/home.html
      title: Kotlin
    - url: https://www.graalvm.org/latest/reference-manual/native-image/
      title: GraalVM Native Image
spec:
  owner: abp
  type: service
  parameters:
    - title: Stack Configuration
      required:
        - language_flavor
        - database
      properties:
        backend:
          title: Backend
          type: string
          const: spring-boot
        frontend:
          title: Frontend
          type: string
          const: api-only
          description: |
            Spring Boot supports Thymeleaf templates and Spring MVC
            views; if a server-rendered UI is the killer feature,
            consider that an alternative path. Default here is
            API-only.
        language_flavor:
          title: Language
          type: string
          enum:
            - kotlin
            - java
          enumNames:
            - 'Kotlin'
            - 'Java'
        database:
          title: Database
          type: string
          enum:
            - postgres
            - mysql
            - sqlite
            - h2
          enumNames:
            - 'Postgres — default for production'
            - 'MySQL'
            - 'SQLite'
            - 'H2 — embedded development DB'
        persistence:
          title: Persistence
          type: string
          default: spring-data-jpa
          enum:
            - spring-data-jpa
            - spring-data-jdbc
            - jooq
            - none
          enumNames:
            - 'Spring Data JPA — Hibernate-backed ORM'
            - 'Spring Data JDBC — simpler, no lazy loading'
            - 'jOOQ — typesafe SQL DSL'
            - 'None — raw JDBC'
        background_jobs:
          title: Background Jobs
          type: string
          default: spring-scheduler
          enum:
            - spring-scheduler
            - quartz
            - none
          enumNames:
            - 'Spring @Scheduled — built-in cron/fixed-rate'
            - 'Quartz — durable, clustered job scheduling'
            - 'None'
        auth:
          title: Authentication
          type: string
          default: spring-security-oauth2
          enum:
            - spring-security-oauth2
            - spring-security-form
            - none
          enumNames:
            - 'Spring Security — OAuth2 resource server'
            - 'Spring Security — form login + sessions'
            - 'None'
        observability:
          title: Observability
          type: string
          default: actuator-micrometer
          enum:
            - actuator-micrometer
            - opentelemetry
            - none
          enumNames:
            - 'Spring Boot Actuator + Micrometer — default'
            - 'OpenTelemetry'
            - 'None'
        native_image:
          title: GraalVM Native Image
          type: string
          default: disabled
          enum:
            - disabled
            - enabled
          enumNames:
            - 'Disabled — JVM runtime'
            - 'Enabled — GraalVM native image build'
  tooling:
    package_manager: gradle
    build_dsl: kotlin
    language_flavor: kotlin-or-java
    test_runner: junit5
    lint_format: ktlint-or-spotless
    runtime_cli: gradle
  smoke_test: |
    GET /actuator/health returns {"status":"UP"}. One @SpringBootTest
    integration test boots the context and asserts the response.
  switch_when: |
    Compact API with minimal concepts → api-javalin. Cold-start
    optimization / native image as primary goal → service-quarkus.
    Compile-time DI without Quarkus extension conventions →
    Micronaut (future sibling).
