Skip to content
Bernardusz edited this page Jun 9, 2026 · 3 revisions

Levtus (Levis Conatus) πŸ§πŸš€

Maven Central License Maven Release Qodana

Levtus (Latin: Levis Conatus - "Light Effort") is a high-performance, zero-dependency HTTP/1.1 engine built from the ground up for the modern JVM. It is designed to be lightweight, secure, and incredibly fast by leveraging the power of Java 21+ Virtual Threads (Project Loom).

"Infrastructure should be simple, transparent, and built to last."


✨ Why Levtus?

  • πŸ“¦ Zero External Dependencies: No runtime overhead, no third-party version conflicts, and tiny deployment binaries.
  • 🌳 Trie-Based Router: Route matching speed is proportional only to the depth of your URL segments (O(L)), making it consistently fast even as you add hundreds of endpoints.
  • πŸ”’ Built-In Security Guards: Configurable hardware safeguards prevent denial-of-service (DoS) attempts by enforcing strict size boundaries on headers during stream consumption.
  • πŸͺΆ Native Java Performance: Optimized for Java 25+, taking full advantage of modern platform innovations.

⚑ Technical Highlights

  • Loom-Native Concurrency: Uses a newVirtualThreadPerTaskExecutor to handle thousands of concurrent connections with minimal memory footprint.
  • Trie-Based Routing: Features a high-performance Prefix Tree (Trie) router for $O(K)$ route matching (where $K$ is the path length).
  • Zero Dependencies: Pure Java. No external libraries, no "DLL hell," and ultra-small JAR size.
  • Hardened Security: Built-in protection against:
    • Path Traversal: Secure render() logic with path normalization.
    • Memory Exhaustion: Configurable limits for headers, body size, and line lengths.
    • Connection Overload: Semaphore-based throttling to protect system resources.
  • SSL/TLS Ready: Native support for HTTPS via PKCS12 keystores.
  • Fluent API: Express-inspired context handling for JSON, HTML, and binary data.

πŸš€ Quick Start

import io.github.bernardusz.levtus.Levtus;

public class Main {
    public static void main(String[] args) {
        Levtus app = Levtus.create();

        // Middleware support
        app.use((ctx, next) -> {
            System.out.println("Request received: " + ctx.req().path());
            next.run();
        });

        // Simple GET route
        app.get("/hello", ctx -> {
            ctx.text("Hello from the Levtus Engine!");
        });

        // Dynamic routing with path params
        app.get("/user/{id}", ctx -> {
            String userId = ctx.param("id");
            ctx.json("{\"id\": \"" + userId + "\"}");
        });

        // Secure static file rendering
        app.get("/", ctx -> {
            ctx.render("index.html");
        });

        app.listen(8080);
    }
}

πŸ›  Architecture & Internals

The Request Lifecycle

  1. Connection Throttling: A global Semaphore limits active connections to prevent the JVM from being overwhelmed.
  2. Virtual Thread Hand-off: Each socket is handed to a Virtual Thread, keeping the main loop free for new accepts.
  3. Protocol Parsing: Raw InputStream parsing for HTTP/1.1 compliance, including support for persistent connections and keep-alive.
  4. Trie Matching: The router traverses the Trie to find the correct handler while extracting path parameters on the fly.
  5. Middleware Execution: A recursive execution chain allows for powerful pre- and post-processing.

Security Configurations

Levtus gives you fine-grained control over your server's surface area:

app.setMaxBodySize(10 * 1024 * 1024); // 10MB limit
app.setMaxHeaderCount(100);
app.setMaxLineSize(8192); // Prevent Slowloris attacks

πŸ“ˆ Performance

By utilizing Project Loom, Levtus avoids the overhead of traditional thread-pooling and the complexity of reactive programming. It provides a simple, synchronous programming model that scales horizontally with hardware.


πŸ“– Complete Documentation

Explore our comprehensive guides to get the most out of Levtus:

πŸš€ Getting Started

πŸ›  Core APIs

πŸ”’ Security & Advanced

πŸ“ˆ Project


πŸ“œ License

MIT License. Feel free to use, modify, and distribute.


Built with 🐧 and raw sockets πŸ§πŸ’€.

🐧 Getting Started

🧩 Core API

πŸ“¦ Features

πŸ›‘οΈ Security & Stability

πŸš€ Performance & Deployment

🀝 Project

Clone this wiki locally