<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: 29 x</title>
    <description>The latest articles on DEV Community by 29 x (@29_x_395a8d7880988c00d53f).</description>
    <link>https://dev.to/29_x_395a8d7880988c00d53f</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3235200%2F302164a6-607e-4f11-94c2-c71d3b9d1cc1.jpg</url>
      <title>DEV Community: 29 x</title>
      <link>https://dev.to/29_x_395a8d7880988c00d53f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/29_x_395a8d7880988c00d53f"/>
    <language>en</language>
    <item>
      <title>Build Electron Apps Like NestJS: Modular Architecture, Multi-Window Management, and Typed IPC Communication</title>
      <dc:creator>29 x</dc:creator>
      <pubDate>Sun, 01 Jun 2025 05:38:41 +0000</pubDate>
      <link>https://dev.to/29_x_395a8d7880988c00d53f/build-electron-apps-like-nestjs-modular-architecture-multi-window-management-and-typed-ipc-15oh</link>
      <guid>https://dev.to/29_x_395a8d7880988c00d53f/build-electron-apps-like-nestjs-modular-architecture-multi-window-management-and-typed-ipc-15oh</guid>
      <description>&lt;h1&gt;
  
  
  Build Electron Apps Like NestJS: Modular Architecture, Multi-Window Management, and Typed IPC Communication
&lt;/h1&gt;

&lt;p&gt;When we develop Electron applications, the main process often becomes a tangled mess: window creation logic is scattered everywhere, &lt;code&gt;ipcMain&lt;/code&gt; handlers are registered imperatively all over the place, and communication logic is tightly coupled. Maintenance becomes increasingly difficult as the application grows.&lt;/p&gt;

&lt;p&gt;As a full-stack developer with experience in NestJS, I wanted to apply Nest’s modular thinking to the Electron main process.&lt;/p&gt;

&lt;p&gt;That’s why I created this project:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/X29w/electronest" rel="noopener noreferrer"&gt;🔗 GitHub Repository: X29w/electronest&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✨ What Is This Project?
&lt;/h2&gt;

&lt;p&gt;This is a highly scalable and elegant Electron + Vite + NestJS full-featured template that supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;💠 &lt;strong&gt;Main process architecture inspired by NestJS&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;🪟 &lt;strong&gt;Modular multi-window management system&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;🔌 &lt;strong&gt;Type-safe, decorator-based IPC communication&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;📦 &lt;strong&gt;Independent NestJS server integrated into Electron&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;🔄 &lt;strong&gt;Built-in auto-registration of modules, services, and IPC handlers&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;💡 &lt;strong&gt;Perfect for large Electron applications&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔍 Core Innovations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. 🧱 NestJS-Inspired Architecture for Electron Main Process
&lt;/h3&gt;

&lt;p&gt;Inspired by &lt;code&gt;@Module()&lt;/code&gt;, &lt;code&gt;@Injectable()&lt;/code&gt;, and &lt;code&gt;@Controller()&lt;/code&gt; in NestJS, this project brings a similar architecture to the Electron main process.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IPC logic is encapsulated in modules&lt;/li&gt;
&lt;li&gt;Dependency injection is used for services&lt;/li&gt;
&lt;li&gt;Clean separation of concerns&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;✅ No more imperative &lt;code&gt;ipcMain.on(...)&lt;/code&gt; scattered everywhere!&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  2. 🪟 Declarative Multi-Window Management with Decorators
&lt;/h3&gt;

&lt;p&gt;Instead of managing windows manually in random files, you can now use decorators like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;RegisterWindow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;home&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HomeWindow&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And auto-register them via:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;AutoRegisterWindows&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;HomeWindow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;SettingsWindow&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;WindowModule&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All windows are created declaratively, lifecycle-aware, and can expose methods for main/renderer communication.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. 🔁 Decorator-Based IPC Communication (with TypeScript support)
&lt;/h3&gt;

&lt;p&gt;You can define IPC handlers like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;IPCHandle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;get-user-info&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;handleUserInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;UserPayload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUserInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And on the renderer side, TypeScript will provide autocomplete &amp;amp; type-checks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;electronAPI&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;get-user-info&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;123&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;✅ Supports full request/response structure, type inference, and automatic registration.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  4. 🚀 Embedded NestJS Server
&lt;/h3&gt;

&lt;p&gt;A full NestJS backend is embedded in Electron and runs alongside your main process. You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expose REST APIs&lt;/li&gt;
&lt;li&gt;Reuse backend logic in the main process&lt;/li&gt;
&lt;li&gt;Use it to drive IPC logic or window lifecycle behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This is especially useful for heavy logic processing or multi-window state management.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  📦 Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Electron&lt;/strong&gt; – Desktop runtime&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vite&lt;/strong&gt; – Lightning-fast frontend builder&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React&lt;/strong&gt; – UI rendering (can replace with Vue/Svelte/etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NestJS&lt;/strong&gt; – Backend architecture (used inside and alongside Electron)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript&lt;/strong&gt; – Full type safety&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛠️ Get Started
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/X29w/electronest
&lt;span class="nb"&gt;cd &lt;/span&gt;electronest
pnpm &lt;span class="nb"&gt;install
&lt;/span&gt;pnpm dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You’ll have a fully running Electron app with a NestJS server, multi-window setup, and IPC system in just one command.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  📌 Conclusion
&lt;/h2&gt;

&lt;p&gt;This template is perfect for developers who:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Want to build &lt;strong&gt;scalable&lt;/strong&gt; Electron apps&lt;/li&gt;
&lt;li&gt;Prefer &lt;strong&gt;structured architecture&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Value &lt;strong&gt;type safety&lt;/strong&gt; and &lt;strong&gt;modular design&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Are familiar with &lt;strong&gt;NestJS&lt;/strong&gt; or want to bring backend patterns to desktop development&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you found this project interesting, feel free to ⭐️ it on GitHub:&lt;br&gt;
👉 &lt;a href="https://github.com/X29w/electronest" rel="noopener noreferrer"&gt;https://github.com/X29w/electronest&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;




</description>
    </item>
  </channel>
</rss>
