Skip to main content

Source Code Directory Structure

The source code of Electron is separated into a few parts, mostly following Chromium on the separation conventions.

You may need to become familiar with Chromium's multi-process architecture to understand the source code better.

Structure of Source Code#

Electronโ”œโ”€โ”€ build/ - Build configuration files needed to build with GN.โ”œโ”€โ”€ buildflags/ - Determines the set of features that can be conditionally built.โ”œโ”€โ”€ chromium_src/ - Source code copied from Chromium that isn't part of the content layer.โ”œโ”€โ”€ default_app/ - A default app run when Electron is started without|                  providing a consumer app.โ”œโ”€โ”€ docs/ - Electron's documentation.|   โ”œโ”€โ”€ api/ - Documentation for Electron's externally-facing modules and APIs.|   โ”œโ”€โ”€ development/ - Documentation to aid in developing for and with Electron.|   โ”œโ”€โ”€ fiddles/ - A set of code snippets one can run in Electron Fiddle.|   โ”œโ”€โ”€ images/ - Images used in documentation.|   โ””โ”€โ”€ tutorial/ - Tutorial documents for various aspects of Electron.โ”œโ”€โ”€ lib/ - JavaScript/TypeScript source code.|   โ”œโ”€โ”€ browser/ - Main process initialization code.|   |   โ”œโ”€โ”€ api/ - API implementation for main process modules.|   |   โ””โ”€โ”€ remote/ - Code related to the remote module as it is|   |                 used in the main process.|   โ”œโ”€โ”€ common/ - Relating to logic needed by both main and renderer processes.|   |   โ””โ”€โ”€ api/ - API implementation for modules that can be used in|   |              both the main and renderer processes|   โ”œโ”€โ”€ isolated_renderer/ - Handles creation of isolated renderer processes when|   |                        contextIsolation is enabled.|   โ”œโ”€โ”€ renderer/ - Renderer process initialization code.|   |   โ”œโ”€โ”€ api/ - API implementation for renderer process modules.|   |   โ”œโ”€โ”€ extension/ - Code related to use of Chrome Extensions|   |   |                in Electron's renderer process.|   |   โ”œโ”€โ”€ remote/ - Logic that handles use of the remote module in|   |   |             the main process.|   |   โ””โ”€โ”€ web-view/ - Logic that handles the use of webviews in the|   |                   renderer process.|   โ”œโ”€โ”€ sandboxed_renderer/ - Logic that handles creation of sandboxed renderer|   |   |                     processes.|   |   โ””โ”€โ”€ api/ - API implementation for sandboxed renderer processes.|   โ””โ”€โ”€ worker/ - Logic that handles proper functionality of Node.js|                 environments in Web Workers.โ”œโ”€โ”€ patches/ - Patches applied on top of Electron's core dependencies|   |          in order to handle differences between our use cases and|   |          default functionality.|   โ”œโ”€โ”€ boringssl/ - Patches applied to Google's fork of OpenSSL, BoringSSL.|   โ”œโ”€โ”€ chromium/ - Patches applied to Chromium.|   โ”œโ”€โ”€ node/ - Patches applied on top of Node.js.|   โ””โ”€โ”€ v8/ - Patches applied on top of Google's V8 engine.โ”œโ”€โ”€ shell/ - C++ source code.|   โ”œโ”€โ”€ app/ - System entry code.|   โ”œโ”€โ”€ browser/ - The frontend including the main window, UI, and all of the|   |   |          main process things. This talks to the renderer to manage web|   |   |          pages.|   |   โ”œโ”€โ”€ ui/ - Implementation of UI stuff for different platforms.|   |   |   โ”œโ”€โ”€ cocoa/ - Cocoa specific source code.|   |   |   โ”œโ”€โ”€ win/ - Windows GUI specific source code.|   |   |   โ””โ”€โ”€ x/ - X11 specific source code.|   |   โ”œโ”€โ”€ api/ - The implementation of the main process APIs.|   |   โ”œโ”€โ”€ net/ - Network related code.|   |   โ”œโ”€โ”€ mac/ - Mac specific Objective-C source code.|   |   โ””โ”€โ”€ resources/ - Icons, platform-dependent files, etc.|   โ”œโ”€โ”€ renderer/ - Code that runs in renderer process.|   |   โ””โ”€โ”€ api/ - The implementation of renderer process APIs.|   โ””โ”€โ”€ common/ - Code that used by both the main and renderer processes,|       |         including some utility functions and code to integrate node's|       |         message loop into Chromium's message loop.|       โ””โ”€โ”€ api/ - The implementation of common APIs, and foundations of|                  Electron's built-in modules.โ”œโ”€โ”€ spec/ - Components of Electron's test suite run in the renderer process.โ”œโ”€โ”€ spec-main/ - Components of Electron's test suite run in the main process.โ””โ”€โ”€ BUILD.gn - Building rules of Electron.

Structure of Other Directories#

  • .circleci - Config file for CI with CircleCI.
  • .github - GitHub-specific config files including issues templates and CODEOWNERS.
  • dist - Temporary directory created by script/create-dist.py script when creating a distribution.
  • node_modules - Third party node modules used for building.
  • npm - Logic for installation of Electron via npm.
  • out - Temporary output directory of ninja.
  • script - Scripts used for development purpose like building, packaging, testing, etc.
script/ - The set of all scripts Electron runs for a variety of purposes.โ”œโ”€โ”€ codesign/ - Fakes codesigning for Electron apps; used for testing.โ”œโ”€โ”€ lib/ - Miscellaneous python utility scripts.โ””โ”€โ”€ release/ - Scripts run during Electron's release process.    โ”œโ”€โ”€ notes/ - Generates release notes for new Electron versions.    โ””โ”€โ”€ uploaders/ - Uploads various release-related files during release.
  • typings - TypeScript typings for Electron's internal code.