Technical Overview
Technical Overview
SnapDock V3 is a desktop Markdown editor built with Electron, JavaScript, HTML and CSS. Its architecture focuses on keeping the application straightforward, using familiar web technologies without introducing frameworks or dependencies that weren't needed.
This document explains how SnapDock works internally, why its major technical decisions were made, and where those decisions introduced limitations.
It covers the maintained V3 architecture. Future versions may use different technologies and approaches.
1. Architecture
SnapDock uses Electron to provide a desktop application built with web technologies.
The application is divided into three main components:
| Component | Responsibility |
|---|---|
| Main process | Application lifecycle, windows, filesystem operations, native dialogs, PDF generation and updates. |
| Preload | Provides a controlled interface between the application window and Electron's main process. |
| Renderer | Handles the editor, tabs, workspace navigation, Markdown rendering, themes and user interface. |
The renderer is written in plain JavaScript, HTML and CSS. JavaScript modules are bundled using esbuild before being loaded by Electron.
There is no React, Vue or other frontend framework.
Why plain JavaScript?
This was a deliberate design decision.
SnapDock didn't require a large frontend framework to provide its intended functionality. Using plain JavaScript avoided additional dependencies and kept the codebase relatively simple.
The goal was to build a Markdown editor, not a framework for building Markdown editors.
That approach also meant the application could be developed around its own requirements rather than adapting those requirements to a particular frontend ecosystem.
Why Electron?
SnapDock's earlier Python implementation became increasingly difficult to extend as the application grew.
During development, Electron proved more forgiving when individual components encountered errors. Problems were generally easier to isolate to the functionality being worked on, rather than interrupting unrelated parts of the application.
This made Electron a practical choice for expanding SnapDock's features and refining its interface.
TypeScript was considered as a further improvement to development and maintainability, but V3 remained a JavaScript application.
2. Application Processes
Main process
The main process starts from main.js.
It is responsible for creating the application window, managing its lifecycle and performing operations that require access to Electron or the operating system.
These include:
- Opening and saving files.
- Selecting workspace folders.
- Reading directory contents.
- Monitoring filesystem changes.
- Displaying native dialogs.
- Managing application updates.
- Generating PDF documents.
- Handling application close requests.
The main process also coordinates with the renderer when unsaved changes need attention before closing the application.
Preload bridge
The preload script, located at src/preload.js, exposes named APIs that allow the renderer to request supported operations.
For example, when a user opens a document, the renderer requests the operation through the preload interface. The main process performs the filesystem work and returns the result.
This separation keeps ordinary interface code from requiring direct access to Node.js filesystem APIs.
The application uses Electron's IPC mechanisms for communication between these components.
The main window enables context isolation and disables direct Node.js integration in the renderer. It does not currently enable Electron's renderer sandbox. Security-related behaviour is reviewed separately as the application evolves.
Renderer
The renderer is responsible for the parts of SnapDock users interact with directly.
Its modules manage document tabs, editor input, Markdown preview, workspace navigation, recent files, appearance settings and interface behaviour.
The renderer's entry point is src/scripts.js, with supporting modules organised under src/modules/.
The application uses DOM operations and JavaScript modules rather than a dedicated UI framework.
3. The Markdown Editor
SnapDock V3 uses a native HTML textarea as its editing surface.
This was another deliberate effort to keep the application lightweight and avoid introducing a more complex editing framework.
For conventional Markdown editing, the approach provided a straightforward way to work with plain text.
However, it eventually became one of V3's architectural limitations.
The Live View limitation
Live View was originally intended to provide a render-as-you-type editing experience, similar to Typora.
Instead of writing Markdown in one pane and viewing the rendered result in another, formatting would appear directly within the editable document.
A standard textarea cannot display independently formatted text within its contents. Supporting this behaviour would therefore have required a substantially different editing implementation.
Although technically possible, the additional complexity would have undermined the simplicity that motivated the original design.
By the time Live View was investigated, development was already moving toward a future generation of SnapDock with a different technical foundation.
Rather than rebuilding V3's editor around a feature that might soon be replaced, Live View development was deferred.
V3 retains its conventional editor and separate preview modes.
Live View is a strong candidate for V4, but its implementation has not been finalised.
4. Document Management
SnapDock works directly with local Markdown files.
It does not require documents to be imported into a database or converted into a proprietary project format.
Opening and editing documents
When a document is opened, SnapDock reads its contents and creates a tab in the renderer.
Each tab maintains information such as its file path, title, current content and whether it contains unsaved changes.
The application uses a shared editing surface. Switching tabs stores the outgoing document's content and loads the selected document into the editor.
New documents begin as untitled tabs held in memory until saved.
Saving
Saved documents are written to the filesystem as UTF-8 text.
SnapDock does not automatically save document changes.
Instead, it tracks whether a tab has been modified and provides save operations and unsaved-change warnings.
Closing the application with modified documents triggers a confirmation process, allowing the user to save or discard changes.
This protects against ordinary accidental closure, but it is not a crash-recovery or document-backup system.
Workspaces
A workspace represents a selected directory on the user's computer.
SnapDock displays its contents through a navigable file tree, allowing documents to be opened without repeatedly using the operating system's file picker.
The file tree loads directory contents as folders are expanded.
SnapDock uses Chokidar to monitor filesystem activity within the selected workspace. When changes are detected, the navigation tree can be refreshed.
This monitoring is primarily concerned with the workspace display. It does not provide automatic merging or conflict resolution for documents modified externally while open in the editor.
Recent files and sessions
SnapDock maintains recent-file paths to make previously accessed documents easier to find.
Recent Files stores references to files, not additional copies of their contents.
Optional session functionality can also record saved document paths for reopening. It does not preserve unsaved document contents.
Workspace selection and session behaviour are intentionally separate from the documents themselves. SnapDock does not need to keep a workspace permanently open for its files to remain accessible.
5. Markdown Rendering
SnapDock uses Markdown-it as its Markdown rendering engine.
Markdown-it was selected because it was a mature, established solution that suited the application's requirements at the time.
Rather than implementing a Markdown parser from scratch, SnapDock builds on Markdown-it and a collection of extensions.
Supported rendering features
The V3 rendering pipeline includes:
| Feature | Implementation |
|---|---|
| Standard Markdown | Markdown-it |
| Syntax-highlighted code | Highlight.js |
| Tables and strikethrough | Markdown-it rendering |
| Footnotes | markdown-it-footnote |
| Task lists | markdown-it-task-lists |
| Highlighted text | markdown-it-mark |
| Subscript and superscript | markdown-it-sub and markdown-it-sup |
| Emoji | markdown-it-emoji |
| Heading anchors | markdown-it-anchor |
| Callout blocks | Markdown-it containers |
| Collapsible sections | Markdown-it containers |
| PDF page breaks | Custom rendering rule |
SnapDock also enables automatic link detection, typographic substitutions and raw HTML handling.
Markdown-it and GitHub Flavored Markdown
Although SnapDock supports many features commonly associated with GitHub Flavored Markdown, it does not directly use GitHub's Markdown rendering implementation.
Differences in parser behaviour, extensions and styling can result in documents appearing differently between SnapDock and GitHub.
SnapDock also provides some extensions that are not part of standard Markdown.
Preview modes
SnapDock supports a full preview and a split view.
In full preview, the rendered document replaces the editor pane.
In split view, the editor and rendered document appear side by side. The divider can be adjusted to change the amount of space allocated to each.
The preview updates as document content changes, using a short delay to avoid unnecessary rendering on every keystroke.
This is separate from the planned Live View concept, which would render formatting inside the editable document itself.
Images and links
Relative Markdown image paths are resolved using the location of the saved document.
For example:

