<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sathvik K</title>
    <description>The latest articles on DEV Community by Sathvik K (@builtbysathvik).</description>
    <link>https://dev.to/builtbysathvik</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4267079%2F79fbc84d-431d-4b91-a7c2-f495cd03a883.jpg</url>
      <title>DEV Community: Sathvik K</title>
      <link>https://dev.to/builtbysathvik</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/builtbysathvik"/>
    <language>en</language>
    <item>
      <title>I put my notes inside a physics simulation</title>
      <dc:creator>Sathvik K</dc:creator>
      <pubDate>Thu, 26 Nov 2026 14:29:35 +0000</pubDate>
      <link>https://dev.to/builtbysathvik/i-put-my-notes-inside-a-physics-simulation-1aik</link>
      <guid>https://dev.to/builtbysathvik/i-put-my-notes-inside-a-physics-simulation-1aik</guid>
      <description>&lt;p&gt;Most note apps show you a graph of your notes as a nice extra. I wanted the graph to &lt;em&gt;be&lt;/em&gt; the app, and I wanted it to tell me something: which notes I actually use, and which ones I've forgotten.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;Graph Notes&lt;/strong&gt;: a note-taking app where every note is a body in a physics simulation. It has zero dependencies and is plain JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it in your browser:&lt;/strong&gt; &lt;a href="https://sathvik8317.github.io/graph-notes/" rel="noopener noreferrer"&gt;https://sathvik8317.github.io/graph-notes/&lt;/a&gt; (it opens with demo notes)&lt;br&gt;
Repo: &lt;a href="https://github.com/sathvik8317/graph-notes" rel="noopener noreferrer"&gt;https://github.com/sathvik8317/graph-notes&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Recency gravity.&lt;/strong&gt; Notes you open or edit get pulled to the centre. Notes you haven't touched drift out to the edge. Colour goes from warm (recent) to cool (stale). After a few weeks of use the layout becomes a picture of what you're actually thinking about.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Drag to link.&lt;/strong&gt; Drop one note onto another in the graph and a &lt;code&gt;Related: [[Target]]&lt;/code&gt; line gets added to the note you dragged. No typing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time travel.&lt;/strong&gt; Press Replay and watch the graph grow from your first note. Notes appear on the day you created them, and links appear when you first wrote them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzwm1isdlcaqium1e99ip.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzwm1isdlcaqium1e99ip.png" alt="Replay mode: an earlier, smaller version of the graph" width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It also has what you'd expect: Markdown with &lt;code&gt;[[wikilinks]]&lt;/code&gt; (headings and aliases too), &lt;code&gt;[[&lt;/code&gt; autocomplete, backlinks, renames that rewrite every link, search, JSON export/import, dark mode and a phone layout.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcu4brg25npdtzlzmsj4f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcu4brg25npdtzlzmsj4f.png" alt="Dark mode with a note open and its backlinks" width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How the physics works
&lt;/h2&gt;

&lt;p&gt;I studied how Obsidian's graph view is put together (physics in a Web Worker, flat typed arrays, Barnes-Hut) and wrote my own engine in the style of d3-force. No Obsidian code is used.&lt;/p&gt;

&lt;p&gt;Each tick does four things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Link springs&lt;/strong&gt; pull linked notes together.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Many-body repulsion&lt;/strong&gt; pushes every note away from every other note. Doing that pair by pair is O(n²), so it uses a &lt;strong&gt;Barnes-Hut quadtree&lt;/strong&gt; (θ = 0.9): a far-away group of notes is treated as one heavy point.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gravity&lt;/strong&gt; pulls each note towards the centre.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collision&lt;/strong&gt; on a grid stops circles from overlapping.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The engine runs in a &lt;strong&gt;Web Worker&lt;/strong&gt;, so typing in the editor never stutters. Positions come back to the main thread as a transferred &lt;code&gt;Float32Array&lt;/code&gt;, which is a handover rather than a copy. With 2,000 nodes a tick takes about 9 ms.&lt;/p&gt;

&lt;p&gt;Recency gravity turned out to be one line. Each note gets its own gravity multiplier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;g&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.25&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;2.75&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;halfLife&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A note you just touched gets 3x pull, and one you've ignored for a long time gets 0.25x. Repulsion does the rest and pushes the low-gravity notes outward. You set the half-life in the settings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three bugs that taught me something
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The target ran away.&lt;/strong&gt; My first drag-to-link never worked. Every note repels every other note, so when I dragged a note towards its target, the target slid away from it. The fix: while you hold a note, it becomes a "ghost" that doesn't repel or collide with anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Links inside code blocks.&lt;/strong&gt; If a note contains a code sample with &lt;code&gt;[[something]]&lt;/code&gt; in it, that's not a link. The parser has to skip code spans and fenced blocks, or you get phantom edges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The camera.&lt;/strong&gt; If you fit the view once on load, it fits the starting jumble and the graph then grows off screen. If you fit only once it settles, the screen is empty for a second. So it fits twice: once early so something is visible, and again when the layout settles, unless you've already panned or zoomed yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;The quickest way is the live demo: &lt;a href="https://sathvik8317.github.io/graph-notes/" rel="noopener noreferrer"&gt;https://sathvik8317.github.io/graph-notes/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To run it locally, you need Node 20+ and nothing else:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/sathvik8317/graph-notes
&lt;span class="nb"&gt;cd&lt;/span&gt; graph-notes
node serve.mjs   &lt;span class="c"&gt;# http://localhost:5173&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It opens with demo notes so you can play with the graph right away. Notes are stored in your browser's &lt;code&gt;localStorage&lt;/code&gt;, so use Export for backups. There are 21 tests covering the physics engine, the data model and the Markdown renderer (&lt;code&gt;node --test test/&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ghost links:&lt;/strong&gt; on-device embeddings that suggest links between related notes you never connected&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Continents:&lt;/strong&gt; detect clusters and give them names and soft outlines&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WebAssembly engine&lt;/strong&gt; for very large graphs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you use a graph view in your own notes app: do you actually look at it, or is it just pretty? I'm curious whether recency gravity would change that for you.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
