Skip to main content
logo_image

Tether

A high-performance Rust CLI built to automate entity scaffolding and boilerplate management for the TesseracTS framework.

#Rust, #TypeScript, #Drizzle ORM, #CLI, #Boilerplate, #Automation
Tether
Developer Tooling
May 2024

Goal

Eliminate repetitive boilerplate creation in the TesseracTS framework by building a blazingly fast Rust CLI for entity scaffolding.

My Role

Lead Developer

Timeline & Tools

May 2024 – Present

Rust, Clap, Tera, TypeScript, Drizzle ORM

01. Overview

Tether is the backbone of the TesseracTS framework's developer experience. It’s a CLI tool written in Rust designed to handle the "boring stuff"—creating router configs, services, controllers, repositories, and validations every time a new entity is needed.

Instead of manual copy-pasting, Tether uses a blueprint-driven approach to generate production-ready code in milliseconds.

Core Capabilities

  • Blueprint Initialization: Generate standardized JSON schemas for new entities.
  • Template Generation: Scaffold complex TypeScript structures using embedded Tera templates.
  • Smart Cloning: Duplicate existing modules with automatic case-aware string transformations.
  • Embedded Assets: The entire template engine and assets are compiled directly into a single portable binary.

02. The Problem

In modern full-stack development, especially with layered architectures, adding a single feature like "Blog Posts" often requires creating 6-8 different files:

  • post.schema.ts (Drizzle/DB)
  • post.types.ts (TypeScript interfaces)
  • post.validation.ts (Zod/Joi schemas)
  • post.service.ts (Business logic)
  • post.controller.ts (Request handling)
  • post.router.ts (API routes)

Doing this manually is not just slow—it's an invitation for "find and replace" errors. One missed Character to Post rename in a repository can break the entire service.


03. The Architecture

Tether is built for speed and portability using the Rust ecosystem.

The CLI Interface (Clap)
Uses clap for a robust, type-safe command-line interface with subcommands for init, generate, and clone.

Template Engine (Tera)
Utilizes the tera engine (inspired by Jinja2) for flexible code generation. Templates are logic-aware, allowing for conditional field rendering based on the entity schema.

Binary Embedding (Rust-Embed)
To ensure the tool is truly portable, all boilerplate templates are embedded into the Rust binary at compile time. This means the CLI doesn't depend on external template folders to function.


04. Blueprint-Driven Development

Tether introduces a "Blueprint First" workflow. You start by initializing a schema:

tether init character

This generates a character.tether-schema.json file where you define fields, types, and features (like soft deletes or timestamps). Once defined, a single command generates the entire entity stack:

tether generate character.tether-schema.json --flavor drizzle

05. Intelligent Cloning

The clone command is Tether's secret weapon for rapid iteration. Often, a new entity is 80% similar to an existing one.

tether clone src/entities/character src/entities/location

Tether doesn't just copy the directory. It performs Case-Aware Transformation:

  • Character (Pascal) → Location
  • character (Kebab/Lower) → location
  • CHARACTER (Macro/Snake) → LOCATION
  • characterName (Camel) → locationName

It applies these changes to both the filenames and the content of every file within the directory, ensuring a perfectly renamed module in seconds.


06. Technical Highlights

Tera Template Example

Tether uses sophisticated templates to handle field mapping:

// {{ctx.kebab}}.schema.ts.tera
export const {{ctx.camel}}Table = pgTable("{{ctx.snake}}", {
  id: uuid("id").primaryKey().defaultRandom(),
  {% for field in fields %}
  {{field.name}}: {{field.type}}("{{field.name}}"),
  {% endfor %}
  ...timestamps
});

High-Performance Transformations

The cloning engine uses the heck crate to ensure that string transformations are consistent with standard naming conventions across the TesseracTS ecosystem.


07. Results & Reflection

Tether has reduced the time to spin up a new REST entity from ~15 minutes of manual work to under 5 seconds.

Main lessons:

  • Rust for CLI is unmatched: The startup time and type safety make it the perfect choice for developer tools.
  • Embedding is essential: Removing the need for a templates/ folder makes the tool much easier to distribute.
  • Cloning > Scaffolding: While blueprints are great for complex new items, the clone command is what I use most frequently for rapid prototyping.

08. Tech Stack

Language: Rust
Crates: Clap (CLI), Tera (Templates), Rust-Embed (Assets), Heck (Casing), Serde (JSON)
Target Framework: TesseracTS (TypeScript, Drizzle ORM, Express)