apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: api-javalin
  title: Java — Javalin (lightweight)
  description: |
    Compact JVM HTTP API with minimal framework surface (Java or
    Kotlin source). Pairs well with Gradle Kotlin DSL and JUnit 5.
    Pick this when simple blocking code, fast startup, and a small
    concept count are valuable.
  tags:
    - java
    - lightweight-api
    - javalin
  links:
    - url: https://javalin.io/documentation
      title: Javalin
    - 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://junit.org/junit5/docs/current/user-guide/
      title: JUnit 5
spec:
  owner: abp
  type: service
  parameters:
    - title: Stack Configuration
      required:
        - language_flavor
        - database
      properties:
        backend:
          title: Backend
          type: string
          const: javalin
        frontend:
          title: Frontend
          type: string
          const: api-only
        language_flavor:
          title: Language
          type: string
          enum:
            - kotlin
            - java
          enumNames:
            - 'Kotlin — recommended for new code'
            - 'Java — when the team is Java-only'
        database:
          title: Database
          type: string
          enum:
            - postgres
            - mysql
            - sqlite
            - h2
            - none
          enumNames:
            - 'Postgres — default for production'
            - 'MySQL'
            - 'SQLite'
            - 'H2 — embedded development DB'
            - 'None — stateless service'
        persistence:
          title: Persistence Library
          type: string
          default: jdbi
          enum:
            - jdbi
            - jooq
            - exposed
            - none
          enumNames:
            - 'JDBI — SQL with object mapping (Kotlin/Java)'
            - 'jOOQ — typesafe SQL DSL'
            - 'Exposed — Kotlin SQL framework'
            - 'None — raw JDBC'
        background_jobs:
          title: Background Jobs
          type: string
          default: none
          enum:
            - none
            - quartz
          enumNames:
            - 'None'
            - 'Quartz — scheduled jobs'
        auth:
          title: Authentication
          type: string
          default: none
          enum:
            - none
            - jwt-handler
          enumNames:
            - 'None'
            - 'JWT — javalin-jwt-handler'
        observability:
          title: Observability
          type: string
          default: none
          enum:
            - none
            - opentelemetry
          enumNames:
            - 'None'
            - 'OpenTelemetry'
  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 /health returns 200. One JUnit 5 test starts the Javalin app
    on a random port via Javalin.create() + Test factory and asserts
    the response status.
  switch_when: |
    Need auto-config / starters / actuator / data integrations /
    enterprise conventions → service-spring-boot. Coroutine-native
    async / multiplatform Kotlin → Ktor (future sibling). Cold-start
    / native-image fit → service-quarkus. Compile-time DI without
    Quarkus extension conventions → Micronaut (future sibling).
