@powerhousedao/academy 0.1.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +3 -0
- package/CHANGELOG.md +9 -0
- package/Dockerfile +31 -0
- package/ProcFile +1 -0
- package/README.md +43 -0
- package/babel.config.js +3 -0
- package/blog/BeyondCommunication-ABlueprintForDevelopment.md +88 -0
- package/blog/TheChallengeOfChange.md +86 -0
- package/blog/images/Iteration.png +0 -0
- package/blog/images/RAD.png +0 -0
- package/docs/academy/01-GetStarted/00-GetStarted.mdx +181 -0
- package/docs/academy/01-GetStarted/01_InstallDemoPackage.md +38 -0
- package/docs/academy/01-GetStarted/02-ToDoList/01-CreateNewPowerhouseProject.md +97 -0
- package/docs/academy/01-GetStarted/02-ToDoList/02-DefineToDoListDocumentModel.md +86 -0
- package/docs/academy/01-GetStarted/02-ToDoList/03-ImplementOperationReducers.md +201 -0
- package/docs/academy/01-GetStarted/02-ToDoList/04-BuildToDoListEditor.md +494 -0
- package/docs/academy/01-GetStarted/02-ToDoList/_category_.json +8 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/DocumentModelHeader.png +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/DocumentModelOperations.png +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/OpenDocumentModelEditor.gif +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/completeEditor.png +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/connectApp.gif +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/form.png +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/mytodolist.gif +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/reducers.png +0 -0
- package/docs/academy/01-GetStarted/02-ToDoList/images/vscode.png +0 -0
- package/docs/academy/01-GetStarted/styles.module.css +99 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/00-BuilderTools.md +234 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/01-SetupBuilderEnvironment.md +247 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/04-UtilitiesAndTips.md +79 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/01-SetupBuilderEnvironment.md +216 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/02-CreateNewPowerhouseProject.md +78 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/03-DefineChatroomDocumentModel.md +139 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/04-ImplementOperationReducers.md +364 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/05-ImplementChatroomEditor.md +194 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/06-LaunchALocalReactor.md +15 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image-1.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image-2.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image-3.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image-4.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image-5.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/image.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/ChatRoomConnectApp.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/ChatRoomTest.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/completeEditor.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/form.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/reducers.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/Chatroom/images/vscode.png +0 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-MoreTutorials/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/01-Create/02-StandardDocumentModelWorkflow.md +229 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/01-BuildingBeautifulDocumentEditors.md +109 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/02-ConfiguringDrives.md +51 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/03-BuildingADriveExplorer.md +174 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/01-OperationHistory.md +67 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/02-RevisionHistoryTimeline.md +132 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/_category_.json +7 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/images/committer-address-popup.png +0 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/images/revision-hash-popup.png +0 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/images/revision-history-list.png +0 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/07-DocumentTools/images/signature-details-popup.png +0 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/images/CreateDrive.png +0 -0
- package/docs/academy/02-AdvancedTutorial/03-BuildingUserExperiences/images/mytodolist.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/01-ReadingAndWritingThroughTheAPI.mdx +121 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/02-GraphQLAtPowerhouse.md +156 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/03-WorkingWithSubgraphs/02-GraphQLAndSubgraphs.mdx +119 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/03-WorkingWithSubgraphs/03-WorkingWithSubgraphs.md +312 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/03-WorkingWithSubgraphs/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/04-analytics-processor.md +342 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/01-SetupBuilderEnvironment.md +215 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/02-CreateNewPowerhouseProject.md +55 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/03-GenerateAnAnalyticsProcessor.md +173 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/04-UpdateAnalyticsProcessor.md +223 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/Create-SPV.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/Create-a-new-asset.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/Create-a-transaction.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/Transaction-table.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/create-a-new-RWA-document.gif +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/05-AnalyticsProcessorTutorial/images/granularity.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/GraphQL References/QueryingADocumentWithGraphQL.md +244 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/GraphQL References/rwa-reports/listener-raw.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/GraphQL References/rwa-reports/raw-reports1.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/GraphQL References/rwa-reports/raw-reports2.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/GraphQL References/rwa-reports/rwaRegister.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/apse.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/best-practices.md +60 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/filter.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/filteroptions.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/graphql/index.md +166 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/graphql/integration.md +75 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/dbs.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/high-level.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/indexeddb.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/libs-core.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/libs.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/lod.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/logo.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/navbar.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-1.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-2.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-3.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-4.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-5.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/overview-6.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/paths-1.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/images/paths-2.jpg +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/intro.md +149 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/benchmarks.md +27 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/browser.md +77 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/compatibility.md +14 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/index.md +230 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/memory.md +72 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/pg.md +63 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/schema.md +14 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/typescript/utilities.md +102 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/use-cases/index.md +7 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/use-cases/maker.md +652 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/06-Analytics Engine/use-cases/processors.md +3 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/images/OperationHistory.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/images/OperationsQuery.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/images/QueryDocumentID.png +0 -0
- package/docs/academy/02-AdvancedTutorial/04-WorkWithData/images/SwitchboardButton.png +0 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/00-IntegrateInAFront-End +3 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/01-IntroducingFusion +18 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/02-IntroductionToPackages.md +79 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/02-PublishYourProject.md +230 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/03-RunOnACloudServer.md +279 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/03-SetupEnvironment.md +436 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/04-GraphQLNamespacing +44 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/05-LaunchYourBackend.md +3 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/06-LaunchYourFrontend.md +3 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/_category_.json +8 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/images/SSHConnection.png +0 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/images/homedesign.png +0 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/images/keyconcepts.png +0 -0
- package/docs/academy/02-AdvancedTutorial/05-Launch/images/tutorialschema.png +0 -0
- package/docs/academy/02-AdvancedTutorial/06-Authorization/Authorization.md +100 -0
- package/docs/academy/02-AdvancedTutorial/_category_.json +7 -0
- package/docs/academy/03-APIReferences/00-PowerhouseCLI.md +1 -0
- package/docs/academy/03-APIReferences/_category_.json +7 -0
- package/docs/academy/04-ComponentLibrary/01-PowerhouseDesignSystem.md +94 -0
- package/docs/academy/04-ComponentLibrary/02-BuildingWithScalars.md +54 -0
- package/docs/academy/04-ComponentLibrary/03-Scalar-Components/01-phid-field.mdx +72 -0
- package/docs/academy/04-ComponentLibrary/03-Scalar-Components/02-input-field.mdx +0 -0
- package/docs/academy/04-ComponentLibrary/04-Complex-Components/01-sidebar.mdx +36 -0
- package/docs/academy/04-ComponentLibrary/05-Layout-Components/01-test-toupdate.mdx +61 -0
- package/docs/academy/04-ComponentLibrary/06-Fragments/01-test-toupdate.mdx +61 -0
- package/docs/academy/04-ComponentLibrary/_category_.json +8 -0
- package/docs/academy/05-Architecture/00-PowerhouseArchitecture.md +50 -0
- package/docs/academy/05-Architecture/01-WorkingWithTheReactor.md +48 -0
- package/docs/academy/05-Architecture/02-ReferencingMonorepoPackages +65 -0
- package/docs/academy/05-Architecture/04-MovingBeyondCRUD +61 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/01-WhatIsADocumentModel.md +188 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/02-DAOandDocumentsModelsQ+A.md +177 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/02-domain-modeling.md +103 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/03-BenefitsOfDocumentModels.md +95 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/05-best-practices.md +257 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/_category_.json +8 -0
- package/docs/academy/05-Architecture/05-DocumentModelTheory/three-data-layers.png +0 -0
- package/docs/academy/05-Architecture/_category_.json +7 -0
- package/docs/academy/05-Architecture/images/image.png +0 -0
- package/docs/academy/06-Cookbook.md +905 -0
- package/docs/academy/07-Glossary.md +50 -0
- package/docs/bookofpowerhouse/01-Overview.md +29 -0
- package/docs/bookofpowerhouse/02-GeneralFrameworkAndPhilosophy.md +15 -0
- package/docs/bookofpowerhouse/03-PowerhouseSoftwareArchitecture.md +33 -0
- package/docs/bookofpowerhouse/04-DevelopmentApproaches.md +36 -0
- package/docs/bookofpowerhouse/05-SNOsandANewModelForOSSandPublicGoods.md +73 -0
- package/docs/bookofpowerhouse/06-SNOsInActionAndPlatformEconomies.md +17 -0
- package/docs/renown/01-intro.md +18 -0
- package/docs/renown/02-renown-login-flow.md +60 -0
- package/docusaurus +0 -0
- package/docusaurus.config.ts +170 -0
- package/package.json +50 -0
- package/powerhouse-docs@0.0.0 +0 -0
- package/sidebars.ts +33 -0
- package/src/components/HomepageFeatures/index.tsx +250 -0
- package/src/components/HomepageFeatures/styles.module.css +267 -0
- package/src/css/custom.css +450 -0
- package/src/pages/index.module.css +37 -0
- package/src/pages/index.tsx +42 -0
- package/src/pages/markdown-page.md +7 -0
- package/static/.nojekyll +0 -0
- package/static/fonts/FranieBold.otf +0 -0
- package/static/fonts/FranieRegular.otf +0 -0
- package/static/img/Powerhouse Website Drive.png +0 -0
- package/static/img/Powerhouse Website Storage Layer (1).png +0 -0
- package/static/img/Powerhouse Website Storage Layer.png +0 -0
- package/static/img/Powerhouse-main-light.svg +13 -0
- package/static/img/Powerhouse-main.svg +13 -0
- package/static/img/Renown Intro Diagram.png +0 -0
- package/static/img/Union.svg +3 -0
- package/static/img/academy/icons/Advanced.svg +4 -0
- package/static/img/academy/icons/Book.svg +5 -0
- package/static/img/academy/icons/Cookbook.svg +3 -0
- package/static/img/academy/icons/Create.svg +3 -0
- package/static/img/academy/icons/Data.svg +3 -0
- package/static/img/academy/icons/Editor.svg +3 -0
- package/static/img/academy/icons/Flash.svg +3 -0
- package/static/img/academy/icons/Launch.svg +3 -0
- package/static/img/academy-icon.png +0 -0
- package/static/img/connect-icon.png +0 -0
- package/static/img/connect.png +0 -0
- package/static/img/docusaurus-social-card.jpg +0 -0
- package/static/img/docusaurus.png +0 -0
- package/static/img/empty-background.png +0 -0
- package/static/img/favicon.ico +0 -0
- package/static/img/fusion-icon.png +0 -0
- package/static/img/fusion.png +0 -0
- package/static/img/ph-icon-light.svg +3 -0
- package/static/img/powerhouse-layer.png +0 -0
- package/static/img/powerhouse-storage-layer.png +0 -0
- package/static/img/reactor.png +0 -0
- package/static/img/renown-icon.png +0 -0
- package/static/img/renown.png +0 -0
- package/static/img/switchboard-icon.png +0 -0
- package/static/img/switchboard.png +0 -0
- package/static/img/undraw_docusaurus_mountain.svg +171 -0
- package/static/img/undraw_docusaurus_react.svg +170 -0
- package/static/img/undraw_docusaurus_tree.svg +40 -0
- package/static/img/video-placeholder.svg +16 -0
- package/static.json +7 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Setup Builder Environment
|
|
2
|
+
|
|
3
|
+
Let's set up your computer to start with any of the Powerhouse Connect tutorials. Don't worry if this is your first time setting up a development environment - we'll guide you through each step!
|
|
4
|
+
|
|
5
|
+
:::warning
|
|
6
|
+
If you've already setup git, node, and npm, your most important step is to install the Powerhouse CLI with the command `npm install ph-cmd`. A global install is recommended if you want to use the command from any directory as a power user. The Powerhouse CLI is used to create, build, and run your Document Models and give you direct access to a series of Powerhouse ecosystem tools.
|
|
7
|
+
:::
|
|
8
|
+
|
|
9
|
+
## Table of Contents
|
|
10
|
+
- [Prerequisites](#prerequisites)
|
|
11
|
+
- [Installing node.js 22](#installing-nodejs)
|
|
12
|
+
- [For Windows](#for-windows)
|
|
13
|
+
- [For macOS](#for-macos)
|
|
14
|
+
- [For Linux (Ubuntu/Debian)](#for-linux-ubuntudebian)
|
|
15
|
+
- [Installing Visual Studio Code](#installing-visual-studio-code)
|
|
16
|
+
- [For Windows](#for-windows-1)
|
|
17
|
+
- [For macOS](#for-macos-1)
|
|
18
|
+
- [For Linux (Ubuntu/Debian)](#for-linux-ubuntudebian-1)
|
|
19
|
+
- [Install Git](#install-git)
|
|
20
|
+
- [For Windows](#for-windows-2)
|
|
21
|
+
- [For macOS](#for-macos-2)
|
|
22
|
+
- [For Linux (Ubuntu/Debian)](#for-linux-ubuntudebian-2)
|
|
23
|
+
- [Configure Git](#configure-git-all-systems)
|
|
24
|
+
- [Verify Installation](#verify-installation)
|
|
25
|
+
|
|
26
|
+
## Prerequisites
|
|
27
|
+
|
|
28
|
+
Before we begin with any of the Powerhouse Connect tutorials, we need to install some software on your computer. We'll need three main tools: node.js 22, which helps us run our code, Visual Studio Code (VS Code), which is where we'll write our code, and Git, which helps us manage our code. Follow the steps below based on your computer's operating system.
|
|
29
|
+
|
|
30
|
+
### Installing node.js 22
|
|
31
|
+
|
|
32
|
+
node.js 22 is a tool that lets us run our application. Let's install it step by step.
|
|
33
|
+
|
|
34
|
+
#### For Windows:
|
|
35
|
+
1. **Set up PowerShell for running commands:**
|
|
36
|
+
- Press the Windows key
|
|
37
|
+
- Type "PowerShell"
|
|
38
|
+
- Right-click on "Windows PowerShell" and select "Run as administrator"
|
|
39
|
+
- In the PowerShell window, type this command and press Enter:
|
|
40
|
+
```powershell
|
|
41
|
+
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
42
|
+
```
|
|
43
|
+
- Type 'A' when prompted to confirm
|
|
44
|
+
- You can now close this window and open PowerShell normally for the remaining steps
|
|
45
|
+
|
|
46
|
+
2. **Install node.js 22:**
|
|
47
|
+
- Visit the [node.js 22 official website](https://nodejs.org/)
|
|
48
|
+
- Click the big green button that says "LTS" (this means Long Term Support - it's the most stable version)
|
|
49
|
+
- Once the installer downloads, double-click it to start installation
|
|
50
|
+
- Click "Next" through the installation wizard, leaving all settings at their defaults
|
|
51
|
+
|
|
52
|
+
3. **Verify Installation:**
|
|
53
|
+
- Open PowerShell (no need for admin mode)
|
|
54
|
+
- Type these commands one at a time and press Enter after each:
|
|
55
|
+
```powershell
|
|
56
|
+
node --version
|
|
57
|
+
pnpm --version
|
|
58
|
+
```
|
|
59
|
+
- You should see version numbers appear after each command (e.g., v18.17.0). If you do, congratulations - node.js 22 is installed!
|
|
60
|
+
|
|
61
|
+
> **Note**: If node.js 22 commands don't work in VS Code, restart VS Code to refresh environment variables.
|
|
62
|
+
|
|
63
|
+
#### For macOS:
|
|
64
|
+
1. **Install Homebrew:**
|
|
65
|
+
- Open Terminal (press Command + Space and type "Terminal")
|
|
66
|
+
- Copy and paste this command into Terminal and press Enter:
|
|
67
|
+
```bash
|
|
68
|
+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
69
|
+
```
|
|
70
|
+
- Follow any additional instructions that appear
|
|
71
|
+
|
|
72
|
+
2. **Install node.js 22:**
|
|
73
|
+
- In the same Terminal window, type this command and press Enter:
|
|
74
|
+
```bash
|
|
75
|
+
brew install node
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
3. **Verify Installation:**
|
|
79
|
+
- In Terminal, type these commands one at a time and press Enter after each:
|
|
80
|
+
```bash
|
|
81
|
+
node --version
|
|
82
|
+
pnpm --version
|
|
83
|
+
```
|
|
84
|
+
- If you see version numbers, you've successfully installed node.js 22!
|
|
85
|
+
|
|
86
|
+
#### For Linux (Ubuntu/Debian):
|
|
87
|
+
1. **Open Terminal:**
|
|
88
|
+
- Press Ctrl + Alt + T on your keyboard, or
|
|
89
|
+
- Click the Activities button and type "Terminal"
|
|
90
|
+
|
|
91
|
+
2. **Update Package List:**
|
|
92
|
+
```bash
|
|
93
|
+
sudo apt update
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
3. **Install node.js 22 and npm:**
|
|
97
|
+
```bash
|
|
98
|
+
sudo apt install nodejs npm
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
4. **Verify Installation:**
|
|
102
|
+
- Type these commands one at a time and press Enter after each:
|
|
103
|
+
```bash
|
|
104
|
+
node --version
|
|
105
|
+
pnpm --version
|
|
106
|
+
```
|
|
107
|
+
- If you see version numbers, you're all set!
|
|
108
|
+
|
|
109
|
+
### Installing Visual Studio Code
|
|
110
|
+
|
|
111
|
+
VS Code is the editor we'll use to write our code. Here's how to install it:
|
|
112
|
+
|
|
113
|
+
#### For Windows:
|
|
114
|
+
1. Visit the [Visual Studio Code website](https://code.visualstudio.com/)
|
|
115
|
+
2. Click the blue "Download for Windows" button
|
|
116
|
+
3. Once the installer downloads, double-click it
|
|
117
|
+
4. Accept the license agreement and click "Next"
|
|
118
|
+
5. Leave the default installation location and click "Next"
|
|
119
|
+
6. In the Select Additional Tasks window, make sure "Add to PATH" is checked
|
|
120
|
+
7. Click "Next" and then "Install"
|
|
121
|
+
8. When installation is complete, click "Finish"
|
|
122
|
+
|
|
123
|
+
#### For macOS:
|
|
124
|
+
1. Visit the [Visual Studio Code website](https://code.visualstudio.com/)
|
|
125
|
+
2. Click the blue "Download for Mac" button
|
|
126
|
+
3. Once the .zip file downloads, double-click it to extract
|
|
127
|
+
4. Drag Visual Studio Code.app to the Applications folder
|
|
128
|
+
5. Double-click the app to launch it
|
|
129
|
+
6. To make VS Code available in your terminal:
|
|
130
|
+
- Open VS Code
|
|
131
|
+
- Press Command + Shift + P
|
|
132
|
+
- Type "shell command" and select "Install 'code' command in PATH"
|
|
133
|
+
|
|
134
|
+
#### For Linux (Ubuntu/Debian):
|
|
135
|
+
1. Open Terminal (Ctrl + Alt + T)
|
|
136
|
+
2. First, update the packages list:
|
|
137
|
+
```bash
|
|
138
|
+
sudo apt update
|
|
139
|
+
```
|
|
140
|
+
3. Install the dependencies needed to add Microsoft's repository:
|
|
141
|
+
```bash
|
|
142
|
+
sudo apt install software-properties-common apt-transport-https wget
|
|
143
|
+
```
|
|
144
|
+
4. Import Microsoft's GPG key:
|
|
145
|
+
```bash
|
|
146
|
+
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
|
|
147
|
+
```
|
|
148
|
+
5. Add the VS Code repository:
|
|
149
|
+
```bash
|
|
150
|
+
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
|
|
151
|
+
```
|
|
152
|
+
6. Install VS Code:
|
|
153
|
+
```bash
|
|
154
|
+
sudo apt install code
|
|
155
|
+
```
|
|
156
|
+
7. Once installed, you can launch VS Code by:
|
|
157
|
+
- Typing `code` in the terminal, or
|
|
158
|
+
- Finding it in your Applications menu
|
|
159
|
+
|
|
160
|
+
### Install Git
|
|
161
|
+
|
|
162
|
+
#### Windows
|
|
163
|
+
1. Open PowerShell (press Windows key, type "PowerShell", and press Enter)
|
|
164
|
+
2. Visit the [Git website](https://git-scm.com/)
|
|
165
|
+
3. Download the latest version for Windows
|
|
166
|
+
4. Run the installer and use the recommended settings
|
|
167
|
+
5. Verify installation by opening PowerShell:
|
|
168
|
+
```powershell
|
|
169
|
+
git --version
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
#### macOS
|
|
173
|
+
1. Install using Homebrew:
|
|
174
|
+
```bash
|
|
175
|
+
brew install git
|
|
176
|
+
```
|
|
177
|
+
2. Verify installation:
|
|
178
|
+
```bash
|
|
179
|
+
git --version
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### Linux (Ubuntu/Debian)
|
|
183
|
+
1. Update package list:
|
|
184
|
+
```bash
|
|
185
|
+
sudo apt update
|
|
186
|
+
```
|
|
187
|
+
2. Install Git:
|
|
188
|
+
```bash
|
|
189
|
+
sudo apt install git
|
|
190
|
+
```
|
|
191
|
+
3. Verify installation:
|
|
192
|
+
```bash
|
|
193
|
+
git --version
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Configure Git (All Systems)
|
|
197
|
+
|
|
198
|
+
Open your terminal (command prompt) and run the following commands to set up Git:
|
|
199
|
+
|
|
200
|
+
After installation, set up your identity:
|
|
201
|
+
```bash
|
|
202
|
+
git config --global user.name "Your Name"
|
|
203
|
+
git config --global user.email "your.email@example.com"
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Verify Installation
|
|
207
|
+
|
|
208
|
+
Open your terminal (command prompt) and run the following commands to verify your setup:
|
|
209
|
+
```bash
|
|
210
|
+
node --version
|
|
211
|
+
pnpm --version
|
|
212
|
+
git --version
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
You should see version numbers displayed for all commands. You're now ready to start with any of the Powerhouse Connect tutorials!
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Create New Powerhouse Project
|
|
2
|
+
|
|
3
|
+
Before we start diving into the tutorial, lets have a quick look at all the steps we'll go through.
|
|
4
|
+
|
|
5
|
+
1. We'll set up a powerhouse project and navigate to the newly created project directory to launch an analytics processor.
|
|
6
|
+
2. Afterwards we'll run a new Reactor instance. A Reactor instance is a local (or remote) node in the Powerhouse network.
|
|
7
|
+
3. We'll create a new Real World Asset (RWA) Portfolio document model on the reactor node and add multiple purchase transactions to it.
|
|
8
|
+
4. We'll observe how the analytics processor receives the operations we've added to the document in the previous step.
|
|
9
|
+
5. We'll stop the reactor & replace our default code with the analytics processor code so it can calculate the different metrics & dimensions we want to see.
|
|
10
|
+
4. Finally we'll run the analytics processor engine on the document model and look at the total value of specific asset classses on a monthly basis, add more data and adjust the granularity of the data we want to see.
|
|
11
|
+
|
|
12
|
+
This tuturial should give you a good understanding of how the analytics processor works and how you can use it to listen, query and combine data from multiple document models or dimensions.
|
|
13
|
+
Offering you the option to cut and slice your data in any way you want.
|
|
14
|
+
|
|
15
|
+
Let's start with step 1 & 2 in the next section of the tutorial!
|
|
16
|
+
|
|
17
|
+
To create a new Powerhouse Document Model Library project, you can use the `ph init` command in your terminal. This command will create a new project in the current directory.
|
|
18
|
+
|
|
19
|
+
## Create New Powerhouse Document Model Library Project
|
|
20
|
+
|
|
21
|
+
:::info
|
|
22
|
+
This command will create a new project in the current directory.
|
|
23
|
+
You can run the command in the terminal window of your OS or you open the newly installed VSCode and run the command in the terminal window of VSCode.
|
|
24
|
+
You will need VSCode later in the tutorial once you have generated the document model.
|
|
25
|
+
Make sure the terminal reflects the directory where you want to create the new project.
|
|
26
|
+
To open a directory in a terminal, you use the cd command to change your current directory. The cd command takes an argument, usually the name of the folder you want to move to, so the full command is
|
|
27
|
+
```bash
|
|
28
|
+
cd your-directory
|
|
29
|
+
```
|
|
30
|
+
This essentially opens that folder and places you in it.
|
|
31
|
+
:::
|
|
32
|
+
|
|
33
|
+
Once you've navigated to the directory where you want to create the new project and in your terminal, run the following command:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
`ph init`
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
In the terminal, you will be asked to enter the project name. Fill in the project name and press enter.
|
|
40
|
+
Since we'll be using the Analytics Processor on a Real World Asset report (RWA), we'll name the project `rwa-analytics`.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
? What is the project name? ‣ rwa-analytics
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Once the project is created and the dependencies are installed (which can take a few minutes), you will see the following output:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
The installation is done!
|
|
50
|
+
|
|
51
|
+
You can start by typing:
|
|
52
|
+
cd rwa-analytics-demo
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Great! You've created a new powerhouse project, let's move on to the next step.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Generate the Reactor & Analytics Processor
|
|
2
|
+
|
|
3
|
+
### Launch the Reactor
|
|
4
|
+
|
|
5
|
+
**First**, navigate to the project directory with `cd rwa-analytics` to start the reactor from the project directory.
|
|
6
|
+
Now open the directory with your code editor with the command `code . `
|
|
7
|
+
|
|
8
|
+
Next, launch the reactor by running the following command in your terminal.
|
|
9
|
+
`ph reactor` . A Reactor instance is a local (or remote) node in the Powerhouse network that can hold & sychronize data. You'll see the following output in your terminal while the reactor is starting up and a new browser window opens with the Connect application. The reactor you've created will become available as a public drive in Connect's left hand side bar, named `Powerhouse`.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
[Reactor]: Initializing ReactorRouterManager...
|
|
13
|
+
[Reactor]: > Registered system subgraph.
|
|
14
|
+
[Reactor]: > Registered d/:drive subgraph.
|
|
15
|
+
[Reactor]: ➜ Reactor: http://localhost:4001/d/powerhouse
|
|
16
|
+
[Reactor]: > Registered analytics subgraph.
|
|
17
|
+
[Reactor]: > Loading document models from /Users/yourmachine/rwa-analytics-demo/document-models
|
|
18
|
+
[Reactor]: > Loading processors from /Users/yourmachine/rwa-analytics-demo/processors
|
|
19
|
+
[Reactor]: > Loading subgraphs from /Users/yourmachine/rwa-analytics-demo/subgraphs
|
|
20
|
+
[Connect]: Watching local document models at '/Users/yourmachine/rwa-analytics-demo/document-models'...
|
|
21
|
+
[Connect]: Watching local document editors at '/Users/yourmachine/rwa-analytics-demo/editors'...
|
|
22
|
+
[Connect]: ➜ Local: http://localhost:3000/
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
As you can see the reactor registered the default system subgraph but also the `d/:drive` subgraph for fetching documents and pushing updates. It also registered the analytics subgraph, which we'll use later for running analytics queries on the document model in the next steps.
|
|
26
|
+
|
|
27
|
+
### Generate the Analytics Processor
|
|
28
|
+
**Next** we'll open up a second terminal window and generate the analytics processor.
|
|
29
|
+
Use the following command to generate the analytics processor in a seperate terminal window.
|
|
30
|
+
```bash
|
|
31
|
+
npm run generate -- --processor rwa-analytics --document-types makerdao/rwa-portfolio
|
|
32
|
+
```
|
|
33
|
+
In your project directory you'll now see the folder 'processors' being created.
|
|
34
|
+
Later we'll see how this processor is actively listening for the operations on a document model.
|
|
35
|
+
Eventually we'll replace the default code of the generated processor with our own custom analytics processor code to listen to specific operations, dimensions and metrics.
|
|
36
|
+
|
|
37
|
+
### Add data to the document model in the Reactor
|
|
38
|
+
|
|
39
|
+
Now that we've generated the analytics processor we need to give it some data to listen to.
|
|
40
|
+
For this we've created the local reactor instance, which will represent a node in the Powerhouse network.
|
|
41
|
+
It represents a node that is usually hosted as a remote server, but in our case we run it locally on our machine.
|
|
42
|
+
The document model data will be stored in the local reactor instance and be analyzed by the analytics processor.
|
|
43
|
+
|
|
44
|
+
Let's move on to the next step where we'll create a new RWA document model and add data to it.
|
|
45
|
+
|
|
46
|
+
### A brief introduction to the RWA document model
|
|
47
|
+
|
|
48
|
+
:::info
|
|
49
|
+
An RWA document model helps an arranger for Sky (previously MakerDAO) to accurately track the value of a Real World Asset (RWA) such as US treasury bills by tracking the purchase, sale and other transactions on the asset.
|
|
50
|
+
In the case of Sky these real world assets are used to back the Sky/MakerDAO stablecoin.
|
|
51
|
+
Let's pretend we're an arranger and we want to track the value of a new RWA asset and analyze the total value of the assetclass on a monthly basis.
|
|
52
|
+
Aside from setting up an analytics processor you'll now also become familiar with how the RWA reporting workflow is captured in a document model.
|
|
53
|
+
:::
|
|
54
|
+
|
|
55
|
+
We'll run through the following scenario:
|
|
56
|
+
1. Add the Asset "T-Bill 4565446" with CUSIP : TB4565446, maturity 01/12/2024. So we have a new asset to track and work with in the document model.
|
|
57
|
+
2. Make a "principal draw" of $10,000,000 on May 1. We're simulating an arranger borrowing $10,000,000 from Sky to purchase the asset.
|
|
58
|
+
3. Make a purchase of 2,500,000 TB4565446 bills for $2,490,000 on May 15.
|
|
59
|
+
4. Make a purchase of 2,000,000 TB4565446 bills for $1,995,000 on June 15.
|
|
60
|
+
5. Make a sale of 4,000,000 TB4565446 bills for $4,000,000 on July 1.
|
|
61
|
+
6. Verify that the document data is correctly entered.
|
|
62
|
+
7. Inspect the document history.
|
|
63
|
+
|
|
64
|
+
### Create a new RWA document model in Connect
|
|
65
|
+
|
|
66
|
+
Under the 'New Document' section in Connect, click on the 'RWA Portfolio' document.
|
|
67
|
+
Name your document model `Sky Rwa's` and click on 'Create'.
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+
|
|
71
|
+
You'll immmediaty see that you've arrived in the portfolio editor with the option to add a new asset.
|
|
72
|
+
Since this document model is a portfolio for tracking the value of different assets, we'll first need to create the asset to be able to add any transaction history to them and track the value of the assets.
|
|
73
|
+
|
|
74
|
+
Hit the 'create asset' button. Which will offer you an overview of all the fields you need to fill in.
|
|
75
|
+
Before we can add an asset, we need to create a new "Special purpose vehicle" (SPV) for the asset.
|
|
76
|
+
A SPV is a legal entity that is created to hold the real world asset such as a US treasury bill.
|
|
77
|
+
For the sake of easily remembering the SPV let's name it 'SPV A'.
|
|
78
|
+
|
|
79
|
+

|
|
80
|
+
|
|
81
|
+
Let's add the asset details now and fill in the following details:
|
|
82
|
+
|
|
83
|
+
- Asset name: T-Bill 4565446
|
|
84
|
+
- CUSIP: TB4565446
|
|
85
|
+
- ISIN: US0045654460
|
|
86
|
+
- Maturity: 12/31/2024
|
|
87
|
+
- Asset Type: Treasury Bill
|
|
88
|
+
- SPV: SPV A
|
|
89
|
+
|
|
90
|
+
Click on the 'Save' button to save the asset.
|
|
91
|
+
Your new asset should look like this:
|
|
92
|
+
|
|
93
|
+

|
|
94
|
+
|
|
95
|
+
### Add a transaction to the asset
|
|
96
|
+
|
|
97
|
+
We're now going to add a transaction to the asset and therefor simulate an arranger borrowing $10,000,000 through a loan from Sky to purchase the asset.
|
|
98
|
+
|
|
99
|
+
To do this, move to the transaction tab and click on the 'create transaction' button below the table.
|
|
100
|
+
|
|
101
|
+
Fill in the following details to complete the transaction of $10,000,000 from Sky to the SPV, known as a principal draw.
|
|
102
|
+
|
|
103
|
+
- Transaction type: Principal Draw
|
|
104
|
+
- Entry Time: 01/05/2024
|
|
105
|
+
- Cash Amount: $10,000,000
|
|
106
|
+
- Transaction reference: 0x123 (this is a reference to the transaction on the blockchain)
|
|
107
|
+
|
|
108
|
+
Click on the 'Save' button to save the transaction.
|
|
109
|
+
|
|
110
|
+

|
|
111
|
+
|
|
112
|
+
You'll now see the transaction appear in the transaction table.
|
|
113
|
+
|
|
114
|
+
### Let's buy & sell some T-bills!
|
|
115
|
+
|
|
116
|
+
Now that we've created the T-bill asset and took out a loan from Sky to purchase it, we can start buying some T-bills.
|
|
117
|
+
Let's buy 2,500,000 T-bills for $2,490,000 on May 15.
|
|
118
|
+
|
|
119
|
+
Create a new transaction and fill in the following details:
|
|
120
|
+
|
|
121
|
+
- Transaction type: Asset Purchase
|
|
122
|
+
- Entry Time: 15/05/2024
|
|
123
|
+
- Asset name: T-Bill 4565446 - US0045654460 - TB4565446
|
|
124
|
+
- Quantity: 2,500,000
|
|
125
|
+
- Asset proceeds: $2,490,000 (this is the price of the T-bills, the price at maturity is $2,500,000, so the profit is $10,000)
|
|
126
|
+
- Transaction reference: 0x123456 (this is a reference to the transaction on the blockchain)
|
|
127
|
+
|
|
128
|
+
Click on the 'Save' button to save the transaction.
|
|
129
|
+
|
|
130
|
+
To make the analysis slightly more interesting, let's also buy 2,000,000 T-bills for $1,995,000 on June 15.
|
|
131
|
+
|
|
132
|
+
Create a new transaction and fill in the following details:
|
|
133
|
+
|
|
134
|
+
- Transaction type: Asset Purchase
|
|
135
|
+
- Entry Time: 15/06/2024
|
|
136
|
+
- Asset name: T-Bill 4565446 - US0045654460 - TB4565446
|
|
137
|
+
- Quantity: 2,000,000
|
|
138
|
+
- Asset proceeds: $1,995,000
|
|
139
|
+
- Transaction reference: 0x123456789
|
|
140
|
+
|
|
141
|
+
Click on the 'Save' button to save the transaction.
|
|
142
|
+
|
|
143
|
+
Our last transaction will be a sale of 4,000,000 T-bills for $4,000,000 on July 1.
|
|
144
|
+
|
|
145
|
+
Create a new transaction and fill in the following details:
|
|
146
|
+
|
|
147
|
+
- Transaction type: Asset Sale
|
|
148
|
+
- Entry Time: 01/07/2024
|
|
149
|
+
- Asset name: T-Bill 4565446 - US0045654460 - TB4565446
|
|
150
|
+
- Quantity: 4,000,000
|
|
151
|
+
- Asset proceeds: $4,000,000
|
|
152
|
+
- Transaction reference: 0x1234567890
|
|
153
|
+
|
|
154
|
+
Click on the 'Save' button to save the transaction.
|
|
155
|
+
|
|
156
|
+
Your table of transactions should now look like this:
|
|
157
|
+
|
|
158
|
+

|
|
159
|
+
|
|
160
|
+
### Verify that the document data is correctly entered & inspect the document history
|
|
161
|
+
|
|
162
|
+
Connect offers you with a few ways to inspect the document data and history. Click on the 'revision history' button in the top right corner of your document model in Connect to see the history of your operations on the document model.
|
|
163
|
+
|
|
164
|
+
Here you'll see that the logic and intelligence of the document model has created a group transaction for the asset, which is the sum of all the sub transactions for the T-bill asset. When you hover over the 'CREATE_GROUP_TRANSACTION' operation you'll see the exact logic that was used to create the group transaction. It's this data that will be used by the analytics processor to calculate the value of the asset over time.
|
|
165
|
+
|
|
166
|
+
Additionally, Connect has a seamless integration with Switchboard, which offer a graphql interface to the document model.
|
|
167
|
+
This allows you to inspect the document data and history in a structured way. Currently we're making use of the Apollo GraphQL sandbox to inspect the document data as it's the easiest way to get started.
|
|
168
|
+
|
|
169
|
+
To inspect the document data, click on the 'Switchboard' icon in the top right corner of your document model in Connect.
|
|
170
|
+
|
|
171
|
+
This will open a new tab with the graphql interface to the document model. If you click 'run' the base query will be executed and you'll see the document data and history. You'll find all the transactions we've added to the asset in the document model previously.
|
|
172
|
+
|
|
173
|
+
Now let's move on to the next step where we'll update the analytics processor code to listen to the document model and calculate the total value of the asset class on a monthly basis.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Update the Analytics Processor
|
|
2
|
+
|
|
3
|
+
Now let's implement our custom analytics processor code to calculate the total value of the asset class on a monthly basis.
|
|
4
|
+
You will likely already be in the desired directory, but if not, navigate to the project directory and open it.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
cd rwa-analytics
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Now open the directory with your code editor.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
code .
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Open the file `processors/rwa-analytics/index.ts` and replace the existing code with the following below:
|
|
17
|
+
|
|
18
|
+
To get a better understanding of how the analytics processor work specific for this tutorial, we've added some comments to the code that might help you understand the different parts of the code.
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import {
|
|
22
|
+
AnalyticsPath,
|
|
23
|
+
type IAnalyticsStore,
|
|
24
|
+
AnalyticsSeriesInput,
|
|
25
|
+
} from "@powerhousedao/reactor-api";
|
|
26
|
+
import {
|
|
27
|
+
CreateGroupTransactionInput,
|
|
28
|
+
} from "document-model-libs/real-world-assets";
|
|
29
|
+
import { DateTime } from "luxon";
|
|
30
|
+
import { IProcessor } from "document-drive/processors/types";
|
|
31
|
+
import { InternalTransmitterUpdate } from "document-drive/server/listener/transmitter/internal";
|
|
32
|
+
import { PHDocument } from "document-model";
|
|
33
|
+
|
|
34
|
+
export class RwaAnalyticsProcessor implements IProcessor {
|
|
35
|
+
constructor(private readonly analyticsStore: IAnalyticsStore) {
|
|
36
|
+
//
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// This is the function that is called when the processor receives a new strand.
|
|
40
|
+
async onStrands<TDocument extends PHDocument>(
|
|
41
|
+
strands: InternalTransmitterUpdate<TDocument>[]
|
|
42
|
+
): Promise<void> {
|
|
43
|
+
if (strands.length === 0) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const values: AnalyticsSeriesInput[] = [];
|
|
48
|
+
for (const strand of strands) {
|
|
49
|
+
// A strand is a collection of operations that are related to a single document and contain the data for the document.
|
|
50
|
+
if (strand.operations.length === 0) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const documentId = strand.documentId.replace("/", "-");
|
|
55
|
+
|
|
56
|
+
// This is the first operation in the strand.
|
|
57
|
+
const firstOp = strand.operations[0];
|
|
58
|
+
const source = AnalyticsPath.fromString(
|
|
59
|
+
// This is the source of the operation, in our case it is the driveId, documentId, branch and scope.
|
|
60
|
+
`ph/${strand.driveId}/${documentId}/${strand.branch}/${strand.scope}`,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (firstOp.index === 0) { // This is the index of the operation in the strand.
|
|
64
|
+
// This is the function that clears the source of the operation since there could be data existing from previous runs for the same document to avoid double counting.
|
|
65
|
+
await this.analyticsStore.clearSeriesBySource(source, true);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
for (const operation of strand.operations) {
|
|
69
|
+
// This is the type of the operation that is being displayed in the terminal.
|
|
70
|
+
console.log(">>> ", operation.type);
|
|
71
|
+
|
|
72
|
+
// This is the type of the operation that is being displayed in the terminal.
|
|
73
|
+
if (operation.type === "CREATE_GROUP_TRANSACTION") {
|
|
74
|
+
// This is the input of the operation. See how we're using the GroupTransactionInput type from the document model.
|
|
75
|
+
const groupTransaction =
|
|
76
|
+
operation.input as CreateGroupTransactionInput;
|
|
77
|
+
if (
|
|
78
|
+
![
|
|
79
|
+
// Although an RWA portfolio could have multiple types of transactions, we're only interested in the ones that are relevant to our analytics.
|
|
80
|
+
"AssetPurchase",
|
|
81
|
+
"AssetSale",
|
|
82
|
+
"PrincipalDraw",
|
|
83
|
+
"PrincipalReturn",
|
|
84
|
+
].includes(groupTransaction.type)
|
|
85
|
+
) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Up next we'll go through the crucial design decision of defining the different dimensions or categories that are relevant to our analytics and queries. In this case we'll create 2 series values for each transaction type. Cash and Fixed Income transactions.
|
|
90
|
+
const { fixedIncomeTransaction, cashTransaction } =
|
|
91
|
+
groupTransaction;
|
|
92
|
+
|
|
93
|
+
if (fixedIncomeTransaction) {
|
|
94
|
+
const dimensions = {
|
|
95
|
+
// We're selecting T-bills as one of the dimensions.
|
|
96
|
+
asset: AnalyticsPath.fromString(
|
|
97
|
+
`sky/rwas/assets/t-bills/${fixedIncomeTransaction.assetId}`
|
|
98
|
+
),
|
|
99
|
+
// We're selecting the portfolio as another dimension.
|
|
100
|
+
portfolio: AnalyticsPath.fromString(
|
|
101
|
+
`sky/rwas/portfolios/${documentId}`,
|
|
102
|
+
),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
values.push({
|
|
106
|
+
dimensions,
|
|
107
|
+
metric: "AssetBalance", // We're selecting the AssetBalance metric.
|
|
108
|
+
source,
|
|
109
|
+
start: DateTime.fromISO(fixedIncomeTransaction.entryTime), // We're selecting the entryTime as the start of the series value.
|
|
110
|
+
value:
|
|
111
|
+
groupTransaction.type === "AssetPurchase"
|
|
112
|
+
? fixedIncomeTransaction.amount
|
|
113
|
+
: -fixedIncomeTransaction.amount,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// We're doing the same thing for cash transactions.
|
|
118
|
+
if (cashTransaction) {
|
|
119
|
+
const dimensions = {
|
|
120
|
+
asset: AnalyticsPath.fromString(`sky/rwas/assets/cash`), // We're selecting cash as one of the dimensions.
|
|
121
|
+
portfolio: AnalyticsPath.fromString(
|
|
122
|
+
`sky/rwas/portfolios/${documentId}`, // We're selecting the portfolio as another dimension since we want to know the cash balance for each portfolio. Each portfolio has a unique documentId. We can then later group or separate by this analytics dimension. We will then also be able to use this dimension to query the cash balance for each portfolio or select a specific portfolio but combine it with other dimensions to get more specific data such as the cash balance for each portfolio for each month. We'll be able to make any combination of hierarchies of dimensions to cut & slice the data we want.
|
|
123
|
+
),
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
values.push({
|
|
127
|
+
dimensions,
|
|
128
|
+
metric: "AssetBalance", // We're selecting the AssetBalance metric for our tutorial scenario
|
|
129
|
+
source,
|
|
130
|
+
start: DateTime.fromISO(cashTransaction.entryTime), // We're selecting the entryTime as the start of the series value.
|
|
131
|
+
value:
|
|
132
|
+
groupTransaction.type === "AssetPurchase" ||
|
|
133
|
+
groupTransaction.type === "PrincipalReturn"
|
|
134
|
+
? -cashTransaction.amount
|
|
135
|
+
: cashTransaction.amount,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Insert all the values into the analytics store at once.
|
|
143
|
+
await this.analyticsStore.addSeriesValues(values);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async onDisconnect() {}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Now that we've implemented the analytics processor, we can make it receive the correct data by running the reactor again in our other terminal window. We currently don't support hot reloading yet so we'll need to stop the reactor and start it again. Press `Ctrl + C` in the terminal window of the reactor to stop it and then run `ph reactor` again.
|
|
151
|
+
|
|
152
|
+
You should now be able to see in the terminal output of the reactor that the processor has received the operations and their details and they are available in the subgraphs. In case you would register a new listener for the analytics processor with a new ID, it would display all the operations from operation 0
|
|
153
|
+
|
|
154
|
+
Now let's move over to the graphql playground to see the data that has been added to the analytics store.
|
|
155
|
+
You'll need to use this specific endpoint to access the graphql playground `http://localhost:4001/analytics`
|
|
156
|
+
|
|
157
|
+
Then, use this query to get the data from the analytics store, but don't forget to also add the variables below.
|
|
158
|
+
|
|
159
|
+
```graphql
|
|
160
|
+
query analytics ($filter: AnalyticsFilter) {
|
|
161
|
+
analytics {
|
|
162
|
+
series(filter: $filter) {
|
|
163
|
+
start
|
|
164
|
+
period
|
|
165
|
+
rows {
|
|
166
|
+
metric
|
|
167
|
+
sum
|
|
168
|
+
value
|
|
169
|
+
dimensions {
|
|
170
|
+
path
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
With the following variables:
|
|
178
|
+
|
|
179
|
+
```graphql
|
|
180
|
+
{
|
|
181
|
+
"filter": {
|
|
182
|
+
"metrics": ["AssetBalance"],
|
|
183
|
+
"granularity": "monthly",
|
|
184
|
+
"start": "2024-05-01",
|
|
185
|
+
"end": " 2024-12-31",
|
|
186
|
+
"dimensions": [
|
|
187
|
+
{
|
|
188
|
+
"lod": 4,
|
|
189
|
+
"name": "asset",
|
|
190
|
+
"select": "sky"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
You'll see that the data is now being displayed per month for each of the asset classes.
|
|
198
|
+
|
|
199
|
+
`sum`: Displays the total cumulative sum of the asset class for the month.
|
|
200
|
+
|
|
201
|
+
`value`: Displays the total change in value of the asset class for that month.
|
|
202
|
+
|
|
203
|
+
You'll also see that in the month of july the AssetBalance for the "path": "sky/rwas/assets/cash" has increased by 4.000.000 since we sold 4.000.000 worth of T-bills in July.
|
|
204
|
+
|
|
205
|
+
When you play around with the variables of our query you can see the different granularity of the data that is being displayed on the image below.
|
|
206
|
+
|
|
207
|
+

|
|
208
|
+
|
|
209
|
+
If you would take 'total' you would see the total value left in the portfolio.
|
|
210
|
+
|
|
211
|
+
To see more changes become present in the analytics store, you could add more transactions to the portfolio. We could do this by adding a rwa portfolio with a different documentId.
|
|
212
|
+
Imagine that this is similar to real time updates that might happen to a live environment when new transactions are added to a porftolio.
|
|
213
|
+
|
|
214
|
+
Now you know how to implement a custom analytics processor and how to query the data from the analytics store!
|
|
215
|
+
In case you'd want to try it out on another document model follow the steps below.
|
|
216
|
+
|
|
217
|
+
1. Generate the processor
|
|
218
|
+
2. Update the processor code
|
|
219
|
+
3. Launch the processor
|
|
220
|
+
4. Launch the reactor (again) and add your data
|
|
221
|
+
5. Query the data from the analytics store
|
|
222
|
+
|
|
223
|
+
Enjoy!
|
|
Binary file
|