Skip to content

A production-ready Spring Boot 3.5.5 + Kotlin 2.0 starter project, offering a unified package with essential backend features pre-integrated and real-world examples. Includes a complete OpenTelemetry-based observability stack for unified monitoring, distributed tracing, and log aggregation.

Notifications You must be signed in to change notification settings

awakelife93/spring-boot-kotlin-boilerplate

Repository files navigation

Spring Boot Boilerplate (Kotlin)

A production-ready Spring Boot 3.5.5 + Kotlin 2.0 starter project, offering a unified package with essential backend features pre-integrated and real-world examples. Includes a complete OpenTelemetry-based observability stack for unified monitoring, distributed tracing, and log aggregation.

Environment & Skills

  • Application

    • Kotlin 2.0
    • Jdk 21
    • Spring boot 3.5.5
      • mvc
      • webflux
    • Gradle 8.10
    • Spring Security
    • Spring Batch
    • Springdoc OpenAPI
    • Postgresql
    • h2 database (PostgreSQL mode) - localhost environment
    • Jpa
    • QueryDSL
    • Redis
    • Jwt
    • Validation
    • Kotlin Logging
    • Logback
    • Flyway
    • Webhook
      • Slack
      • Discord
    • Kafka
    • WebClient
    • Spring Actuator
  • Test

    • Spring Boot Starter Test
    • Spring Security
    • Spring Batch
    • Junit 5
    • Mockito Kotlin
    • Mockito Inline
    • Kotest
    • Mockk
    • Instancio
    • h2 database (PostgreSQL mode)
    • Flyway
  • Etc

    • Docker
    • Pgadmin
    • Ktlint
    • Detekt
    • Mailhog
    • Netty resolver dns native macos
    • Kafka UI
  • Monitoring

    • Prometheus
    • Grafana
    • Tempo
    • OpenTelemetry Collector
    • Loki
    • Sentry

Project Guide

  • monitoring
  • docker
  • src
    • common
    • domain (post, user, auth)
    • example
      • WelcomeSignUpConsumer: Kafka Consumer(SignUp Event) Example
    • infrastructure (kafka, redis, webhook, mail)
    • security
      • spring security + jwt logic
    • utils
    • resources
      • db
        • migration: flyway sql
        • sql: spring batch postgresql metadata sql
      • logback-spring.xml
        • Logback configuration with environment-specific settings
        • Profiles: prod, dev, local
      • application.yml
        • prod, dev, local, common, test, secret-{environment}
        • common: Write common variables for the project.
        • test: Create the variables needed for your test environment.
        • secret-{environment}: your secret variables for each environment.

Clean Architecture + Hexagonal Architecture Version

If you're interested, check this out as well:

Local Installation

To use the application, the following two services must be installed and running:

  • kafka
  • redis
  • mailhog
  • grafana
  • prometheus
  • opentelemetry collector
  • tempo
  • loki

Description

  1. Security & CVE Management
    • The project manages dependency vulnerabilities centrally through the applyCveFixes() function in build.gradle.kts
    • All known CVE fixes are automatically applied during dependency resolution
// Example: CVE fix implementation
requested.group == "org.apache.commons" && requested.name == "commons-lang3" -> {
	useVersion("3.18.0")
	because("CVE-2025-48924")
}
  1. Database DDL Management

    • This project uses Flyway for DDL management instead of JPA auto-generation.
    • Migration scripts are located in src/main/resources/db/migration
    • If you prefer not to use Flyway, entity synchronization is configured - you can use JPA DDL auto-generation instead.
  2. Webhook

// example

// 1. all
webHookProvider.sendAll(
	"Subscription request received from method ${parameter.method?.name}.",
	mutableListOf("Request Body: $body")
)

// 2. target slack
webHookProvider.sendSlack(
	"Failed to send message to Kafka (foo)",
	mutableListOf("Failed to send message to Kafka: ${exception.message} / $foo")
)

// 3. target discord
webHookProvider.sendDiscord(
	"Failed to send message to Kafka (bar)",
	mutableListOf("Failed to send message to Kafka: ${exception.message} / $bar")
)
  1. Mailhog

  2. Lint

  3. Docker & Infrastructure Services

    • The project includes Docker Compose configurations for all required services
    • For detailed setup, port information, and service management, see Docker Setup Guide
  4. Create Spring Batch metadata table (localhost, development and production environments.)

  5. Two types of tests

  6. Kafka

  7. Example

  8. OpenTelemetry Stack Configuration (Monitoring & Observability)

    • All observability data (metrics, traces, logs) are now collected through OpenTelemetry Collector
    • OpenTelemetry Collector Endpoints:
      • OTLP gRPC: localhost:4317
      • OTLP HTTP: localhost:4318
    • Grafana: Unified dashboard for metrics, traces, and logs
    • OpenTelemetry Collector:
  9. Service Access URLs (When services are running)

    Application

    Infrastructure Services

    • MailHog (Email Testing): http://localhost:8025
    • PgAdmin (PostgreSQL Management): http://localhost:8088
    • Kafka UI (Kafka Management): http://localhost:9000
    • Redis (CLI/Client access): localhost:6379
    • PostgreSQL (Database connection): localhost:5432
    • Kafka (Broker connection): localhost:9092
    • Zookeeper (Coordination service): localhost:2181

    Observability

    • Grafana (Unified Observability Dashboard): http://localhost:3000
      • Username: demo
      • Password: demo
      • Metrics (Prometheus), Traces (Tempo), Logs (Loki) visualization
      • Data Source Configuration (use Docker internal network addresses):
        • Prometheus: http://prometheus:9090
        • Tempo: http://tempo:3200
        • Loki: http://loki:3100
    • Prometheus (Metrics Collection): http://localhost:9090
    • Tempo (Distributed Tracing): http://localhost:3200
    • Loki (Log Aggregation): http://localhost:3100
    • OpenTelemetry Collector:
      • gRPC: localhost:4317
      • HTTP: localhost:4318

Author

Hyunwoo Park

About

A production-ready Spring Boot 3.5.5 + Kotlin 2.0 starter project, offering a unified package with essential backend features pre-integrated and real-world examples. Includes a complete OpenTelemetry-based observability stack for unified monitoring, distributed tracing, and log aggregation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published