SynthKernel
A novel architecture for modular monolith development in TypeScript. It leverages the power of type orchestration and runtime dynamics to deliver a type-safe, scalable, and highly modular software paradigm.
A novel architecture for modular monolith development in TypeScript. It leverages the power of type orchestration and runtime dynamics to deliver a type-safe, scalable, and highly modular software paradigm.
The modular monolith is not a new concept. For decades, developers have sought the balance between the simplicity of a monolith and the maintainability of microservices. Yet, the implementation of this pattern often falters under the weight of "God Objects," manual registry maintenance, and configuration drift.
SynthKernel does not invent the modular monolith. Instead, it proposes a novel architectural paradigm for structuring one. By leveraging advanced TypeScript generics, extreme Inversion of Control, and a strict Loader-Module separation, SynthKernel ensures that modularity is enforced by the type system itself. This article explores the architecture's unique approach to type orchestration, its AI-native design philosophy, and how it eliminates the friction traditionally associated with modular development.
→ Explore the GitHub Repository
While the benefits of modular design are well-documented, the mechanics of implementation remain painful. Traditional approaches typically suffer from flaws below:
SynthKernel addresses these issues not by changing the goal (modular monolith), but by reinventing the structure. It shifts the center of gravity from the Loader to the Modules, using the type system to automate what was previously manual labor.
SynthKernel is a low-level system design approach that pushes the philosophy of Inversion of Control (IoC) to its extremum. Its novelty lies in three core architectural decisions:
In most frameworks, the Loader (or Framework Core) provides the APIs. In SynthKernel, Modules are the actual center of the entire application. Modules define APIs, execute real logic, and wire themselves via dependency injection. The Loader acts solely as a lifecycle manager and a facade. It contains no business logic.
SynthKernel uses advanced TypeScript generics to automatically merge module interfaces into the Loader's type definition.
For example, ff a module contributes a method dispatch(), the Loader's type automatically gains dispatch(). If the module is removed, the method vanishes from the type, triggering a compile-time error if still referenced. This can eliminate drift with type system becoming the single source of truth.
Modules physically attach their methods to the Loader instance at runtime via a controlled augment() mechanism. This ensures that the static type safety matches the runtime behavior, a rare achievement in dynamic languages.
A SynthKernel implementation consists of a central Loader and flat Modules, structured strictly to ensure clarity and AI compatibility.
Interacts only with the loader.
index.ts (Loader): The entry point. Defines base options and lifecycle hooks.BaseModule.ts: The abstract base class all modules extend.types.ts: Core utility types for orchestration (Orchestratable).[ModuleName].ts: Self-contained logic units that augment the Loader.SynthKernel is designed not just for humans, but for agentic coding. AI models perform best when constrained by strict guidelines and patterns (similar to how they excel with React or Vue). SynthKernel imposes strict conventions in file names (index.ts, BaseModule.ts), class structures, and naming rules are standardized. It also enforces the clear separation between Loader (lifecycle) and Modules (logic), which reduces the risk of AI entangling themselves as well as the codebase into a spaghetti.
SynthKernel provides an official Agent Skill to assist in scaffolding and maintenance. This ensures that AI-generated code adheres to the architecture's strict standards.
Install the Skill:
npx skills add hesprs/synthkernelThis allows coding agents to automatically generate modules, split bloated logic, and maintain the project structure without human intervention.
SynthKernel is a powerful tool, but it is not a silver bullet. It is best suited for specific contexts where structure and type safety are paramount.
SynthKernel is design philosophy, not a library or software. You can try to kick off a sample project that experiment with SynthKernel.
PolisAlert demo project.SynthKernel is an experimental, open-source research project maintained by Hēsperus. It is licensed to encourage both adoption and collaboration.