Skip to content

Latest commit

 

History

History
210 lines (158 loc) · 4.87 KB

File metadata and controls

210 lines (158 loc) · 4.87 KB
title Development
description Guide to developing with Routstr

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:

```bash docker run -d -p 7000:7000 scsibug/nostr-rs-relay ``` ```bash docker run -d -p 3338:3338 cashubtc/cashu-fedibtc ``` Create a config with the local relay and mint:
```json
{
  "proxy": {
    "name": "Local Provider",
    "endpoint": "http://localhost:11434/v1"
  },
  "routing": {
    "nostr": {
      "relays": ["ws://localhost:7000"]
    }
  },
  "payment": {
    "cashu": {
      "enabled": true,
      "mint": "http://localhost:3338"
    }
  }
}
```
```bash 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

If the proxy cannot connect to providers:
1. Check that your Nostr relays are accessible
2. Verify that your proxy is properly announced to the network
3. Ensure your local network allows the connections
If your provider isn't receiving requests:
1. Verify it's properly announced to the network
2. Check that your API endpoint is accessible
3. Look at the proxy logs for errors
For payment issues:
1. Test your Lightning or Cashu setup independently
2. Verify the payment flow using the debugging tools
3. Check logs for payment-related errors

Additional Resources