Development Guide

This guide covers how to set up and develop with Routstr, whether you’re building an application that uses Routstr, or contributing to Routstr itself.

Repository Structure

The Routstr project consists of several key components:

/routstr
  /proxy         - Self-hosted proxy for model providers
  /frontend      - Web interface for the Routstr marketplace
  /protocol      - Core protocol specifications (RIPs)
  /docs          - Documentation site
  /scripts       - Utility scripts and development tools

Development Environment

Prerequisites

  • Node.js 19 or higher
  • Docker (for containerized development)
  • A Lightning wallet or node (for payment testing)
  • Cashu mint (optional, for token payments)

Setting Up the Proxy

# Clone the repository
git clone https://github.com/routstr/routstr.git
cd routstr/proxy

# Install dependencies
npm install

# Build the proxy
npm run build

# Run the proxy locally
npm run dev

Setting Up the Frontend

cd routstr/frontend

# Install dependencies
npm install

# Run the development server
npm run dev

Running Tests

We use Jest for JavaScript/TypeScript testing:

# Run proxy tests
cd proxy
npm test

# Run frontend tests
cd frontend
npm test

Working with the Protocol

The Routstr Improvement Proposals (RIPs) define the standards and protocols that make up the Routstr network:

  • RIP-01: OpenAI-API Proxy with Cashu micropayments
  • RIP-02: Nostr event announcements for inference nodes
  • RIP-03: Web interface for browsing and filtering nodes
  • RIP-04: Anonymous quality evaluations
  • RIP-05: Smart clients with Tor/proxy routing

When developing for Routstr, refer to these specifications to ensure compatibility.

Local Development Network

For local development, you can set up a complete Routstr network locally:

1

Start a local Nostr relay

docker run -d -p 7000:7000 scsibug/nostr-rs-relay
2

Start a local Cashu mint

docker run -d -p 3338:3338 cashubtc/cashu-fedibtc
3

Configure a local proxy

Create a config with the local relay and mint:

{
  "proxy": {
    "name": "Local Provider",
    "endpoint": "http://localhost:11434/v1"
  },
  "routing": {
    "nostr": {
      "relays": ["ws://localhost:7000"]
    }
  },
  "payment": {
    "cashu": {
      "enabled": true,
      "mint": "http://localhost:3338"
    }
  }
}
4

Run the proxy

docker run -p 8080:8080 -v $(pwd)/config.json:/app/config.json ghcr.io/routstr/proxy

Docker Deployment

For production deployment, use the official Docker image:

# Pull the latest proxy image
docker pull ghcr.io/routstr/proxy:latest

# Run the proxy with your configuration
docker run -d -p 8080:8080 -v /path/to/config.json:/app/config.json ghcr.io/routstr/proxy

Contributing to Routstr

We welcome contributions to all aspects of the Routstr ecosystem:

  1. Fork the repository you want to contribute to
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Coding Standards

  • We use TypeScript for type safety
  • Follow the existing code style and include tests
  • Documentation is required for new features

Building and Deploying

Building the Proxy

cd proxy
npm run build

The built package will be in the dist directory.

Building the Frontend

cd frontend
npm run build

The built site will be in the out directory.

Troubleshooting

Additional Resources