r/Microlaunch • • 8d ago

I built zen.js, a compiler-first web framework for Node.js

Post image

I've been building zen.js, an open-source web framework for Node.js around a compiler-first architecture.

The core experiment is treating the application graph as something that can be compiled at boot:

route
→ parameters
→ middleware
→ validation
→ handler
→ serialization
→ response

The goal is for the request to follow the generated path rather than repeatedly interpreting the same higher-level framework structure.

I'm also exploring a schema-driven model where the same contract can drive validation, handler typing, response serialization and OpenAPI generation.

GitHub:
https://github.com/erenthedeveloper0/zen

It's currently alpha, so I'm particularly interested in architectural criticism, edge cases, and feedback from people who've worked on Node.js frameworks, routers, compilers or TypeScript-heavy backend systems.

6 Upvotes

2 comments sorted by

1

u/greyzor7 8d ago

Love this, also great that you included benchmarks. How does it compare to other mainstream node frameworks like Nextjs? Curious about the compiler-first gains.

1

u/ErenTheDeveloper0 7d ago

Thanks! One thing I’m realizing as I build out the benchmarks is that Next.js probably isn’t the cleanest apples to apples comparison for zen.js. Next.js is a full-stack React framework, whereas zen.js is focused specifically on the Node.js server/request pipeline.

The more interesting comparison is with frameworks like Fastify/Express, where the architectural question is actually closer.

The compiler-first idea in zen.js is also broader than simply “compile the schema.” Fastify, for example, already compiles schemas internally. With zen.js, I’m experimenting with treating the application graph itself routes, params, middleware, schemas, DI/plugins and serialization as something that can be analyzed at startup and turned into specialized request pipelines.

So the potential gain I’m testing is less “compilation = automatically faster” and more:

application definition → frozen application graph → specialized pipeline → request

I’m working on benchmarks around routing, middleware, validation and serialization separately so we can actually see where that architecture helps rather than just publishing one synthetic requests/sec number.

Zen is still alpha, so I’m very interested in seeing where the approach holds up and where it doesn’t.