Server & SSR Architecture
Understand Dinou's dual-process architecture: the parent web server (server.js) that generates the RSC Flight payload, and the child process (render-html.js) that performs HTML Server-Side Rendering (SSR).
Key Files Involved:
• Main parent server:./dinou/server.js
• Child HTML renderer:./dinou/core/render-html.js
💡 Overview
Dinou separates the tasks of handling browser traffic, executing Server Components, and generating the RSC Flight payload from the CPU-heavy tasks of HTML string rendering and hydration bootstrapping.
By isolating these environments into a dual-process model, the parent web server remains highly responsive while offloading HTML Server-Side Rendering (SSR) to a dedicated child process.
⚙️ Technical Constraint: Node.js Environment Conditions
This dual-process separation is not just a performance design; it is technically forced by Node's environment conditions:
- The Parent Server: Must run with Node's
--conditions=react-serverflag to load React's Server Component runtime (which providesrenderToPipeableStreamfromreact-server-dom-esm/server). - The Child Renderer: Must run without the
react-serverflag to load the standard client/SSR runtime (which providesrenderToReadableStreamor equivalent fromreact-dom/server).
In Node.js, these two runtimes are mutually exclusive within a single process. Attempting to load both in the same process leads to duplicate React instances, context conflicts, and runtime crashes.
📊 Dual-Process Architecture
The flowchart below demonstrates how the parent web server communicates with the child HTML renderer to compile and stream page responses:
📂 Module Directory
Explore the core modules of this group:
Main Server (server.js)
Bootstraps the Express application, controls hot module replacement (HMR), handles request middleware, and serves cached or dynamic pages.
HTML Renderer (render-html.js)
Spawns in a sub-process, receives JSX descriptors, pre-renders React Server Components layout trees, and pipes compiled HTML back to the main server.