apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: service-clojure
  title: Clojure — Ring + Reitit + opinionated service stack
  description: |
    Clojure service with the lightweight base (Ring + Reitit) plus
    Integrant for component lifecycle, malli for request/response
    schemas, next.jdbc + HoneySQL for persistence, and OpenTelemetry
    by default. Same handler style as the lightweight tier.
  tags:
    - clojure
    - service
    - ring
    - reitit
    - integrant
  links:
    - url: https://github.com/weavejester/integrant
      title: Integrant
    - url: https://github.com/metosin/malli
      title: malli
    - url: https://github.com/seancorfield/next-jdbc
      title: next.jdbc
    - url: https://github.com/seancorfield/honeysql
      title: HoneySQL
    - url: https://opentelemetry.io/docs/languages/other/
      title: OpenTelemetry (clj-otel)
spec:
  owner: abp
  type: service
  parameters:
    - title: Stack Configuration
      required:
        - database
      properties:
        backend:
          title: Backend
          type: string
          const: ring-reitit-integrant
        frontend:
          title: Frontend
          type: string
          const: api-only
        server:
          title: HTTP Server
          type: string
          default: jetty
          enum:
            - jetty
            - http-kit
            - aleph
          enumNames:
            - 'Jetty — simplest'
            - 'HTTP Kit — async, low-memory'
            - 'Aleph — Netty-backed, async + websockets'
        database:
          title: Database
          type: string
          enum:
            - postgres
            - sqlite
            - mysql
          enumNames:
            - 'Postgres — default'
            - 'SQLite'
            - 'MySQL'
        persistence:
          title: Persistence Library
          type: string
          default: next-jdbc-honeysql
          enum:
            - next-jdbc-honeysql
            - next-jdbc
          enumNames:
            - 'next.jdbc + HoneySQL — query DSL'
            - 'next.jdbc — JDBC wrapper only'
        lifecycle:
          title: Component Lifecycle
          type: string
          default: integrant
          enum:
            - integrant
            - mount
            - component
          enumNames:
            - 'Integrant — data-driven system map'
            - 'mount — global state with start/stop'
            - 'Component — protocol-based (Stuart Sierra)'
        validation:
          title: Schema / Validation
          type: string
          default: malli
          enum:
            - malli
            - spec
            - none
          enumNames:
            - 'malli — modern, domain-modeling schemas'
            - 'clojure.spec — built-in spec library'
            - 'None'
        background_jobs:
          title: Background Jobs
          type: string
          default: none
          enum:
            - none
            - core-async
            - external
          enumNames:
            - 'None'
            - 'core.async — in-process channels'
            - 'External — Sidekiq/SQS/etc. via JVM client'
        auth:
          title: Authentication
          type: string
          default: buddy-auth
          enum:
            - buddy-auth
            - none
          enumNames:
            - 'buddy-auth — JWT / session middleware'
            - 'None'
        observability:
          title: Observability
          type: string
          default: opentelemetry
          enum:
            - opentelemetry
            - tools-logging
          enumNames:
            - 'OpenTelemetry — clj-otel SDK + traces/metrics'
            - 'clojure.tools.logging — structured via logback'
  tooling:
    package_manager: deps-edn
    language_flavor: clojure
    test_runner: kaocha
    lint_format: clj-kondo-cljfmt
    runtime_cli: clojure
  smoke_test: |
    GET /health returns 200. One kaocha test boots the Integrant
    system, invokes the Reitit handler, and asserts the response.
  switch_when: |
    Truly minimal service with no lifecycle/schema/observability
    stack → api-ring-reitit.
