Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit 9865e7a

Browse files
committed
feat(docs): update intro and landing
1 parent 0f0ac1d commit 9865e7a

11 files changed

Lines changed: 313 additions & 109 deletions

File tree

docs/docs/connectivity.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Connectivity
3+
sidebar_position: 2
4+
---
5+
6+
# Connectivity
7+
8+
No need to connect peers manually, DStack will handle it by itself
9+
10+
if you want to ensure that some peers is connected
11+
12+
### Connect to peer manually
13+
14+
```javascript
15+
await stack.connect('/some/addr');
16+
```
17+
18+
### Get connected Peers
19+
20+
```javascript
21+
const peers = await stack.peers();
22+
```

docs/docs/intro.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

docs/docs/intro.mdx

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
title: Quick Look
3+
sidebar_position: 1
4+
---
5+
6+
import Flowchart from '../src/components/Flowchart.js';
7+
8+
_DStack is under heavy development, currently some docs is not finished yet_
9+
10+
Let's discover **DStack in less than 15 minutes**.
11+
12+
### Architecture
13+
14+
<Flowchart
15+
snapToGrid={true}
16+
elements={[
17+
{
18+
id: 'ipfs',
19+
type: 'input',
20+
data: { label: 'IPFS' },
21+
position: { x: 400, y: 25 },
22+
},
23+
{
24+
id: 'stack',
25+
data: { label: 'Stack' },
26+
position: { x: 400, y: 100 },
27+
},
28+
{
29+
id: 'pubsub',
30+
type: 'output',
31+
data: { label: 'PubSub' },
32+
style: { borderColor: '#000' },
33+
position: { x: 200, y: 300 },
34+
},
35+
{
36+
id: 'store',
37+
data: { label: 'Store' },
38+
position: { x: 500, y: 250 },
39+
},
40+
{
41+
id: 'shard',
42+
type: 'output',
43+
style: { borderColor: '#000' },
44+
data: { label: 'Shard' },
45+
position: { x: 500, y: 350 },
46+
},
47+
// animated edge
48+
{ id: 'e1-2', source: 'ipfs', target: 'stack', animated: true },
49+
{ id: 'e2-3', source: 'stack', target: 'pubsub' },
50+
{ id: 'e3-4', source: 'stack', target: 'store' },
51+
{
52+
id: 'e4-5',
53+
source: 'store',
54+
target: 'shard',
55+
animated: true,
56+
},
57+
]}
58+
/>
59+
60+
## Add DStack to your project
61+
62+
Using Yarn:
63+
64+
```shell
65+
yarn add @dstack-js/lib
66+
```
67+
68+
Using NPM:
69+
70+
```shell
71+
npm i -S @dstack-js/lib
72+
```
73+
74+
You also need IPFS, can use `@dstack-js/ipfs` or `ipfs-core@^0.13.0`, `@dstack-js/ipfs` provides zero configuration package for DStack.
75+
76+
### Initialize Stack
77+
78+
```javascript
79+
import { create } from '@dstack-js/ipfs';
80+
import { Stack } from '@dstack-js/lib';
81+
82+
// Browser:
83+
const ipfs = await create();
84+
// In Node.js environment you need to provide WebRTC implementation
85+
// const wrtc = require('wrtc');
86+
// const ipfs = await create({}, wrtc);
87+
88+
const stack = await Stack.create('namespace', ipfs);
89+
90+
console.log('My Peer ID is:', stack.id);
91+
```
92+
93+
### Interact with PubSub
94+
95+
```javascript
96+
stack.pubsub.subscribe('topic', (msg) => {
97+
console.log('Received a message', msg.from, msg.data);
98+
});
99+
100+
stack.pubsub.publish('topic', 'Hello, DStack!');
101+
```
102+
103+
### Interact with Store
104+
105+
```javascript
106+
const shard = await stack.store.set('hello', 'world');
107+
108+
// Set value
109+
await shard.set('dstack');
110+
111+
// Get fresh value
112+
await shard.get();
113+
114+
const shard = await stack.store.get('hello');
115+
```

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"prism-react-renderer": "^1.2.1",
2424
"react": "^17.0.1",
2525
"react-dom": "^17.0.1",
26+
"react-flow-renderer": "^9.7.3",
2627
"url-loader": "^4.1.1"
2728
},
2829
"name": "docs",

docs/src/components/Flowchart.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import ReactFlow, { Background } from 'react-flow-renderer';
3+
4+
export default ({ elements, style, ...props }) => (
5+
<div
6+
style={{
7+
height: 425,
8+
background: 'white',
9+
borderRadius: '4px',
10+
padding: '4px',
11+
...style,
12+
}}
13+
>
14+
<ReactFlow
15+
elements={elements}
16+
grid={true}
17+
nodesDraggable={false}
18+
nodesConnectable={false}
19+
elementsSelectable={false}
20+
{...props}
21+
>
22+
<Background variant="dots" gap={10} size={0.5} />
23+
</ReactFlow>
24+
</div>
25+
);

docs/src/components/HomepageFeatures.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@ const FeatureList = [
88
Svg: require('../../static/img/logo_white.svg').default,
99
description: (
1010
<>
11-
DStack was designed from the ground up to be easily installed and
12-
used to built semi-decentralized apps quickly, where your product infrastructure is single source of truth
11+
DStack was designed from the ground up to be easily installed and used
12+
zero configuration
1313
</>
1414
),
1515
},
1616
{
17-
title: 'Powered by GraphQL',
18-
Svg: require('../../static/img/graphql.svg').default,
17+
title: 'Powered by IPFS',
18+
Svg: require('../../static/img/ipfs.svg').default,
1919
description: (
2020
<>
21-
DStack provides a set of graphql elements (scalars, directives, etc) to store and fetch your data on decentralized web
21+
DStack simplifies IPFS JavaScript API for application development usage
2222
</>
2323
),
2424
},
2525
{
26-
title: 'TypeScript Support',
27-
Svg: require('../../static/img/Typescript_logo_2020.svg').default,
26+
title: 'Under construction',
27+
Svg: require('../../static/img/Under_construction.svg').default,
2828
description: (
2929
<>
30-
Built using TypeScript and includes type definition in every module
30+
In an active development <br /> Highly experimental as of a moment
3131
</>
3232
),
3333
},
3434
];
3535

36-
function Feature({Svg, title, description}) {
36+
function Feature({ Svg, title, description }) {
3737
return (
3838
<div className={clsx('col col--4')}>
3939
<div className="text--center">

docs/static/img/Typescript_logo_2020.svg

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Loading

docs/static/img/graphql.svg

Lines changed: 0 additions & 61 deletions
This file was deleted.

docs/static/img/ipfs.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)