@powerhousedao/academy 3.3.0-dev.1 → 3.3.0-dev.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 3.3.0-dev.3 (2025-07-08)
2
+
3
+ ### 🚀 Features
4
+
5
+ - added operational hooks and utils in reactor-browser ([216f7d03d](https://github.com/powerhouse-inc/powerhouse/commit/216f7d03d))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - acaldas
10
+
11
+ ## 3.3.0-dev.2 (2025-07-05)
12
+
13
+ ### 🩹 Fixes
14
+
15
+ - **academy:** graphql at powerhouse update ([fea4eae24](https://github.com/powerhouse-inc/powerhouse/commit/fea4eae24))
16
+
17
+ ### ❤️ Thank You
18
+
19
+ - Callme-T
20
+
1
21
  ## 3.3.0-dev.1 (2025-07-04)
2
22
 
3
23
  This was a version bump only for @powerhousedao/academy to align it with other projects, there were no code changes.
@@ -98,7 +98,7 @@ import BrowserOnly from '@docusaurus/BrowserOnly';
98
98
  </h3>
99
99
  </div>
100
100
  <div className={styles.cardContent}>
101
- <a href="/academy/MasteryTrack/WorkWithData/ReadingAndWritingThroughTheAPI" className="path-button">Read & write through the API</a>
101
+ <a href="/academy/MasteryTrack/WorkWithData/UsingTheAPI" className="path-button">Read & write through the API</a>
102
102
  <a href="/academy/MasteryTrack/WorkWithData/WorkingWithSubgraphs" className="path-button">Create your own subgraph</a>
103
103
  <a href="/academy/MasteryTrack/WorkWithData/Analytics-Engine/intro" className="path-button">Use the analytics engine</a>
104
104
  </div>
@@ -66,7 +66,7 @@ You can also add a new remote drive to your Connect environment programmatically
66
66
  `bash
67
67
  ph reactor
68
68
  `
69
- - The GraphQL endpoint of your instance. For example, for the staging environment, use: `https://staging.switchboard.phd/graphql/system` (this is a supergraph gateway. Read more about [subgraphs and supergraphs here](/academy/MasteryTrack/WorkWithData/WorkingWithSubgraphs).
69
+ - The GraphQL endpoint of your instance. For example, for the staging environment, use: `https://staging.switchboard.phd/graphql/system` (this is a supergraph gateway. Read more about [subgraphs and supergraphs here](/academy/MasteryTrack/WorkWithData/UsingSubgraphs).
70
70
  - Appropriate permissions to perform mutations.
71
71
  :::
72
72
 
@@ -143,6 +143,6 @@ This approach allows you to automate drive creation and integration with other s
143
143
  You've now experienced the use of GraphQL to modify or read data captured in Powerhouse for the first time.
144
144
  You can now either continue with:
145
145
  - User interfaces and [build a custom drive experiences](/academy/MasteryTrack/BuildingUserExperiences/BuildingADriveExplorer)
146
- - Keep playing with data and the [Switchboard API](/academy/MasteryTrack/WorkWithData/ReadingAndWritingThroughTheAPI)
146
+ - Keep playing with data and the [Switchboard API](/academy/MasteryTrack/WorkWithData/UsingTheAPI)
147
147
 
148
148
  Enjoy!
@@ -1,9 +1,10 @@
1
1
  # GraphQL at Powerhouse
2
2
 
3
- In this section, we will cover **the core concepts of GraphQL with examples applied to the Powerhouse ecosystem**. More specifically, GraphQL is used as:
4
- - The **schema definition language (SDL)** for defining our document models and thereby self-documenting the API to the data model. It allows developers to define the structure and relationships of data in a strongly-typed format.
5
- - As the **query language in subgraphs**, which allow different services to expose and query structured data dynamically. Jump to the section [GraphQL and Subgraphs](/academy/MasteryTrack/WorkWithData/WorkingWithSubgraphs/GraphQLAndSubgraphs) to learn more about this.
3
+ In this section, we will cover **the core concepts of GraphQL with examples applied to the Powerhouse ecosystem**. GraphQL plays a fundamental role in defining document model data schemas, handling data access patterns, and enabling event-driven workflows within the Powerhouse ecosystem.
6
4
 
5
+ More specifically, GraphQL is used as:
6
+ - The **schema definition language (SDL)** for defining our document models and thereby self-documenting the API to the data model. It allows developers to define the structure and relationships of data in a strongly-typed format.
7
+ - As the **query language in subgraphs**, which allow different services to expose and query structured data dynamically.
7
8
 
8
9
  ### Why GraphQL?
9
10
 
@@ -152,5 +153,132 @@ When dealing with lists of data, GraphQL employs a pattern that includes:
152
153
  ```
153
154
 
154
155
  ---
156
+
157
+ ## GraphQL Subgraphs in Powerhouse
158
+
159
+ Powerhouse structures its data into **subgraphs**, which are modular GraphQL services that connect to the Reactor (Powerhouse's core data infrastructure) or Operational Data Stores fueled by data from processors. Each subgraph has its own SDL, ensuring modularity and flexibility while working within the ecosystem.
160
+
161
+ ### Fetching data from the Reactor
162
+
163
+ Powerhouse uses GraphQL to expose system-level data, such as drives, users, and operational records through the **System Subgraph**, which allows querying of drives, stored files and folders.
164
+
165
+ ### Operational data stores
166
+
167
+ Custom subgraphs can be created to store and retrieve operational data in real time. For example, a subgraph can track file uploads and expose this data via GraphQL queries:
168
+
169
+ ```graphql title="File Schema Example"
170
+ type File {
171
+ id: ID!
172
+ name: String!
173
+ size: Int!
174
+ createdAt: DateTime!
175
+ }
176
+
177
+ type Query {
178
+ getFile(id: ID!): File
179
+ }
180
+ ```
181
+
182
+ This schema ensures that every File entity has an ID, name, size, and timestamp, providing a structured approach to file management data.
183
+
184
+ ---
185
+
186
+ ## CQRS Architecture with GraphQL
187
+
188
+ Powerhouse uses **CQRS (Command Query Responsibility Segregation)** to separate write operations (commands) from read operations (queries). This improves system scalability and flexibility:
189
+
190
+ - **GraphQL Queries** handle read operations, retrieving structured data efficiently
191
+ - **GraphQL Mutations** handle write operations, modifying the state in a controlled manner
192
+
193
+ Powerhouse's subgraphs act as the read layer, while processors handle write operations into operational data stores. This prevents conflicts between querying and modifying data.
194
+
195
+ | Layer | Role | GraphQL Usage | Implementation |
196
+ | --- | --- | --- | --- |
197
+ | Write Model (Commands) | Handles state changes (adding, modifying, deleting) | GraphQL Mutations | Processor |
198
+ | Read Model (Queries) | Optimized for fetching/reading/retrieving data | GraphQL Queries | Subgraph |
199
+
200
+ ### Read and write separation
201
+
202
+ **Read Model (Query)**
203
+ - Optimized for data retrieval
204
+ - Structured using GraphQL Queries
205
+ - Aggregates and exposes data via a subgraph
206
+ - Pulls data from Operational Data Stores, Analytics Stores, and Reactor
207
+ - Subgraphs do not directly modify the data—they only expose pre-processed information
208
+
209
+ ```graphql title="Example Query Operation"
210
+ query {
211
+ getFile(id: "123") {
212
+ name
213
+ size
214
+ createdAt
215
+ }
216
+ }
217
+ ```
218
+
219
+ **Write Model (Mutation)**
220
+ - Handles state changes (adding, modifying, deleting)
221
+ - Structured using GraphQL Mutations
222
+ - Writes data to Operational Data Stores
223
+
224
+ ```graphql title="Example Mutation Operation"
225
+ mutation {
226
+ createFile(name: "document.pdf", size: 1024) {
227
+ id
228
+ name
229
+ createdAt
230
+ }
231
+ }
232
+ ```
233
+
234
+ ---
235
+
236
+ ## GraphQL and Event-Driven Architecture
237
+
238
+ Event-Driven Architecture (EDA) enables asynchronous processing where events trigger actions. Powerhouse uses GraphQL to expose real-time event data from its Reactor and Operational Data Stores.
239
+
240
+ ### How GraphQL fits into EDA
241
+
242
+ - **Real-Time Data Exposure** – Subgraphs fetch event-based data updates
243
+ - **Event Subscription Mechanism** – Powerhouse is working towards integrating GraphQL Subscriptions for real-time updates
244
+ - **Efficient Decoupling** – Events are stored in an operational datastore, and GraphQL queries retrieve structured results
245
+
246
+ ### Example: Powerhouse's event flow
247
+
248
+ 1. Processor detects an event (e.g., file upload)
249
+ 2. Writes event data to the Operational Data Store
250
+ 3. Subgraph exposes the updated data via GraphQL
251
+
252
+ ---
253
+
254
+ ## GraphQL Subscriptions
255
+
256
+ Although Powerhouse currently uses queries and mutations, **GraphQL Subscriptions** could allow real-time streaming of event-based data in future implementations:
257
+
258
+ ```graphql title="Example Future Subscription"
259
+ subscription {
260
+ fileUploaded {
261
+ id
262
+ name
263
+ size
264
+ createdAt
265
+ }
266
+ }
267
+ ```
268
+
269
+ This would enable clients to listen for new file uploads without polling, providing a more efficient real-time experience.
270
+
271
+ ---
272
+
155
273
  ## Summary
156
- GraphQL offers a streamlined and efficient approach to data retrieval, particularly useful when you need granular control over your API interactions. By defining a robust schema, using precise fields and arguments, and leveraging introspection, GraphQL minimizes unnecessary data transfers. If you want to learn more about GraphQL, there is the following link to the official documentation: [Introduction to GraphQL](https://graphql.org/learn/).
274
+
275
+ GraphQL offers a streamlined and efficient approach to data retrieval, particularly useful when you need granular control over your API interactions. In the Powerhouse ecosystem, GraphQL serves multiple critical functions:
276
+
277
+ - **Schema Definition**: Defines document models and self-documents APIs
278
+ - **Subgraph Architecture**: Enables modular, scalable data services
279
+ - **CQRS Implementation**: Separates read and write operations for better performance
280
+ - **Event-Driven Integration**: Supports real-time data exposure and future subscription capabilities
281
+
282
+ By defining robust schemas, using precise fields and arguments, leveraging introspection, and implementing subgraphs with CQRS principles, GraphQL minimizes unnecessary data transfers while maximizing flexibility and scalability in the Powerhouse platform.
283
+
284
+ For more information about GraphQL fundamentals, visit the [Introduction to GraphQL](https://graphql.org/learn/) documentation.
@@ -1,9 +1,10 @@
1
- # Read and write through the API
1
+ # Using the API
2
2
 
3
3
  ## Introduction to Switchboard
4
4
 
5
- **Switchboard** is the API interface that allows developers and data engineers to get access to data collected through document models in Connect and Fusion.
6
- After structurally capturing the desired data from your formalized business processes, it can be used to build insightful experiences in external websites, drive widgets, or create specific reports and dashboards in Fusion.
5
+ **Switchboard** is the API interface that enables developers and data engineers to access data captured through document models in Connect and Fusion.
6
+
7
+ Once you've structured and captured data from your business processes, Switchboard allows you to leverage that data to build insightful experiences in external websites, create interactive drive widgets, or generate detailed reports and dashboards in Fusion.
7
8
 
8
9
  :::tip Using your document's state schema
9
10
  Since your document models are defined with a GraphQL schema, you can use the same objects and fields in your queries and mutations to retrieve or write data from and to your documents.
@@ -39,10 +40,10 @@ This will return a URL to access the Reactor.
39
40
 
40
41
  ### Adding a remote drive or Reactor to Connect
41
42
 
42
- If the remote drive or Reactor isn't present yet in Connect, you can add it by clicking the (+) button in the Connect drive navigation and using the localhost URL to add a new drive with its underlying reactor. Usually, this is http://localhost:4001/d/powerhouse.
43
+ If the remote drive or Reactor isn't present yet in Connect, you can add it by clicking the (+) 'Create New Drive' button in the Connect drive navigation and using the localhost URL to add a new drive with its underlying reactor. Usually, this is http://localhost:4001/d/powerhouse.
43
44
 
44
45
  Get access to an **organization's drive** instances by adding their drive to your Connect Drive navigation tree view with the help of the correct drive URL.
45
- Click the (+) to add a public drive. To add a new drive, you'll have to know the correct public URL of the drive. Read more about [configuring drives](/academy/Architecture/WorkingWithTheReactor).
46
+ Click the (+) 'Create New Drive' to add a public drive. To add a new drive, you'll have to know the correct public URL of the drive. Read more about [configuring drives](/academy/Architecture/WorkingWithTheReactor).
46
47
 
47
48
  <figure className="image-container">
48
49
  <img src={require("./images/AddNewDriveURL.png").default} alt="Add a drive through an URL" />
@@ -92,7 +93,7 @@ Copy this ID to use it in the Switchboard API.
92
93
  <figcaption>You can copy your Document ID from your operations history.</figcaption>
93
94
  </figure>
94
95
 
95
- When you navigate to your Switchboard endpoint (e.g., http://localhost:4001/graphql/system, https://switchboard.phd/graphql/system, or a custom domain), you can use this document ID to query the state of your document.
96
+ When you navigate to your Switchboard endpoint by adding **`/graphql/system`** to the end of your URL. (e.g., http://localhost:4001/graphql/system, https://switchboard.phd/graphql/system, or add it to a custom domain), you can use this document ID to query the state of your document.
96
97
  The documentation on the left-hand side of the Apollo Sandbox will show you all the different fields that are available to query.
97
98
 
98
99
  <figure className="image-container">
@@ -128,7 +129,7 @@ It extracts common metadata fields such as **id**, **name**, **documentType**, *
128
129
 
129
130
  ### Get the state of the document
130
131
 
131
- Once you've found your document via any of the three options, you'll be able to query its state.
132
+ Once you've found your document via any of the three options above, you'll be able to query its state.
132
133
 
133
134
  In the previous step, we queried for document metadata. Now let's query for the actual content of the document state.
134
135
 
@@ -230,4 +231,7 @@ After performing a write mutation, you can verify that the change was successful
230
231
  1. **Query the document state again:** Rerun the `getDocument` query from earlier in this tutorial. You should see the new item in the list or the deleted item removed.
231
232
  2. **Check the Operation History:** The operation history in Connect will show the new `ADD_TODO_ITEM` or `DELETE_TODO_ITEM` operation, along with who performed it and when. This provides a complete audit trail of all changes to the document.
232
233
 
234
+
235
+ ### Summary
236
+
233
237
  This ability to programmatically read from and write to documents via the GraphQL API is a powerful feature of Powerhouse. It unlocks countless possibilities for integrating your structured data into other applications, building automated workflows, and creating rich, data-driven user experiences.