Staticraft v0.1.7
Architecture Deep Dive

Decoupled Generator & Serving Layer

Staticraft eliminates traditional SSR vulnerabilities by isolating HTML compilation inside a private background daemon and serving immutable static files directly through Nginx or CDNs.

Decoupled Architecture

How Staticraft Operates

By severing the connection between public web traffic and your dynamic database backend, Staticraft delivers bulletproof security, zero-downtime updates, and sub-millisecond static response times.

1. Private Network Isolated Worker

Background Generator

A daemon process running inside a private network or CI/CD runner. It pulls data from DBs, CMS, or APIs and compiles static HTML.

> server.js data()
> TemplateEngine.render()
> ScheduleManager timer
Atomic Swapper rename(2) POSIX
2. Public Workspace Zero App Ports

Nginx / Caddy / CDN

The public web server serves pre-rendered static HTML files directly from `.raft/`. Zero Node.js runtime overhead on HTTP hits.

> root .raft/
> Cache-Control: 1 Year
> error_page 404 /404.html
Zero vulnerable open application ports exposed to public web traffic
Learn how to set up Nginx / Caddy

Core Architectural Principles

Four design guarantees that make Staticraft resilient, fast, and secure.

01. ZERO PUBLIC PORTS

Private Generator Isolation

In production mode (staticraft start), the engine opens zero listening HTTP ports. Attackers cannot send malformed requests, SQL injections, or RCE payloads to the application backend because the backend is completely unexposed.

02. POSIX RENAME(2)

Atomic File Swapping

Pages are compiled into temporary staging files first. Once rendering completes successfully, Staticraft triggers an atomic rename(2) system call to swap the file into .raft/. Nginx never encounters empty or half-rendered pages.

03. SCHEDULE MANAGER

Timer-Driven Revalidation

Routes specify their own background refresh intervals via revalidate: 600. The background ScheduleManager handles background timers seamlessly without needing complex CI/CD webhook triggers.

04. IMMUTABLE SERVING

Sub-Millisecond TTFB

Nginx, Caddy, or CDNs serve pre-rendered static files directly from RAM or disk cache. Response times are bounded only by network latency (< 2ms TTFB), easily handling millions of requests.