DEV Community

Cover image for Stop writing boilerplate: A Single Source of Truth for Rust, Go, Python and TS
hlop3z
hlop3z

Posted on

Stop writing boilerplate: A Single Source of Truth for Rust, Go, Python and TS

One Schema to Rule Them All

Keeping database schemas in sync across Rust, Go, Python, and TypeScript is painful: you update a table, then update structs, then interfaces… and pray you didn't make a typo.

I built AstrolaDB, a standalone CLI in Go, to solve this. Define your schema once in JavaScript, then generate SQL migrations and type-safe code for multiple languages. Without Node.js, Python or JVM.

GitHub: github.com/hlop3z/astroladb
Docs: hlop3z.github.io/astroladb


Why Multi-Language Schemas Hurt

Typical workflow across multiple services:

  1. Update a table in Postgres
  2. Update structs in Rust, Go, or Python
  3. Update interfaces in TypeScript
  4. Pray nothing breaks

Schemas inevitably drift apart. I wanted a single source of truth without locking into an ORM or heavy runtime.


One Schema, Many Languages

AstrolaDB (alab) is a schema-as-code orchestration tool:

  • ⚡ Write your schema once in JavaScript
  • 🚀 Generate SQL migrations, native types, and OpenAPI specs
  • 🧩 Logical namespacing for tables like auth.user or billing.invoice
  • 🏋️ Runs as a single ~8MB binary, locally or in CI

Supports Rust, Go, Python, TypeScript, and more.


How It's Different

  • Zero Dependencies: Single binary, no Node.js, Python, or JVM
  • Embedded JS Engine: Uses Goja for fast, portable JS execution
  • Developer-Friendly: Live preview, quick generation and type-safe code

Quick Start

Download Release

# Initialize demo project
alab init --demo

# Preview schema in browser
alab live

# Generate code
alab export -f all
Enter fullscreen mode Exit fullscreen mode

Example: Auth User Table

Write your schema once and generate outputs for multiple languages.

Schema

// schemas/auth/user.js
export default table({
  id: col.id(),
  username: col.string(50).unique(),
  age: col.integer().optional(),
});
Enter fullscreen mode Exit fullscreen mode

Generated Rust

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AuthUser {
    pub id: String,
    pub username: String,
    pub age: Option<i32>,
}
Enter fullscreen mode Exit fullscreen mode

Generated Go

type AuthUser struct {
    Id       string  `json:"id"`
    Username string  `json:"username"`
    Age      *int32  `json:"age,omitempty"`
}
Enter fullscreen mode Exit fullscreen mode

Full examples for Python and TypeScript are in the Code Generation.


Built with DX in Mind

Developer experience


How It Works

Flowchart mermaid


Try It Today

Define your schema once, generate type-safe code in minutes, and stop worrying about typos across languages.

Share your thoughts in the comments or open an issue on GitHub. I built AstrolaDB to solve my own polyglot headaches, now I want to make it useful for you.

GitHub logo hlop3z / astroladb

Define once in JavaScript, export strongly typed models to Rust, Go, Python, TypeScript and more.

astrola-db

AstrolaDB (alab)

CI Go Report Card Release Experimental

One schema: many languages.

Documentation | Comparison | Generated-Code | Commands | Fields

Flowchart


Welcome to AstrolaDB aka alab. A schema-as-code orchestration tool with a one-to-many multi-language code generation.

No Node.js dependency. No runtime lock-in.

Define your schema once in JavaScript, then generate SQL migrations, Rust structs, Go models, Python classes, TypeScript types, GraphQL schemas, and OpenAPI specs.

Schemas are written in constrained JavaScript not for logic, but for type safety, autocomplete, IDE support and explicit configuration. Think of it as a fancy JSON.


Key Highlights

  • Lightweight & Portable
  • Zero-dependency, single binary (~8 MB)
  • Fast, portable and CI/CD-friendly
  • No heavy runtimes: JVM | Node.js | Python

Download Release

Windows Mac (Intel) Mac (Apple Silicon) Linux (amd64) Linux (arm64)


Install

curl -fsSL https://raw.githubusercontent.com/hlop3z/astroladb/main/install.sh | sh
Enter fullscreen mode Exit fullscreen mode

Quick Start

Initialize project

alab init
Enter fullscreen mode Exit fullscreen mode

Create a table schema

alab table auth user
Enter fullscreen mode Exit fullscreen mode

Edit your schema

// schemas/auth/user.js
export default table({
  id
Enter fullscreen mode Exit fullscreen mode

Top comments (0)