Create a new chatroom project
π¦ Reference Code: chatroom-demo
This tutorial has a complete reference implementation available. You can:
- View the complete code for each step
- Clone and compare your implementation
- Use
git diffto compare your code with the reference
π How to use this tutorial
This tutorial is designed for you to build your own project from scratch while having access to reference code.
Setup: Create your project and connect to tutorial repoβ
-
Create your project following the tutorial:
mkdir ph-projects
cd ph-projects
ph init
# When prompted, enter project name: ChatRoom
cd ChatRoom -
Add the tutorial repository as a remote to access reference code:
git remote add tutorial https://github.com/powerhouse-inc/chatroom-demo.git
git fetch tutorial --prune -
Create your own branch to keep your work organized:
git checkout -b my-chatroom-project
Now you have access to the complete reference implementation while working on your own code!
Compare your work with the referenceβ
At any point, compare what you've built with the reference:
# Compare your current work with the reference
git diff tutorial/main
# Compare specific files
git diff tutorial/main -- package.json
If you get stuckβ
Reset your code to match the reference:
# Reset to reference (WARNING: loses your changes)
git reset --hard tutorial/main
Overviewβ
This tutorial guides you through creating a ChatRoom application using Powerhouse.
A Powerhouse project primarily consists of a document model and its editor. The ChatRoom demonstrates real-time collaboration features where users can post messages and react with emojis.
Prerequisitesβ
- Powerhouse CLI installed:
pnpm install -g ph-cmdornpm install -g ph-cmd - Node.js 22 and a package manager (pnpm or npm) installed
- Visual Studio Code (or your preferred IDE)
- Terminal/Command Prompt access
If you need help with installing the prerequisites you can visit our page prerequisites
Before you beginβ
-
Open your terminal (either your system terminal or IDE's integrated terminal)
-
Optionally, create a folder first to keep your Powerhouse projects:
mkdir ph-projects
cd ph-projects -
Ensure you're in the correct directory before running the
ph initcommand.
In the terminal, you will be asked to enter the project name. Fill in the project name and press Enter.you@yourmachine:~/ph-projects % ph init
? What is the project name? β£ ChatRoom
Once the project is created, you will see the following output:
Initialized empty Git repository in /Users/you/ph-projects/ChatRoom/.git/
The installation is done!
Navigate to the newly created project directory:
cd ChatRoom
Develop your document model in Vetra Studioβ
Vetra Studio is the builder's orchestration hub for assembling all specifications needed for your package. It provides a Vetra Studio Drive to access, manage, and share document model specifications, editors, and data integrationsβall through a visual interface. For deeper coverage, see the Vetra Studio documentation.
Once in the project directory, run the ph vetra --watch command to start a Vetra Studio Drive where you'll be defining your specifications.
ph vetra --watch
The host application for Vetra Studio will start and you will see the following output:
βΉ [reactor-api] [package-manager] Loading packages: @powerhousedao/vetra
βΉ [reactor-api] [server] WebSocket server available at /graphql/subscriptions
βΉ [reactor-api] [graphql-manager] Registered /graphql/system subgraph.
βΉ [reactor-api] [graphql-manager] Registered /graphql supergraph
βΉ [reactor-api] [server] MCP server available at http://localhost:4001/mcp
Switchboard initialized
β Drive URL: http://localhost:4001/d/vetra-bac239dd
β Local: http://localhost:3000/
β Network: use --host to expose
β press h + enter to show help
A new browser window will open when visiting localhost and you will see the Vetra Studio Drive. If it doesn't open automatically, you can open it manually by navigating to http://localhost:3000/ in your browser.
Create a new document model by clicking the Document Models 'Add new specification' button. Name your document ChatRoom (PascalCase, no spaces or hyphens).
Pay close attention to capitalization, as it influences code generation.
If you've followed the steps correctly, you'll have an empty ChatRoom document where you can define the 'Document Specifications'.
Alternatively: Develop a single document model in Connect
Once in the project directory, run the ph connect command to start a local instance of the Connect application. This allows you to start your document model specification document.
ph connect
The Connect application will start and you will see the following output:
β Local: http://localhost:3000/
β Network: http://192.168.5.110:3000/
β press h + enter to show help
A new browser window will open and you will see the Connect application. If it doesn't open automatically, you can open it manually by navigating to http://localhost:3000/ in your browser.
If your local drive is not present, navigate to Settings in the bottom left corner. Settings > Danger Zone > Clear Storage. Clear the storage of your localhost application as it might have an old session cached.
Move into your local drive.
Create a new document model by clicking the DocumentModel button, found in the 'New Document' section at the bottom of the page. Name your document ChatRoom (PascalCase, no spaces or hyphens).
Verify your setupβ
At this point, your project structure should include:
- Empty
document-models/,editors/,processors/, andsubgraphs/directories - Configuration files:
powerhouse.config.json,powerhouse.manifest.json - Package management files:
package.json,pnpm-lock.yaml - Build configuration:
tsconfig.json,vite.config.ts,vitest.config.ts
Up nextβ
In the next tutorial, you will learn how to design your document model and export it to be later used in your Powerhouse project.