NioFlow: A Configurable Java Micro-Framework.
NioFlow is a minimalistic Java HTTP framework focusing on explicit programmatic configuration. It utilizes a hybrid architecture: NIO Selector for connection acceptance and a bounded thread pool for blocking request processing.
$ ./scripts/run.ps1
[INFO] Bootstrap: Initializing Server Components...
[INFO] Security: Loaded keystore.jks, enabling Native TLS
[INFO] Database: JDBC pool active on Async Executor ThreadPool
[INFO] NIO: Registering ServerSocketChannel on 0.0.0.0:443
[READY] Selector Event Loop started successfully.
$ curl -X GET https://localhost/api/health
HTTP/1.1 200 OK
Content-Type: application/json
{ "status": "UP", "uptime": "0ms" }
Under the Hood: System Mechanics
Built on Java NIO and robust architectural patterns, NioFlow provides an incredibly fast, non-blocking foundation for building scalable web applications and RESTful APIs.
Hybrid NIO Architecture
Built on Java's java.nio. Connection tracking and event loops use efficient Selectors, while request processing is handled by a bounded worker pool.
Native HTTPS Security
Direct SSLContext integration allows raw SocketChannel handoffs to SSLSocketFactory, dropping the requirement for Nginx proxies entirely for HTTPS.
Zero-Copy Memory
Hardware-accelerated Direct Memory Access via FileChannel.transferTo(). Static files hit the socket without crossing into JVM user-space memory.
Async Database Offload
Prevent worker thread blocking using CompletableFuture. Operations hit HikariCP and PostgreSQL on a dedicated secondary loop, ensuring maximum throughput.
Global Error Handling
Uncaught runtime exceptions are cleanly intercepted. Configure custom JSON fallback responses to guarantee you never leak a raw stack trace to the public internet.
Graceful Shutdown
Built for containerized environments. Using drainAndStop(), NioFlow safely completes all active TCP requests before permitting SIGTERM termination.
Clean Controller Abstraction
While the engine is complex at the socket layer, registering business logic remains declarative and heavily typed. Look at how easy it is to spin up new HTTP endpoints.
1public class ServerApp {2 public static void main(String[] args) {3 NioFlowApp app = new NioFlowApp();45 // Middleware Stack6 app.use(new LoggerMiddleware());7 app.use(new RateLimitMiddleware(100, Duration.ofMinutes(1)));89 // Handlers & Async DB offload10 app.get("/api/orders", new OrderController()::list);1112 // Global Error Intercept13 app.onError((err, ctx) -> ctx.status(500).json("Fail"));1415 // Graceful Shutdown16 Runtime.getRuntime().addShutdownHook(new Thread(() -> {17 app.drainAndStop(30, TimeUnit.SECONDS);18 }));1920 // Native TLS Integration21 app.listenSecure(443, "keystore.jks", "password");22 }23}
The Final Piece of the Architecture Puzzle.
The framework avoids reflection and hidden dependency injection containers. All route logic, exception handling, and middleware flows are wired manually, ensuring completely predictable code execution.