/
README.html
241 lines (230 loc) · 10.3 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Peer-Share</title>
<style>
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.2/dist/katex.min.css" integrity="sha384-yFRtMMDnQtDRO8rLpMIKrtPCD5jdktao2TV19YiZYWMDkUR5GQZR/NOVTdquEx1j" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/markdown.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/highlight.css">
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe WPC', 'Segoe UI', system-ui, 'Ubuntu', 'Droid Sans', sans-serif;
font-size: 14px;
line-height: 1.6;
}
</style>
<style>
.task-list-item { list-style-type: none; } .task-list-item-checkbox { margin-left: -20px; vertical-align: middle; }
</style>
<script src="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.js"></script>
</head>
<body class="vscode-body vscode-light">
<h1 id="peer-share">Peer-Share</h1>
<h2 id="what-is-it">What is it?</h2>
<p>Peer-Share is a distributed peer to peer <a href="https://holochain.org/"><strong>holochain application</strong></a> <em>(<strong>hApp</strong>)</em> that enables peers to shared their contents with others. This content can be shared either completely free of charge or with a paid subscription by using some centralized or distributed payment methods.</p>
<p>Basically this project is an experimental hApp to learn and challenge holochain technology and then design and test some practices and architectures during the Holochain-in-Action meetings.</p>
<p><a href="https://forum.holochain.org/t/about-the-holochain-in-action-category/5448">Holochain-in-Action</a> is a weekly virtual meetings for:</p>
<ul>
<li>Knowledge Sharing</li>
<li>Patterns and best practices discussion</li>
<li>Pair Programming</li>
<li>Analyzing and Designing hApps</li>
</ul>
<p>on Holochain technology and also <a href="https://holo.host/">Holoport</a> echosystem.</p>
<p>If you would like to participate in the Holochain-in-Action meetings please fill out this application form. <a href="https://dawumck27xt.typeform.com/to/uZTCoYs1">here</a></p>
<hr>
<h3 id="run-happ">Run hApp</h3>
<ol start="0">
<li>Install nix-shell</li>
<li>Clone this repository</li>
<li>Go to holo-layer folder and run <code>nix-shell</code> (It takes a lot of time for the first time.)</li>
<li>Go to tests folder and run <code>npm i</code></li>
<li>In the tests folder run <code>npm test</code></li>
</ol>
<hr>
<h3 id="watch-youtube-channel">Watch Youtube Channel:</h3>
<p><a href="https://www.youtube.com/playlist?list=PL2hOZGg8QnUDiTkJF2CD2Fu1D9F6KbsmB">https://www.youtube.com/playlist?list=PL2hOZGg8QnUDiTkJF2CD2Fu1D9F6KbsmB</a></p>
<hr>
<h2 id="general-purposes">General Purposes</h2>
<ol>
<li>Implementing <strong>Dev-ops</strong> in Holochain with minimum DNA changes.</li>
<li>Implementing <strong>hybrid solution</strong> with holocahin (<strong>oracle</strong> topic).</li>
<li>Implementing <strong>modularity</strong> by using some ready modules like File_Storage into the solution.</li>
<li>Designing holochain app with <strong>Holoport</strong></li>
<li>Introducing some patterns and desings for implementing hApps.</li>
</ol>
<h1 id="architect-schema">Architect Schema</h1>
<p><img src="https://i.imgur.com/51Wq6oC.png" alt=""></p>
<h1 id="layers">Layers:</h1>
<ul>
<li>
<p><strong>Holo layer</strong>:</p>
<ul>
<li>Schema abstraction.(Json Schema)</li>
<li>Content abstraction.(Json Content)</li>
<li>Application settings.</li>
<li>Subscription(Capability-token).</li>
<li>Smart Contact:Uploading web-assembly to have customized business rules()(next version)</li>
</ul>
</li>
<li>
<p><strong>Outlet layer</strong>: (MVC pattern)</p>
<ul>
<li><strong>Model</strong>: hApp concrete modeling</li>
<li><strong>View</strong>: UI, view models,</li>
<li><strong>Controller</strong>:
<ul>
<li>DNA Adapter: outlet to DNA</li>
<li>DNA Signaling: DNA to Outlet</li>
<li>Oracle Adapter: connection to hybrid</li>
</ul>
</li>
</ul>
</li>
<li>
<p><strong>External Layer</strong></p>
<ul>
<li>Centralized:
<ul>
<li>Indexing: Elastic Search</li>
<li>Payment methods: Paypal, MasterCard</li>
</ul>
</li>
<li>Cryptocurrency layer
<ul>
<li>Metamask connection</li>
<li>Wallet connection</li>
</ul>
</li>
</ul>
</li>
</ul>
<h1 id="user-stories">User Stories</h1>
<h2 id="guest-user-without-identity">Guest (user without identity):</h2>
<ul>
<li>As a Guest I want to be able to open hApp via browser.</li>
<li>As a Guest I want to search channel and visit the contents.</li>
<li>As a Guest I want to be able to register an account.</li>
</ul>
<h2 id="useruser-with-identity">User:(user with identity)</h2>
<ul>
<li>As a User I want to be able to create a Channel.</li>
<li>As a user I want to see the list of my Channels.</li>
<li>As a User I want to add multiple contents to a Channel.</li>
<li>As a User I want to edit/delete a Channel info.</li>
<li>As a User I want to delete a content of channel.</li>
</ul>
<h2 id="developeruser-with-super-power">Developer:(user with super-power)</h2>
<ul>
<li>As a developer I want to have Dev-ops facility on Outlet layer.</li>
<li>As a developer I want to be able to update app without versioning the DNA.</li>
<li>As a developer I want to be able to create new schema.</li>
</ul>
<hr>
<h1 id="dna-design">DNA design</h1>
<h2 id="schema-definition-in-zome">Schema Definition in Zome</h2>
<ul>
<li>schema definition is created only by developer using progenitor pattern.</li>
</ul>
<pre><code class="language-rust"><div>[Public Entry][Edit(N),Delete(N)]
<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Schema</span></span> {
definition:JSON, <span class="hljs-comment">// JSON Schema: https://json-schema.org/</span>
version:<span class="hljs-built_in">String</span>
owner_address:AgentPubKey, <span class="hljs-comment">// progenitor pattern, this is developer agent address</span>
}
Validation Rules:
<span class="hljs-number">1</span>- definition, version, owner_address are required.
<span class="hljs-number">2</span>- owner_address should be progenitor pattern
<span class="hljs-number">3</span>- json schema should be valid.
</div></code></pre>
<p>Peer-Share Example:
Schema will be created by Admin User.</p>
<pre><code class="language-json="><code><div>Schema {
name: "Channel",
definition:{
[field:title, type:string,lenght:50, required:yes],
[field:category, type:int, required:yes],
[field:createdat, type:datetime, required:yes],
[field:description, type:string, lenght:4000, required:no],
},
version:"v1",
owner_address:"asdf234sfsewr#$2"
}
Schema {
name: "Tag",
definition:{
[field:name, type:string(25), required:yes]
},
version:"v1",
owner_address:"asdf234sfsewr#$2"
}
</div></code></code></pre>
<h2 id="content-definition-in-zome">Content Definition in Zome</h2>
<h3 id="public-data-definition">Public Data Definition</h3>
<ul>
<li>End-user public data which goes to DHT would be using this entry.</li>
</ul>
<pre><code class="language-rust"><div>[Public Entry][Edit(N),Delete(Y)]
<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Public_Content</span></span> {
content:<span class="hljs-built_in">String</span>, <span class="hljs-comment">// JSON data in JsonSchema standard format</span>
schema:Address, <span class="hljs-comment">// Hash address of JsonSchema</span>
owner: AgentPubKey, <span class="hljs-comment">// user address</span>
}
Validation Rules:
<span class="hljs-number">1</span>- ower address is valid
<span class="hljs-number">2</span>- validate content based on the referenced schema using schema format.
</div></code></pre>
<p>Example:</p>
<pre><code class="language-json="><code><div>Public_Content { // Channel is public entry in DHT
content:{
title:"Holochain in Action",
category:1
createdat:"01-01-2021 12:30",
description:"empty"
},
schema:"HNsj6tQ51s1SPrCBkedbNf0Tp0GbM",
owner:"o23KMBAuJGSYnRmoBZM3lMfTKevIkA"
}
</div></code></code></pre>
<h3 id="private-data-definition">Private Data Definition</h3>
<ul>
<li>End-user private data would be using this entry.</li>
</ul>
<pre><code class="language-rust"><div>[Private Entry][Edit(Y),Delete(Y)]
<span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Private_Content</span></span>{
content:<span class="hljs-built_in">String</span>, <span class="hljs-comment">// JSON data in JsonSchema standard format</span>
schema:Address, <span class="hljs-comment">// Hash address of JsonSchema</span>
owner: AgentPubKey, <span class="hljs-comment">// user address</span>
}
Validation Rules:
<span class="hljs-number">1</span>- ower address is valid
<span class="hljs-number">2</span>- validate content based on the referenced schema using schema format.
</div></code></pre>
<p>Example:</p>
<pre><code class="language-json="><code><div>Private_Content { // Draft-Channel is private entry in source-chain
content:{
title:"Holochain in Action",
category:1
createdat:"01-01-2021 12:30",
description:"empty"
},
schema:"HNsj6tQ51s1SPrCBkedbNf0Tp0GbM",
owner:"o23KMBAuJGSYnRmoBZM3lMfTKevIkA"
}
</div></code></code></pre>
<p><strong>Outlet layer(MVC Pattern)</strong></p>
<ul>
<li><strong>Model</strong>: concerete model of application. This model can be changed during the software life cycle. Model would be apply to DNA as an entry and recieved a Hash address. so all generated content related to each specific model should connect to this address.</li>
<li><strong>View</strong>: all UIs and ViewModel are located here.</li>
<li><strong>Controller</strong>: all controllers to communicate to Outside world and DNA are located here. also some basic app settings and mapping can be here. like:
<ul>
<li>Fetch out-side word setting from DNA and map to oracle services.</li>
<li>Some mapping between data and basic information like Category enumeration to int.</li>
</ul>
</li>
</ul>
</body>
</html>