How to organize your Electron project with Modules — DeepSeek Blog | Neura Market
    Neura MarketNeura Market/DeepSeek
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsBlogVideosGuidesCoursesCommunityTrendingGenerate
    DeepSeekBlogHow to organize your Electron project with Modules
    Back to Blog
    How to organize your Electron project with Modules
    javascript

    How to organize your Electron project with Modules

    traeop February 8, 2026
    0 views

    Hey everyone! I wanted to share a project I've been working on that might help building Electron...

    Hey everyone! I wanted to share a project I've been working on that might help building Electron applications. ## What I Built electron-modular is a simple DI lib for Electron's main process. Think NestJS/Angular style architecture but specifically designed for Electron and this is simple solution. ## Why Does This Exist? When developers building a Electron apps and the main process sometimes became a mess and I want to better organize architecture especially when the project grows and something like this happens: - Services with tangled dependencies - IPC handlers scattered everywhere - Window management logic duplicated - Many dependencies - Sometimes hard to test anything Of course, you can build it correctly if you have the right skills, but it would be nice to have a defined structure similar (NestJS/Angular). ## So, what It Does Organize code into feature modules: RestApiService service from another module ``` import { Injectable } from "@devisfuture/electron-modular"; .... @Injectable() export class RestApiService { .... async get<T>( endpoint: string, options: RequestOptions = {}, ): Promise<T | undefined> { const response = await fetch(endpoint, options); if (response.error !== undefined) { console.error("Error fetching data:", response.error.message); return; } return response.data; } .... } ``` Dependency injection token ``` const USER_REST_API_PROVIDER = Symbol("USER_REST_API_PROVIDER"); ``` TUserRestApiProvider using for Factory Provider within the UserModule. This is like an abstraction between the UserModule and RestApiService ``` type TUserRestApiProvider = { get: <TUser>( endpoint: string, options?: TRequestOptions, ) => Promise<TUser>; }; ``` UserModule is a feature module that encapsulates all user-related logic, including services, data fetching, IPC communication and so on (see detail in repo) ``` import { RgModule} from "@devisfuture/electron-modular"; .... @RgModule({ imports: [RestApiModule], ipc: [UserIpc], // IPC communication handlers windows: [UserProfileWindow], providers: [ UserService, { provide: USER_REST_API_PROVIDER, useFactory: (restApiService: RestApiService): TUserRestApiProvider => ({ get: (endpoint, options) => restApiService.get(endpoint, options), }), inject: [RestApiService], }, ], }) export class UserModule {} ``` Automatic dependency injection ``` import { Injectable, Inject } from "@devisfuture/electron-modular"; .... @Injectable() export class UserService { constructor( @Inject(USER_REST_API_PROVIDER) private auth: TUserAuthProvider, private db: DatabaseService ) {} // Dependencies auto-injected! } ``` Dedicated IPC handlers ``` import { IpcHandler } from "@devisfuture/electron-modular"; .... @IpcHandler() export class UserIpc { constructor(private userService: UserService) {} onInit({ getWindow }) { // Group all user-related IPC here } } ``` Window lifecycle management ``` import { WindowManager } from "@devisfuture/electron-modular"; .... @WindowManager({ hash: 'window:user-profile', isCache: true, options: { width: 600, height: 400 } }) export class UserProfileWindow { onWebContentsDidFinishLoad(window) { // Lifecycle hooks! } } ``` ## Why Provider Pattern? The provider pattern is useful when: - You want to share only specific methods, not entire services - You want better encapsulation and clear module boundaries Instead of exposing a full service, you expose only what's needed: ``` { provide: USER_REST_API_PROVIDER, useFactory: (restApi: RestApiService): TUserRestApiProvider => ({ get: (endpoint, options) => restApi.get(endpoint, options), }), inject: [RestApiService], } ``` ## Resources - GitHub: https://github.com/trae-op/electron-modular - NPM: https://www.npmjs.com/package/@devisfuture/electron-modular - Simple Example App: https://github.com/trae-op/quick-start_react_electron-modular - Full-featured starter: https://github.com/trae-op/electron-modular-boilerplate ## Try It Out ``` npm install @devisfuture/electron-modular ``` The README has a full guide and examples. --- I'd love your feedback! What are the alternatives, and are they easier to use? I hope you guys like it! Positive feedback and GitHub stars would mean a lot to me ) I’ve been trying to create something that would be simple to use.

    Tags

    javascriptelectronshowdevopensource

    Comments

    More Blog

    View all
    How I'm using ASTs and Gemini to solve the "Codebase Onboarding" problem 🧠ai

    How I'm using ASTs and Gemini to solve the "Codebase Onboarding" problem 🧠

    Hi everyone! 👋 I’m Tara, a Senior Software Engineer and Consultant. Over the years, I've jumped...

    T
    tworrell
    Local AI Will Save Us All (The Math Says So, Trust Me)ai

    Local AI Will Save Us All (The Math Says So, Trust Me)

    Every few weeks a take goes viral in tech circles making the case for ditching cloud AI and running...

    S
    Sebastian Schürmann
    Lost in the AI Hype, I Started Smallai

    Lost in the AI Hype, I Started Small

    And it helped me get back into tech without drowning TL;DR at the end Coming back to...

    R
    Rohini Gaonkar
    Building a Replay-Tested Interactive Brokers Client in Gogo

    Building a Replay-Tested Interactive Brokers Client in Go

    I wanted an IBKR library that felt like Go and had testing I could trust. So I wrote one.

    T
    Thomas Marcelis
    Playwright in Pictures: Fully Parallel Modeplaywright

    Playwright in Pictures: Fully Parallel Mode

    Playwright’s fullyParallel mode is often treated as a simple performance switch. In practice, it...

    V
    Vitaliy Potapov
    Designing a CLI for Both Humans and Agentscli

    Designing a CLI for Both Humans and Agents

    Learn how Alpic designed its CLI for both human developers and AI agents — covering tradeoffs like polling, context windows, interactivity, and statelessness.

    J
    Julien Vallini

    Stay up to date

    Get the latest DeepSeek prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for DeepSeek and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.