Multi-purpose WebAssembly monorepo powering secure cryptographic operations and decentralized identity for the Sonr ecosystem.
Motr is a comprehensive WebAssembly-based monorepo that provides secure cryptographic operations, decentralized identity management, and a suite of web applications for the Sonr ecosystem. The architecture leverages Cloudflare Workers for edge computing and Go-compiled WASM for cryptographic operations.
- π Hono-based Worker - Edge-deployed orchestrator serving multiple frontends with SSR
- π Cryptographic Vault - WASM-based secure key management with MPC and threshold cryptography
- π DID Management - Decentralized identity with WebAuthn integration via Enclave
- β‘ Vite Frontends - Modern React apps for auth, console, profile, and search
- π¦ Shared Packages - Reusable TypeScript libraries and UI components
motr/
βββ apps/ # Vite-based frontend applications
β βββ auth/ # Authentication & registration app
β βββ console/ # Developer console & admin interface
β βββ profile/ # User profile management
β βββ search/ # Sonr network search
β
βββ libs/ # Go/WASM cryptographic libraries
β βββ enclave/ # DID & WebAuthn Durable Object worker
β βββ vault/ # Cryptographic vault operations
β
βββ pkgs/ # TypeScript packages
β βββ config/ # Shared build & lint configs
β βββ react/ # React hooks & providers
β βββ sdk/ # Core TypeScript SDK
β βββ ui/ # Shared UI components (shadcn)
β
βββ src/ # Cloudflare Worker (Hono-based)
β βββ worker.ts # Main orchestrator serving all frontends
β
βββ docs/ # Documentation & MDX content
βββ wrangler.toml # Worker deployment configuration
βββ tsconfig.json # Worker TypeScript config
βββ package.json # Root workspace configuration
βββ turbo.json # Turborepo build pipeline
- Bun 1.3+ (install)
- Go 1.24.4+ (install)
- TinyGo 0.39+ (install)
- Wrangler CLI (included in dependencies)
# Clone the repository
git clone https://github.com/sonr-io/motr.git
cd motr
# Install all dependencies (uses Bun workspaces)
bun install
# Build all packages and libraries
turbo build# Start main worker (serves all frontends via Hono)
bun run dev
# Start specific frontend app
bun run dev:auth # Authentication app
bun run dev:console # Console app
bun run dev:profile # Profile app
bun run dev:search # Search app
# Start enclave worker (Durable Object)
cd libs/enclave && wrangler dev
# Start vault worker
cd libs/vault && wrangler dev
# Run tests
turbo test # All tests
bun run test:all # All package tests
# Linting and formatting
turbo lint # Lint all packages
turbo format # Format all packages
turbo check # Type check all packagesThe main orchestrator at src/worker.ts using Hono framework:
Features:
- π― Smart routing based on subdomain, path, and session state
- π¦ Static asset serving for all Vite-built frontends
- π Session management with KV storage
- π Service bindings to Enclave and Vault workers
- π Built-in middleware (logger, etag, CORS)
Routing Strategy:
// Subdomain routing
console.sonr.id/* β Console app
profile.sonr.id/* β Profile app
search.sonr.id/* β Search app
// Path-based routing
/console/* β Console app
/profile/* β Profile app
/search/* β Search app
// Session-based (authenticated users)
/ β Default app from user preferences
// Default (unauthenticated)
/ β Auth appDevelopment:
bun run dev # Start worker at http://localhost:5165
bun run preview # Test with remote bindings
bun run logs # Tail production logsModern React apps built with Vite and TanStack:
- User registration and authentication
- WebAuthn credential management
- OAuth/OIDC flows
- OTP verification
- Developer dashboard
- API key management
- Service configuration
- Analytics and monitoring
- User profile management
- DID document viewer
- Credential management
- Settings and preferences
- Sonr network search
- User discovery
- Service discovery
- Explorer interface
Tech Stack:
- React 19
- TanStack Router, Query, Form
- Vite 5
- Tailwind CSS 4
- TypeScript 5.9+
Development:
cd apps/auth
bun run dev # Start dev server on port 3000
bun run build # Build for production
bun run preview # Preview production buildDurable Object worker for decentralized identity:
Features:
- DID document management (did:snr method)
- WebAuthn credential storage and verification
- Cryptographic key operations
- Identity recovery flows
Technology:
- Go β WASM via TinyGo
- Cloudflare Durable Objects
- Persistent state storage
Build:
cd libs/enclave
bun run build # Compile Go to WASM
wrangler deploy # Deploy Durable ObjectService worker for cryptographic operations:
Features:
- Multi-party computation (MPC)
- Threshold signature schemes
- Multi-chain transaction signing
- Secure key derivation
- IPFS import/export
Supported Chains:
- Cosmos SDK chains
- Ethereum/EVM chains
- Solana
- Bitcoin
Technology:
- Go β WASM via TinyGo
- Service Worker runtime
- Extism plugin system
Build:
cd libs/vault
bun run build # Compile Go to WASMCore TypeScript SDK for Sonr integration:
import { SonrClient, createVault } from '@sonr.io/sdk';
// Initialize client
const client = new SonrClient({
rpcUrl: 'https://rpc.sonr.id',
restUrl: 'https://api.sonr.id',
});
// Create vault
const vault = await createVault({
name: 'my-vault',
password: 'secure-password',
});
// Sign transaction
const signature = await vault.sign({
chain: 'cosmos',
transaction: tx,
});Features:
- Chain-agnostic transaction signing
- DID management utilities
- WebAuthn helpers
- IPFS integration
Shared UI component library built on shadcn/ui:
import { Button, Card, Input } from '@sonr.io/ui';
export function MyComponent() {
return (
<Card>
<Input placeholder="Enter value" />
<Button>Submit</Button>
</Card>
);
}Features:
- 50+ accessible components
- Tailwind CSS styling
- Dark mode support
- TypeScript strict mode
React-specific hooks and providers:
import { useSonr, SonrProvider } from '@sonr.io/react';
function App() {
return (
<SonrProvider config={config}>
<MyApp />
</SonrProvider>
);
}
function MyApp() {
const { account, connect, disconnect } = useSonr();
// ...
}Shared build configurations:
// vite.config.ts
import { createReactAppConfig } from '@sonr.io/config/vite/react-app';
export default createReactAppConfig();// tsconfig.json
{
"extends": "../../pkgs/config/typescript/react-app.json"
}turbo build # Build all packages (respects dependencies)
turbo test # Run all tests in parallel
turbo lint # Lint all packages
turbo dev # Start all dev serversBuild Order:
@sonr.io/sdk- Core SDK (no dependencies)@sonr.io/ui- UI components (depends on sdk)@sonr.io/react- React hooks (depends on ui)libs/vault&libs/enclave- WASM builds (parallel)- Frontend apps - Vite builds (depends on react)
- Worker - TypeScript compilation (depends on all apps)
# Development
bun run dev # Start main worker
bun run dev:worker # Start main worker (alias)
bun run dev:auth # Start auth app
bun run dev:console # Start console app
bun run dev:profile # Start profile app
bun run dev:search # Start search app
bun run dev:all # Start all in parallel
# Building
bun run build # Build all packages
bun run build:apps # Build only frontend apps
bun run build:libs # Build only WASM libraries
bun run build:pkgs # Build only TS packages
bun run build:force # Force rebuild ignoring cache
# Testing
bun run test # Run all tests
bun run test:all # Run tests in all packages
bun run test:watch # Run tests in watch mode
# Quality
bun run lint # Lint all packages
bun run lint:fix # Lint and auto-fix
bun run format # Format all files
bun run check # Run type checks
bun run typecheck # Run type checks (alias)
# Deployment
bun run deploy # Deploy main worker
bun run deploy:staging # Deploy to staging
bun run deploy:production # Deploy to production
bun run preview # Test with remote bindings
bun run logs # Tail production logs
# Maintenance
bun run clean # Clean build artifacts
bun run clean:cache # Clean turbo cache
bun run clean:turbo # Clean turbo daemonAll frontend apps are served by a single Cloudflare Worker:
# Deploy to production
bun run deploy
# Deploy to staging
bun run deploy:staging
# Test before deploying
bun run previewDeployment Process:
- Build all frontend apps (
turbo build) - Compile worker TypeScript
- Wrangler bundles static assets
- Deploy to Cloudflare edge network
# wrangler.toml
name = "motr-orchestrator"
main = "src/worker.ts"
compatibility_date = "2025-01-11"
[env.production]
routes = [
{ pattern = "sonr.id/*", custom_domain = true },
{ pattern = "*.sonr.id/*", custom_domain = true }
]
[env.staging]
name = "motr-orchestrator-staging"
workers_dev = trueEnclave and Vault workers are deployed separately:
# Deploy enclave (Durable Object)
cd libs/enclave && wrangler deploy
# Deploy vault
cd libs/vault && wrangler deploy# All tests
turbo test
# Specific package
bun --filter '@sonr.io/sdk' test
# Watch mode
turbo test -- --watch
# Coverage
turbo test -- --coverage# End-to-end tests
bun run test:e2e
# Worker tests
wrangler dev --test- WORKER_ARCHITECTURE.md - Worker design and routing
- WORKER_README.md - Worker development guide
- API Documentation - API reference
- Migration Guide - Architecture evolution
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting (
turbo check && turbo test) - Commit your changes (conventional commits preferred)
- Push to your branch
- Open a Pull Request
- TypeScript: Oxlint + Biome formatting
- Go:
gofmt+golangci-lint - Commits: Conventional commits (
feat:,fix:,docs:, etc.)
DO NOT open public issues for security vulnerabilities.
Email: [email protected]
- All cryptographic operations run in sandboxed WASM
- Keys never leave the secure enclave
- Multi-party computation for threshold operations
- Zero-knowledge proofs for privacy-preserving operations
- WebAuthn integration for passwordless authentication
- Edge Computing: Cloudflare Workers in 300+ cities worldwide
- Cold Start: < 5ms worker execution time
- Build Size: Optimized WASM bundles (< 500KB)
- Caching: Aggressive caching for static assets
- Code Splitting: Route-based splitting for frontends
MIT License - see LICENSE for details
- Website: sonr.io
- Documentation: docs.sonr.io
- GitHub: github.com/sonr-io/motr
- Discord: discord.gg/sonr
- Twitter: @sonr_io
Built with outstanding open-source technologies:
- Hono - Ultrafast web framework
- TinyGo - Go compiler for WebAssembly
- Extism - Universal plugin system
- TanStack - Modern React utilities
- Cloudflare Workers - Edge computing platform
- Vite - Next generation frontend tooling
- Bun - Fast all-in-one JavaScript runtime
- shadcn/ui - Accessible component library
Made with β€οΈ by the Sonr Team