Web Apps Overview and Setup
These docs guide you through building and integrating with Torus web apps—from understanding our structure and stack to installing and developing.
The ecosystem is built using a monorepo with Turborepo, which allows us to share code and tools across different projects.
Prerequisites
- Node.js -
20.16.0
or higher. - PNPM -
9.7.1
or higher. - Docker - installation guide.
- Just - installation guide.
Docker Tip
If you have difficulties or want alternatives to simplify using Docker, consider:
- Colima: A lightweight solution for running containers on macOS.
- Orbstack: A fast and efficient alternative for managing containers.
Quick Start
# Clone and setupcd torus-tspnpm installcp .env.example .env
# Build and runjust buildjust dev torus-wallet # or any other app
For detailed setup instructions, see the setup guide below.
Frameworks & Libraries
We use a variety of frameworks and libraries to build our web apps. Here are some of the key ones:
- React: JavaScript library for building user interfaces
- Next.js: React framework for building static and server-rendered applications
- TypeScript: Typed superset of JavaScript that compiles to plain JavaScript
- Tailwind: Utility-first CSS framework for rapidly building custom designs
- Drizzle: Typesafe ORM for TypeScript
- tRPC: TypeScript-first RPC framework for Node.js
- TanStack Query: data-fetching library for React
- Polkadot JS API: JavaScript API for interacting with Polkadot-based chains
- Agent API: Enables decentralized collaboration among autonomous AI agents
Project Structure
Directory
.github
- workflows pnpm cache setup & ci/cd
- ISSUE_TEMPLATE Template for open source contributors
- DISCUSSION_TEMPLATE Template for open source contributors
.vscode
… Extensions and settings for VSCode users
Directory
apps
- torus-page Landing Page
- torus-portal Torus Hypergraph
- torus-governance DAO & Governance Portal
- torus-wallet Transactions & Staking
- torus-bridge Bridge between Torus and Subspace
- torus-allocator Set weights to Agents
Directory
services
- torus-cache Blockchain data caching service
- torus-worker Background services
Directory
packages
- ui UI components library
- db Typesafe DB calls using Drizzle
- dsl Constraint definitions for Torus
- api tRPC v11 router definition
- utils Common code
- torus-ts-sdk Typesafe substrate client library
- env-validation Environment variables validation
- torus-provider Polkadot JS API provider
- query-provider React Query provider
Directory
tooling
- eslint Shared, fine-grained, eslint presets
- prettier Shared prettier configuration
- tailwind Shared tailwind configuration
- typescript Shared tsconfig you can extend from
Directory
just
- justfile All the commands you need to run the project
This stack comes from create-t3-app.
This guide will walk you through the process of installing and running the torus-ts
monorepo.
Monorepo setup
-
Clone the repository
Terminal window # Recommended for contributors with SSH keys configured.Terminal window # Works without SSH key setup.git clone https://github.com/renlabs-dev/torus-ts.gitTerminal window gh repo clone renlabs-dev/torus-tsUse the GitHub CLI.
-
Install the dependencies
Terminal window pnpm install# orjust install
-
Configure environment variables
There is an
.env.example
in the root directory you can use for referenceTerminal window cp .env.example .env
-
Setup database
Create a postgres container with docker:
Terminal window docker run --name torus-db-container \-e POSTGRES_PASSWORD=password \-e POSTGRES_DB=torus-ts-db \-e POSTGRES_USER=postgres \-p 1337:1337 \-d postgres:16-alpine \postgres -p 1337Push the Drizzle schema to the database:
Terminal window just db-pushYou can also use the
just db-studio
command to open a GUI provided by Drizzle.
-
Build the project
Terminal window just build
-
Run the project
From the root directory, run the following command:
Terminal window just dev <app-name> # Run any appOr from the app directory, run the following command:
Terminal window pnpm run dev