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

  1. Electron
  2. ├── build/ - Build configuration files needed to build with GN.
  3. ├── buildflags/ - Determines the set of features that can be conditionally built.
  4. ├── chromium_src/ - Source code copied from Chromium that isn't part of the content layer.
  5. ├── default_app/ - A default app run when Electron is started without
  6. | providing a consumer app.
  7. ├── docs/ - Electron's documentation.
  8. | ├── api/ - Documentation for Electron's externally-facing modules and APIs.
  9. | ├── development/ - Documentation to aid in developing for and with Electron.
  10. | ├── fiddles/ - A set of code snippets one can run in Electron Fiddle.
  11. | ├── images/ - Images used in documentation.
  12. | └── tutorial/ - Tutorial documents for various aspects of Electron.
  13. ├── lib/ - JavaScript/TypeScript source code.
  14. | ├── browser/ - Main process initialization code.
  15. | | ├── api/ - API implementation for main process modules.
  16. | | └── remote/ - Code related to the remote module as it is
  17. | | used in the main process.
  18. | ├── common/ - Relating to logic needed by both main and renderer processes.
  19. | | └── api/ - API implementation for modules that can be used in
  20. | | both the main and renderer processes
  21. | ├── isolated_renderer/ - Handles creation of isolated renderer processes when
  22. | | contextIsolation is enabled.
  23. | ├── renderer/ - Renderer process initialization code.
  24. | | ├── api/ - API implementation for renderer process modules.
  25. | | ├── extension/ - Code related to use of Chrome Extensions
  26. | | | in Electron's renderer process.
  27. | | ├── remote/ - Logic that handles use of the remote module in
  28. | | | the main process.
  29. | | └── web-view/ - Logic that handles the use of webviews in the
  30. | | renderer process.
  31. | ├── sandboxed_renderer/ - Logic that handles creation of sandboxed renderer
  32. | | | processes.
  33. | | └── api/ - API implementation for sandboxed renderer processes.
  34. | └── worker/ - Logic that handles proper functionality of Node.js
  35. | environments in Web Workers.
  36. ├── patches/ - Patches applied on top of Electron's core dependencies
  37. | | in order to handle differences between our use cases and
  38. | | default functionality.
  39. | ├── boringssl/ - Patches applied to Google's fork of OpenSSL, BoringSSL.
  40. | ├── chromium/ - Patches applied to Chromium.
  41. | ├── node/ - Patches applied on top of Node.js.
  42. | └── v8/ - Patches applied on top of Google's V8 engine.
  43. ├── shell/ - C++ source code.
  44. | ├── app/ - System entry code.
  45. | ├── browser/ - The frontend including the main window, UI, and all of the
  46. | | | main process things. This talks to the renderer to manage web
  47. | | | pages.
  48. | | ├── ui/ - Implementation of UI stuff for different platforms.
  49. | | | ├── cocoa/ - Cocoa specific source code.
  50. | | | ├── win/ - Windows GUI specific source code.
  51. | | | └── x/ - X11 specific source code.
  52. | | ├── api/ - The implementation of the main process APIs.
  53. | | ├── net/ - Network related code.
  54. | | ├── mac/ - Mac specific Objective-C source code.
  55. | | └── resources/ - Icons, platform-dependent files, etc.
  56. | ├── renderer/ - Code that runs in renderer process.
  57. | | └── api/ - The implementation of renderer process APIs.
  58. | └── common/ - Code that used by both the main and renderer processes,
  59. | | including some utility functions and code to integrate node's
  60. | | message loop into Chromium's message loop.
  61. | └── api/ - The implementation of common APIs, and foundations of
  62. | Electron's built-in modules.
  63. ├── spec/ - Components of Electron's test suite run in the renderer process.
  64. ├── spec-main/ - Components of Electron's test suite run in the main process.
  65. └── 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.
  1. script/ - The set of all scripts Electron runs for a variety of purposes.
  2. ├── codesign/ - Fakes codesigning for Electron apps; used for testing.
  3. ├── lib/ - Miscellaneous python utility scripts.
  4. └── release/ - Scripts run during Electron's release process.
  5. ├── notes/ - Generates release notes for new Electron versions.
  6. └── uploaders/ - Uploads various release-related files during release.
  • typings - TypeScript typings for Electron’s internal code.