Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

README.md

72 lines2.6 KB

1# trytanstackdb.com _(ALPHA version)_
2​
3> Note that this project is still in its early stages.
4​
5An interactive guide for taking the first steps with
6[`@tanstack/tanstack-db`](https://tanstack.com/db/latest/docs/overview) by
7[fuko](fulop.dev/).
8​
9[🔗 trytanstackdb.com](https://trytanstackdb.com)
10​
11https://github.com/user-attachments/assets/32efe3de-f976-4009-9970-40605f1f1b51
12​
13## TODO
14​
15See [TODO.md](./TODO.md).
16​
17## 🚀 Main goals, motivations
18​
19It took a while for TanStack DB to "click" for me, but it's not because this
20library is too nieche. When I used it for a POC and showed that to my
21colleagues, they seemed to immediately understand the advantages of TanStack DB,
22because I could show exactly the things I explained.
23​
24This project aims to bring the same interactive and practical learning
25experience to everybody elseon the internet.
26​
27### Target audience
28​
29There are two types of people in the target audience of this project:
30​
311. Devs, who just heard about TanStack DB, and want to understand what it is,
32 and see if it could be useful for their use cases.
332. _(Future goal):_ People who want to build things with TanStack DB, and want
34 to see a reference implementation of the features it has.
35​
36## Architecture
37​
38The architecture was designed around the two things that I wanted to highlight
39in the interactive tutorial:
40​
411. TanStack DB can make applications feel incredibly fast, even when the network
42 latency is large
432. contrary to conventional local-first approaches, this library doesn't require
44 big technical changes on the back end (works with any database, no need for
45 adding new libs to your backend, simple api endpoints work just fine)
46​
47Databases are expensive, so instead of running one on a server, this app uses a
48local Postgres instance in WASM via [PGlite](https://pglite.dev/).
49​
50I wanted to make it possible to inspect `fetch` requests in the browser to make
51the syncing mechanisms more observable. That is achieved by a service worker
52that proxies http requests between front end and the API handlers (which are
53also part of the front end).
54​
55```mermaid
56sequenceDiagram
57 participant Client
58 participant ServiceWorker as Service Worker (sw.js)
59 participant MainThread as Main Thread (Local API)
60 participant PGlite as PGlite (Local Postgres WASM)
61​
62 Client->>ServiceWorker: API call
63 ServiceWorker->>MainThread: Forward request
64 MainThread->>PGlite: Fetch data
65 PGlite->>MainThread: Return data
66 MainThread->>ServiceWorker: Forward response
67 ServiceWorker->>Client: Respond to original request
68```
69​
70## Development
71​
72See [DEVELOPMENT.md](./DEVELOPMENT.md).