1111[ ![ codecov] ( https://img.shields.io/codecov/c/github/ipfs/helia.svg?style=flat-square )] ( https://codecov.io/gh/ipfs/helia )
1212[ ![ CI] ( https://img.shields.io/github/actions/workflow/status/ipfs/helia/main.yml?branch=main\& style=flat-square )] ( https://github.com/ipfs/helia/actions/workflows/main.yml?query=branch%3Amain )
1313
14+ ## 🌟 Usage
15+
16+ A quick overview of how to get different types of data in and out of your Helia
17+ node.
18+
19+ ### 🪢 Strings
20+
21+ You can use the [ @helia/strings ] ( https://www.npmjs.com/package/@helia/strings )
22+ module to easily add and get strings from your Helia node:
23+
24+ ``` js
25+ import { createHelia } from ' helia'
26+ import { strings } from ' @helia/strings'
27+
28+ const helia = await createHelia ()
29+ const s = strings (helia)
30+
31+ const myImmutableAddress = await s .add (' hello world' )
32+
33+ console .log (await s .get (myImmutableAddress))
34+ // hello world
35+ ```
36+
37+ ### 🌃 JSON
38+
39+ The [ @helia/json ] ( https://www.npmjs.com/package/@helia/json ) module lets you add
40+ or get plain JS objects:
41+
42+ ``` js
43+ import { createHelia } from ' helia'
44+ import { json } from ' @helia/json'
45+
46+ const helia = await createHelia ()
47+ const j = json (helia)
48+
49+ const myImmutableAddress = await j .add ({ hello: ' world' })
50+
51+ console .log (await j .get (myImmutableAddress))
52+ // { hello: 'world' }
53+ ```
54+
55+ ### 🌠 DAG-JSON
56+
57+ The [ @helia/dag-json ] ( https://www.npmjs.com/package/@helia/dag-json ) allows you
58+ to store references to linked objects as
59+ [ CIDs] ( https://docs.ipfs.tech/concepts/content-addressing ) :
60+
61+ ``` js
62+ import { createHelia } from ' helia'
63+ import { dagJson } from ' @helia/dag-json'
64+
65+ const helia = await createHelia ()
66+ const d = dagJson (helia)
67+
68+ const object1 = { hello: ' world' }
69+ const myImmutableAddress1 = await d .add (object1)
70+
71+ const object2 = { link: myImmutableAddress1 }
72+ const myImmutableAddress2 = await d .add (object2)
73+
74+ const retrievedObject = await d .get (myImmutableAddress2)
75+ console .log (retrievedObject)
76+ // { link: CID(baguqeerasor...) }
77+
78+ console .log (await d .get (retrievedObject .link ))
79+ // { hello: 'world' }
80+ ```
81+
82+ ### 🌌 DAG-CBOR
83+
84+ [ @helia/dag-cbor ] ( https://www.npmjs.com/package/@helia/dag-json ) works in a
85+ similar way to ` @helia/dag-json ` but stores objects using
86+ [ Concise Binary Object Representation] ( https://cbor.io/ ) :
87+
88+ ``` js
89+ import { createHelia } from ' helia'
90+ import { dagCbor } from ' @helia/dag-cbor'
91+
92+ const helia = await createHelia ()
93+ const d = dagJson (helia)
94+
95+ const object1 = { hello: ' world' }
96+ const myImmutableAddress1 = await d .add (object1)
97+
98+ const object2 = { link: myImmutableAddress1 }
99+ const myImmutableAddress2 = await d .add (object2)
100+
101+ const retrievedObject = await d .get (myImmutableAddress2)
102+ console .log (retrievedObject)
103+ // { link: CID(baguqeerasor...) }
104+
105+ console .log (await d .get (retrievedObject .link ))
106+ // { hello: 'world' }
107+ ```
108+
109+ ### 🐾 Next steps
110+
111+ Check out the [ helia-examples] ( https://github.com/ipfs-examples/helia-examples )
112+ repo for how to do mostly anything with your Helia node.
113+
14114## Table of contents <!-- omit in toc -->
15115
116+ - [ 🌟 Usage] ( #-usage )
117+ - [ 🪢 Strings] ( #-strings )
118+ - [ 🌃 JSON] ( #-json )
119+ - [ 🌠 DAG-JSON] ( #-dag-json )
120+ - [ 🌌 DAG-CBOR] ( #-dag-cbor )
121+ - [ 🐾 Next steps] ( #-next-steps )
16122- [ 🥅 Purpose and goals] ( #-purpose-and-goals )
17123- [ 🏃♀️ Getting Started] ( #️-getting-started )
18124- [ 📒 API Docs] ( #-api-docs )
125+ - [ 📐 System diagram] ( #-system-diagram )
19126- [ 🏭 Code Structure] ( #-code-structure )
20127- [ 📣 Project status] ( #-project-status )
21128- [ 🛣️ Roadmap] ( #️-roadmap )
@@ -39,11 +146,43 @@ Check out the [Helia examples repo](https://github.com/ipfs-examples/helia-examp
39146
40147- https://ipfs.github.io/helia
41148
149+ ## 📐 System diagram
150+
151+ ``` mermaid
152+ graph TD;
153+ User["User or application"]-->IPNS["@helia/ipns"];
154+ User-->UnixFS["@helia/unixfs"];
155+ User-->Libp2p;
156+ User-->Datastore;
157+ User-->Blockstore;
158+ UnixFS-->Blockstore;
159+ IPNS-->Datastore;
160+ subgraph helia [Helia]
161+ Datastore
162+ Blockstore-->Bitswap;
163+ Libp2p-->DHT;
164+ Libp2p-->PubSub;
165+ Libp2p-->IPNI;
166+ Libp2p-->Reframe;
167+ end
168+ Blockstore-->BlockStorage["File system/IDB/S3/etc"]
169+ Datastore-->DataStorage["Level/S3/IDB/etc"]
170+ Bitswap-->Network;
171+ DHT-->Network;
172+ PubSub-->Network;
173+ IPNI-->Network;
174+ Reframe-->Network;
175+ ```
176+
42177## 🏭 Code Structure
43178Helia embraces a modular approach and encourages users to bring their own implementations of interfacing libraries to suit their needs. Helia also ships supplemental libraries and tools including:
44179
45180- [ ` @helia/UnixFS ` ] ( https://github.com/ipfs/helia-unixfs )
46181- [ ` @helia/ipns ` ] ( https://github.com/ipfs/helia-ipns )
182+ - [ ` @helia/strings ` ] ( https://github.com/ipfs/helia-strings )
183+ - [ ` @helia/json ` ] ( https://github.com/ipfs/helia-json )
184+ - [ ` @helia/dag-json ` ] ( https://github.com/ipfs/helia-dag-json )
185+ - [ ` @helia/dag-cbor ` ] ( https://github.com/ipfs/helia-dag-cbor )
47186
48187These libraries are by no means the "one true implementation", but instead instead provide optionality depending on one's needs.
49188
0 commit comments