<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Examples on @drasi/lib Docs</title><link>https://drasi-project.github.io/drasi-nodejs/docs/examples/</link><description>Recent content in Examples on @drasi/lib Docs</description><generator>Hugo</generator><language>en</language><copyright>Copyright&amp;nbsp;©&amp;nbsp;Drasi&amp;nbsp;a&amp;nbsp;Series&amp;nbsp;of&amp;nbsp;LF&amp;nbsp;Projects,&amp;nbsp;LLC. For&amp;nbsp;website&amp;nbsp;terms&amp;nbsp;of&amp;nbsp;use,&amp;nbsp;trademark&amp;nbsp;policy&amp;nbsp;and&amp;nbsp;other&amp;nbsp;project&amp;nbsp;policies&amp;nbsp;please&amp;nbsp;see&amp;nbsp;&lt;a href="https://lfprojects.org/policies/"&gt;lfprojects.org/policies/&lt;/a&gt;.</copyright><atom:link href="https://drasi-project.github.io/drasi-nodejs/docs/examples/index.xml" rel="self" type="application/rss+xml"/><item><title>Tutorial: Trading Demo</title><link>https://drasi-project.github.io/drasi-nodejs/docs/examples/trading/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://drasi-project.github.io/drasi-nodejs/docs/examples/trading/</guid><description>&lt;p&gt;The &lt;strong&gt;trading demo&lt;/strong&gt; is a self-contained desktop app that embeds &lt;code&gt;@drasi/lib&lt;/code&gt; and
renders &lt;strong&gt;live&lt;/strong&gt; query results in its own window — no browser, no HTTP/SSE, no REST,
no Python. It&amp;rsquo;s a faithful port of &lt;code&gt;drasi-server&lt;/code&gt;&amp;rsquo;s
&lt;a href="https://github.com/drasi-project/drasi-server/tree/main/examples/trading"&gt;&lt;code&gt;examples/trading&lt;/code&gt;&lt;/a&gt;
demo, and it&amp;rsquo;s the best way to see every concept in this documentation working
together.&lt;/p&gt;
&lt;p&gt;The full source is in
&lt;a href="https://github.com/drasi-project/drasi-nodejs/tree/main/examples/trading"&gt;&lt;code&gt;examples/trading&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="what-it-demonstrates"&gt;What it demonstrates&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Real PostgreSQL CDC&lt;/strong&gt; — reference data (&lt;code&gt;stocks&lt;/code&gt;, &lt;code&gt;portfolio&lt;/code&gt;, &lt;code&gt;watchlist&lt;/code&gt;) lives
in a real Postgres database and is streamed into the engine via Drasi&amp;rsquo;s Postgres
source (logical replication) plus a Postgres bootstrap snapshot.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Synthetic joins&lt;/strong&gt; — &lt;code&gt;HAS_PRICE&lt;/code&gt;, &lt;code&gt;OWNS_STOCK&lt;/code&gt;, and &lt;code&gt;ON_WATCHLIST&lt;/code&gt; relate elements
across sources (and across a database and a live feed) with &lt;strong&gt;no foreign keys&lt;/strong&gt;,
entirely inside the query. See &lt;a href="../../concepts/#synthetic-joins"&gt;Concepts → Synthetic joins&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;In-process price feed&lt;/strong&gt; — a tiny Node random-walk generator pushes &lt;code&gt;stock_prices&lt;/code&gt;
into a &lt;a href="../../guides/js-sources/"&gt;JavaScript source&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application reactions&lt;/strong&gt; — one &lt;a href="../../api/#addjsreactionid-queryids-callback"&gt;&lt;code&gt;addJsReaction&lt;/code&gt;&lt;/a&gt;
per query streams result diffs straight to the renderer over a single IPC channel;
the dashboard merges ADD/UPDATE/DELETE/aggregation diffs into live tables.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Plugins downloaded at runtime&lt;/strong&gt; — the Postgres source and bootstrap plugins are
pulled from &lt;code&gt;ghcr.io/drasi-project&lt;/code&gt; on first launch and cached locally. Nothing is
baked in. See &lt;a href="../../guides/plugins/"&gt;Working with plugins&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="architecture"&gt;Architecture&lt;/h2&gt;
&lt;pre class="mermaid"&gt;flowchart LR
 subgraph pg[PostgreSQL - Docker]
 T1[stocks]
 T2[portfolio]
 T3[watchlist]
 end
 subgraph main[Electron main - embeds @drasi/lib]
 PS[postgres source&amp;lt;br/&amp;gt;downloaded OCI]
 PF[price-feed&amp;lt;br/&amp;gt;JS source]
 Q[5 continuous queries&amp;lt;br/&amp;gt;&amp;#43; synthetic joins]
 RX[addJsReaction]
 end
 R[Electron renderer&amp;lt;br/&amp;gt;React dashboard]

 pg --&amp;gt;|logical replication &amp;#43; bootstrap| PS
 PS --&amp;gt; Q
 PF --&amp;gt;|pushChange| Q
 Q --&amp;gt; RX
 RX --&amp;gt;|IPC: trading:stream| R&lt;/pre&gt;
&lt;p&gt;The native addon is N-API v9 (ABI-stable), so it loads directly in Electron&amp;rsquo;s main
process with no &lt;code&gt;electron-rebuild&lt;/code&gt;.&lt;/p&gt;</description></item></channel></rss>