Getting Started

Everything a new user needs to download, install, and run NioFlow quickly.

Prerequisites

Before starting, ensure you have the following installed on your machine:

Installation

NioFlow CLI (Recommended)

The fastest way to get started. The CLI handles scaffolding, environment setup, and Maven management for you.

install-cli
1# Install globally
2npm install -g @jhanvi857/nioflow-cli
3
4# Scaffold a new project
5nioflow new my-app
6cd my-app
7
8# Start development with hot-reload
9nioflow dev

Manual Maven Dependency

If you prefer managing your own pom.xml, add the dependency directly.

pom.xml
1<dependency>
2 <groupId>io.github.jhanvi857</groupId>
3 <artifactId>nioflow-framework</artifactId>
4 <version>1.4.0</version>
5</dependency>

Setup Your First App

App.java
1import io.github.jhanvi857.nioflow.NioFlowApp;
2
3public class App {
4 public static void main(String[] args) {
5 NioFlowApp app = new NioFlowApp();
6
7 app.get("/", ctx -> ctx.send("NioFlow is running"));
8
9 app.listen(8080);
10 }
11}

Feature Flags (Safe Defaults)

.env
1# disabled by default
2NIOFLOW_CHAOS_ENABLED=false
3NIOFLOW_REPLAY_ENABLED=false
4NIOFLOW_WATCH=false
5
6# enable intentionally in non-prod debugging sessions
7# NIOFLOW_CHAOS_ENABLED=true
8# NIOFLOW_REPLAY_ENABLED=true
9# NIOFLOW_WATCH=true
10

Port Registration

In cloud providers, use PORT env var. In local, default to 8080.

port-config
1int port = 8080;
2String value = System.getenv("PORT");
3if (value != null && !value.isBlank()) {
4 port = Integer.parseInt(value);
5}
6app.listen(port);

Suggested Layout

project-structure
1my-app/
2 src/main/java/com/example/
3 App.java
4 controller/
5 TaskController.java
6 auth/
7 AuthController.java
8 repository/
9 TaskRepository.java
10 model/
11 Task.java
12 src/main/resources/public/
13 index.html
14 pom.xml