SnapDock uses the document's directory to determine where the referenced image is located.
Local document links are also resolved relative to the current document.
This allows Markdown documents and their supporting assets to remain organised using ordinary filesystem directories.
6. PDF Export
SnapDock uses Chromium's PDF printing capabilities through Electron.
However, the implementation has an unusual history.
Why a separate rendering window?
The original intention was to export the rendered Markdown directly into a PDF file.
During development, isolating the rendered document proved difficult. Attempts to capture the intended content could include parts of the editor interface or fail to capture the document correctly.
The solution was to create a separate, hidden Electron window dedicated to PDF rendering.
This allowed SnapDock to prepare the document independently of the visible editor and generate a PDF using Chromium's printing system.
It worked, so it stayed.
Possibly a little longer than originally intended.
Current export process
The V3 export process works broadly as follows:
- The renderer provides the current preview HTML.
- The main process prepares a separate HTML document with PDF-specific styling.
- A hidden Electron window loads the prepared content.
- Chromium generates a PDF using
printToPDF(). - The PDF is written to a temporary location.
- SnapDock opens the generated PDF using the system's default viewer.
- The temporary file is scheduled for removal.
This approach provides a way to inspect and retain the exported document through the system PDF viewer.
Because the PDF uses a separate rendering environment and stylesheets, its appearance may differ from the application's preview.
The temporary-window approach is an established V3 workaround rather than the intended long-term export architecture. PDF export is an area planned for reconsideration as SnapDock is redesigned.
7. Application Settings and State
SnapDock separates document content from application preferences.
Documents remain ordinary files on disk, while interface settings and recent activity are stored locally.
Renderer preferences
The renderer uses browser localStorage for preferences and application metadata, including:
- Selected theme.
- Editor font and size.
- Preview mode.
- Current workspace path.
- Recent-file paths.
- Optional session information.
These values belong to the local application profile and are not embedded into Markdown documents.
Other application data
Some settings and operational information are stored through Electron's application-data directory.
For example, spellcheck preferences are maintained separately from renderer preferences.
The update system also uses local metadata to track pending update operations.
SnapDock does not require a user account or remote service to store these preferences.
8. Appearance and Spellcheck
Themes
SnapDock V3 includes five themes:
- Light
- Dark
- Solarized
- Arctic Dark
- Forest
Themes are implemented using CSS and custom properties.
Selecting a theme changes the classes applied to the application interface, allowing the corresponding stylesheet to control its appearance.
Theme selection is stored locally and restored when the application is opened again.
Developers can add custom themes by modifying the source code, registering a new theme and rebuilding SnapDock.
The process is covered in Building from Source.
Editor fonts
The editor supports Mono, Sans and Serif font selections, with size options of 90%, 100%, 110% and 125%.
These settings apply to the editing surface.
Preview and PDF typography use their own styling rules, so changing the editor font does not necessarily change the appearance of exported documents.
Spellcheck
SnapDock uses Electron's spellchecking capabilities.
The application enables spellcheck by default and uses available language dictionaries, preferring US English when available.
Spelling suggestions are provided through the editor's context menu.
Spellcheck preferences are stored locally.
9. Updates and Distribution
SnapDock uses electron-builder for desktop packaging and electron-updater for supported direct installations.
The main V3 build workflows produce:
| Platform | Package format |
|---|---|
| Windows | NSIS installer |
| Linux | AppImage and Debian package |
Microsoft Store and Snap Store distributions use their respective store update systems.
The application identifies its installation source to determine whether its built-in updater should be available.
For supported direct installations, the updater checks for releases, downloads available updates and coordinates installation through Electron.
The update process is designed to operate separately from the user's Markdown documents.
Store packaging and publishing can involve additional processes outside the ordinary local build workflow.
For instructions on compiling and packaging SnapDock, see Building from Source.
10. Engineering Trade-offs
SnapDock V3 reflects a series of practical engineering decisions.
Some were made to keep the application simple. Others were solutions to problems encountered during development.
Not every decision remained ideal as the project evolved.
Simplicity versus flexibility
Avoiding a frontend framework and specialised editor reduced the number of systems involved in the application.
It also meant that more advanced editing behaviour would eventually require custom implementation.
The native textarea is the clearest example: an effective starting point that became restrictive as expectations grew.
Working solutions versus permanent architecture
The PDF export system demonstrates another trade-off.
A separate rendering window solved a real development problem and allowed PDF export to work without delaying the rest of the application.
Over time, that workaround became part of the established architecture.
This is not unusual in software development, but it illustrates why a working implementation and an ideal long-term design are not always the same thing.
What V3 established
V3 helped establish the expected functionality and user experience of SnapDock.
Its architecture supported the development of workspaces, multi-document editing, Markdown rendering, appearance settings and desktop integration.
It also made the limitations of certain approaches clearer.
Those lessons inform future development, including the exploration of alternative application frameworks and a more capable editing experience.
The direction of V4 remains under development. Its final technology stack and features should not be considered confirmed until implemented and released.
11. Source Code
SnapDock is open source under the MIT licence.
The maintained V3 source is available in the main branch of the repository:
Developers interested in modifying or compiling the application should continue with Building from Source, which covers development requirements, repository structure, commands, testing and custom themes.
Contributions and issue reports are welcome through the project's GitHub repository.