Migrating Services to Riven

Step-by-step guide for onboarding an existing service or building a new one on the Riven AI platform.

Overview

This guide walks through the full process of bringing a service onto the Riven AI platform — from installing the CLI to a production deployment. Whether you are migrating an existing service or building a new one, the steps are the same.

This guide assumes you have an AWS account with access to the Riven ECR registry and EKS cluster. Contact a platform admin if you need access.

Migration Steps

1

Install the CLI

Install the Riven CLI, which handles proto codegen, service scaffolding, Docker publishing, and deployments:

Terminal
bash
curl -fsSL https://docs.riven-ai.dev/api/install | bash

Verify the installation:

Terminal
bash
riven --cli-version
2

Authenticate

Log in to the platform to get an auth token:

Terminal
bash
riven auth login

This opens a browser window for authentication. Your token is stored in ~/.config/riven/credentials.json.

3

Initialize your workspace

Set up the workspace configuration with your organization and proto registry:

Terminal
bash
riven init --registry-url https://proto.riven-ai.dev --org-id <your-org-id>

This creates a .rivenrc.json file in your project root with registry URL, org ID, and default settings.

4

Define your Proto API

Create your service's API contract using Protocol Buffers. This is the source of truth for all service communication.

Create a proto/ directory and define your service:

proto/riven/myservice/v1/my_service.proto
protobuf
syntax = "proto3";
 
package riven.myservice.v1;
 
service MyService {
  rpc GetItem(GetItemRequest) returns (GetItemResponse) {}
  rpc ListItems(ListItemsRequest) returns (ListItemsResponse) {}
  rpc CreateItem(CreateItemRequest) returns (CreateItemResponse) {}
}
 
message GetItemRequest {
  string id = 1;
}
 
message GetItemResponse {
  Item item = 1;
}
 
message Item {
  string id = 1;
  string name = 2;
  string description = 3;
}
 
// ... remaining message types

Follow the package naming convention: riven.<domain>.v1. Use snake_case for fields and PascalCase for messages and services.

Lint your proto files to catch issues early:

Terminal
bash
riven proto lint
5

Generate code

Run codegen to produce TypeScript (or Python) client and server stubs from your proto definitions:

Terminal
bash
riven proto generate

Generated code is placed in src/__generated__/ and should be committed to your repository. It is excluded from linting and test coverage.

6

Scaffold the service

Use the CLI to generate the service boilerplate, including Connect RPC server setup, health checks, and Prisma schema:

Terminal
bash
riven service create my-service --lang node

This generates:

  • src/index.ts — Service entry point with Connect RPC server
  • src/service.ts — Service implementation skeleton
  • prisma/schema.prisma — Database schema (PostgreSQL)
  • Dockerfile — Multi-stage production build
  • package.json — Dependencies and scripts

For Python services:

Terminal
bash
riven service create my-service --lang python
7

Implement business logic

Fill in the service implementation. The scaffolded code provides the RPC handlers as empty methods — implement each one:

src/service.ts
typescript
import type { MyService } from './__generated__/riven/myservice/v1/my_service_connect';
 
export const myServiceImpl: MyService = {
  async getItem(request) {
    const item = await prisma.item.findUnique({
      where: { id: request.id },
    });
    if (!item) {
      throw new ConnectError('Item not found', Code.NotFound);
    }
    return { item };
  },
 
  async listItems(request) {
    const items = await prisma.item.findMany();
    return { items };
  },
 
  async createItem(request) {
    const item = await prisma.item.create({
      data: { name: request.name, description: request.description },
    });
    return { item };
  },
};

Write tests alongside your implementation:

Terminal
bash
yarn test
8

Build the Docker image

The scaffolded Dockerfile uses a multi-stage build. Build and tag following the required format:

Terminal
bash
# Get the version and short SHA
VERSION=$(node -p "require('./package.json').version")
SHA=$(git rev-parse --short HEAD)
TAG="${VERSION}-${SHA}"
 
# Build the image
docker build -t my-service:${TAG} .

Or use the CLI to build and push in one step (next step).

9

Publish the image

Push the image to the ECR registry:

Terminal
bash
riven publish

This command:

  1. Reads the version from package.json
  2. Appends the short git SHA
  3. Builds the Docker image
  4. Pushes to the configured ECR repository

Ensure you are authenticated with ECR before publishing. Run aws ecr get-login-password if your session has expired.

10

Deploy to the platform

Deploy your service to the Riven platform:

Terminal
bash
riven dev-center service deploy my-service \
  --tag ${TAG} \
  --repo-type js \
  --image-repository <account-id>.dkr.ecr.us-east-1.amazonaws.com/my-service

For subsequent deployments of an already-registered service:

Terminal
bash
riven dev-center rollout start my-service ${TAG}
11

Verify the deployment

Check that your service is running and healthy:

Terminal
bash
# Check rollout status
riven dev-center rollout status my-service
 
# View pod logs
riven dev-center logs my-service
 
# Run diagnostics
riven doctor

Your service is now live on the platform and accessible via Connect RPC through the platform gateway.

Post-Migration Checklist

After your service is deployed, complete these additional steps:

  • Register proto package — Publish your proto to the registry: riven proto publish
  • Add to service catalog — Register your service in the Dev Center dashboard
  • Configure secrets — Add environment variables and secrets via the platform UI
  • Set up monitoring — Verify Prometheus metrics and Grafana dashboards are collecting data
  • Write documentation — Create a Service Overview page in Internal Docs using the template
  • Configure alerts — Set up alerting rules for error rates, latency, and availability

Next Steps