The purpose of this document is to provide a general overview of the application architecture.
Insomnia is a desktop application built on top of Electron. Electron provides a Chromium runtime for the Insomnia web app to run inside, as well as additional tools to provide access to operating system features.
There are a few more technologies and tools worth mentioning:
Reactis the library used for all UI components.styled-componentsandLessare used for styling UI components.Electron Builderis used to help build, sign, and package Insomnia for distribution.libcurlis the library that Insomnia uses to make requests. We used libcurl as our HTTP client of choice because it allows the deepest amount of debuggability and control of HTTP requests.NeDBa local in-memory database.node-libcurlis a Node.js wrapper around the native libcurl library.CodeMirroris a web-based, extendable, code editor used for highlighting and linting of data formats like JSON, GraphQL, and XML.Commander.jsis used for building the Inso CLI.
Insomnia uses npm workspaces to manage multiple npm packages within a single repository. There are currently the following package locations:
/packagescontains related packages that are consumed byinsomniaor externally.
/packages/insomnia is the entry point for the app. All other packages are imported from this one.
There are a few notable directories inside it:
/main.development.jsEntry for Electron./src/mainStuff that runs inside Electron's main process./src/uiReact components and styling./src/commonUtilities used across both main and render processes./src/pluginsLogic around installation and usage of plugins./src/modelsDB models used to store user data./src/networkSending requests and performing auth (e.g. OAuth 2)./src/templatingNunjucks and rendering related code./src/syncand/src/accountTeam sync and account stuff.
Insomnia stores data in a few places:
- A local in-memory NeDB database stores data for data models (requests, folder, workspaces, etc.).
- localstorage
- a fake localstorage api that writes to file and is used for window sizing
Note: NeDB is officially unmaintained (even for critical security bugs) and was last published in February 2016. Due to this, we hope to move away from it, however doing so is tricky because of how deeply tied it is to our architecture.
We use Jest and react-testing-library to write our unit tests, and Playwright for integration tests.
Unit tests exist alongside the file under test. For example:
/src/common/database.jscontains the database business logic/src/common/__tests__/database.test.jscontains the database tests
Unit tests for components follow the same pattern.
The structure for smoke tests is explained in the smoke testing package: packages/insomnia-smoke-test.
This is just a brief summary of Insomnia's current technical debt.
-
Loading large responses (~20 MB) can crash the app on weaker hardware.
-
Bundling
libcurl(native module) has caused many weeks of headaches trying to get builds working across Windows, Mac, and Linux. More expertise here is definitely needed. -
All input fields that support features like templating or code completion are actually CodeMirror instances. This isn't really debt, but may affect things going forward.
-
upgrade spectral e2e testing
-
upgrading electron
-
preload electron main functions
-
update react classes to function components
-
remove excess packages
-
migrate redux to remix
-
migrate lerna to npm workspaces
-
CI slow ~30m (now 10m)
-
styling vision (react-aria + tailwind)
-
de-polymorph database
-
codemirror is unmaintained
-
nedb is unmaintained
-
grpc state state should be in main rather than renderer
-
drag and drop is flakey
-
sync code is spaghetti
-
template rendering is spaghetti and has poor discoverability
-
inso abstraction limits networking improvements
-
testing feature doesn't scale with investment
-
unify curl.ts and libcurl-promise implementations
https://releases.electronjs.org/
bump the following node and electron versions
.npmrc.nvmrcpackages/insomnia/package.jsonelectron and node-libcurlpackages/insomnia-send-request/package.jsonnode-libcurlshell.nix