Spring-like comfort, without the weight.
CoilBase is a lightweight foundation for maintainable Java applications. It brings familiar repository and service organization, explicit transaction boundaries, and constructor wiring to applications that do not need a large framework runtime. You keep SQL, business logic and resource ownership visible.
The application structure is familiar to Spring Boot developers: repositories for data access, services for business logic, and MVC-style controller → service → repository organization. Controllers and routes use the HTTP framework's native APIs.
CoilBase builds on Jdbi for persistence, adding repository and transaction management conveniences. Core is independent of HTTP frameworks and DI containers, keeping your business logic and data access portable. The optional Avaje Jex integration is the recommended starting point, providing HTTP startup, JSON and error handling without hiding native Jex APIs.
Experiments have used Avaje Jex, Javalin and Micronaut. Read about framework integrations and portability.
Coming from Spring Boot? See CoilBase vs Spring Boot for architectural trade-offs, and the Spring Boot migration guide for practical migration steps.
CoilBase is intentionally small enough to understand, adapt, or fork. Use it as a lightweight application foundation or as a blueprint for your own architecture. Your application uses explicit SQL, ordinary Java classes and native HTTP framework APIs. If you ever decide to move away from CoilBase, you can retain your application architecture and replace CoilBase-specific conveniences with direct use of Jdbi and your preferred HTTP framework.
CoilBase is designed for resource-constrained Java deployments. In exploratory experiments on 512 MiB local VMs, an early CoilBase prototype with Jex used approximately 37% less memory than Spring Boot + Spring JDBC for the same workload on HotSpot, without native compilation or AOT optimization.
| Runtime | Spring Boot + Spring JDBC | Jex + CoilBase | Javalin + CoilBase |
|---|---|---|---|
| HotSpot JDK 27 | 181–188 MiB | 116 MiB | 121–136 MiB |
| GraalVM Native Image | 84–85 MiB | 33–51 MiB | 58–59 MiB |
The figures are median application resident set size (RSS) measurements from two workload runs using an early CoilBase prototype. They describe the memory use of the complete benchmark applications. Memory requirements depend on the application, runtime configuration and deployment. See the runtime comparisons for methodology, other frameworks and limitations.
Given an application-configured DataSource and an existing greetings table,
Core keeps SQL and transaction boundaries explicit:
import pvrlabs.coilbase.RepositoryContext;
var db = RepositoryContext.create(dataSource);
db.transactional(() -> {
db.update("INSERT INTO greetings(message) VALUES (:message)", update -> update
.bind("message", "Hello, CoilBase!").execute());
});
var messages = db.query("SELECT message FROM greetings",
query -> query.mapTo(String.class).list());
System.out.println(messages);Get started with a runnable HTTP application → The example uses HikariCP with H2; no Docker or external database is needed.
CoilBase PetClinic is a complete reference application based on Spring PetClinic. Its migration guide explains one approach to replacing JPA with explicit SQL and service-owned transactions. For a smaller starting point, see Hello CoilBase.
Release artifacts are hosted in the public PVR Labs Maven repository on GitHub, not Maven Central. See repository options for restricted environments.
Add the PVR Labs Maven repository to your project's pom.xml:
<!-- PVR Labs Maven repository for CoilBase releases: https://github.com/PVRLabs/maven-repo -->
<repositories>
<repository>
<id>pvrlabs</id>
<url>https://pvrlabs.github.io/maven/</url>
</repository>
</repositories>Then add Core (Java 17+) to your dependencies:
<dependency>
<groupId>xyz.pvrlabs</groupId>
<artifactId>coilbase-core</artifactId>
<version>0.1.0</version>
</dependency>For Gradle, add the same repository and dependency to your build script, e.g.
in build.gradle.kts:
repositories {
maven { url = uri("https://pvrlabs.github.io/maven/") }
}
dependencies {
implementation("xyz.pvrlabs:coilbase-core:0.1.0")
}For the optional Jex integration (Java 21+), use xyz.pvrlabs:coilbase-jex:0.1.0.
It includes Core. See the release notes for compatibility
expectations.
Applications supply their own JDBC driver, datasource or pool, and row mappers.
See Database Configuration for H2, PostgreSQL
with HikariCP, schema scripts and datasource ownership.
See Application configuration for work-in-progress guidance on plain Java configuration and testability.
Artifact (group xyz.pvrlabs) |
Runtime | Contents |
|---|---|---|
coilbase-core |
Java 17+ | pvrlabs.coilbase: repositories, transactions, SQL selection and optional health/metrics helpers |
coilbase-jex |
Java 21+ | pvrlabs.coilbase.jex: CoilBaseJexApplication and JexErrors |
Core depends on Jdbi, with no Jex, Jackson, Avaje HTTP, DI container or annotation processing requirement. The Jex module intentionally brings Jex and Jackson as regular transitive dependencies, including Java time support for default ISO-8601 JSON.
- Transactions:
transactionaldefines a synchronous boundary on one datasource. Nested managed callbacks join on the same thread and Jdbi instance, without an independent commit or savepoint. Escaping exceptions roll back; caught failures needmarkRollbackOnly()if the transaction must not commit. Configure the context before opening handles. Custom/retrying/container transaction handlers, cross-thread propagation and distributed transactions are unsupported. - Resources: consume query results inside callbacks. Do not return handles or
lazy results that outlive them; close streams and batches explicitly. Applications
configure datasources. The optional Jex application base closes an
AutoCloseableprimary datasource on shutdown/startup failure; otherwise the application handles cleanup; see Database Configuration for ownership details. - Errors: the Jex base installs safe JSON error handling before calling
configureErrorHandling(). Register typed mappings such asmapError(InvalidNameException.class, 400); specific types take precedence over mapped superclasses. See Getting Started. - SQL:
SqlStatementselects immutable overrides by configured dialect; it does not detect databases or rewrite SQL. A dialect name is not a compatibility guarantee.db.executeScript(sql)anddb.executeScriptResource("/script.sql")explicitly run scripts through Jdbi, without introducing a transaction or migration tracking. - Examples and tests: the records example
demonstrates a service coordinating two repositories. The runnable
Hello CoilBase example is a separate Maven project;
these examples are excluded from library binary and source JARs. Run
mvn clean verifyfor the H2-backed persistence tests and Jex HTTP tests; these do not certify every database dialect. Fast integration tests run routinely. Tag heavyweight JUnit tests with@Tag("slow"); runmvn -Pslow-tests verifyto include them along with the normal tests. CI runs this profile in a separate job.
CoilBase has a deliberately narrow scope: it is not a DI container, an ORM, or an abstraction over every Java HTTP framework. There is no automatic migration. Services and repositories can remain independent of the HTTP host; routes, controllers and bootstrap use that host's native APIs. Plain Jdbi remains a good choice when these conventions add no value.
For standalone consumer and parent-POM resolution checks, see consumer verification. Maven distribution includes the parent POM and both modules; applications depend only on the modules they need.
Optional StatLite monitoring provides HTTP and JVM metrics, plus automatic primary database health for Jex applications.
See Development Principles for the architectural and engineering guidance for contributors.
Licensed under Apache-2.0. Dependencies retain their respective licenses.