Skip to content

Introduction

Write once. Deploy Everywhere.

LUMOS is a type-safe schema language designed specifically for Solana development. It bridges the gap between Rust (on-chain programs) and TypeScript (frontend applications) by providing a single source of truth for your data structures.

In one sentence: Write your data structures once in LUMOS, and automatically generate perfectly synchronized Rust and TypeScript code with guaranteed Borsh serialization compatibility.


Building full-stack Solana applications is challenging because you need to maintain identical type definitions in two different languages:

// programs/src/state.rs (Rust)
#[derive(BorshSerialize, BorshDeserialize)]
pub struct GameState {
pub player: Pubkey,
pub score: u64,
pub level: u16,
}
// app/src/types.ts (TypeScript)
interface GameState {
player: PublicKey;
score: number;
level: number;
}
// And you need to write Borsh schema manually...
const GameStateBorshSchema = borsh.struct([
borsh.publicKey('player'),
borsh.u64('score'),
borsh.u16('level'),
]);

Problems:

  • πŸ”΄ Manual synchronization required (error-prone)
  • πŸ”΄ Type mismatches cause runtime failures
  • πŸ”΄ Refactoring breaks in multiple places
  • πŸ”΄ No single source of truth
  • πŸ”΄ Borsh schema written manually (field order must match exactly)

#[solana]
struct GameState {
player: PublicKey,
score: u64,
level: u16,
}

Run lumos generate schema.lumos and get:

  • βœ… Perfect Rust code with correct derives
  • βœ… Perfect TypeScript code with interfaces + Borsh schemas
  • βœ… Types always in sync (impossible to drift)
  • βœ… Borsh schema auto-generated (field order guaranteed)
  • βœ… Refactor once (changes propagate everywhere)

LUMOS uses a compiler-based approach similar to Protocol Buffers or GraphQL Code Generator:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 1. Write Schema (.lumos file) β”‚
β”‚ ↓ β”‚
β”‚ 2. Parser β†’ AST (Abstract Syntax Tree) β”‚
β”‚ ↓ β”‚
β”‚ 3. Transform β†’ IR (Intermediate Rep) β”‚
β”‚ ↓ β”‚
β”‚ 4. Generate β†’ Rust + TypeScript β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Innovation: Language-agnostic IR (Intermediate Representation) makes it easy to add support for new languages in the future (Python, C++, Go, etc.)


Define data structures once. Generate code for multiple languages.

Complete bidirectional type mapping ensures Rust and TypeScript types are always compatible. Runtime deserialization errors are impossible.

First-class support for Anchor programs. LUMOS understands #[account] attributes and generates code without derive conflicts.

Automatic Borsh schema generation for both languages. Field order, type sizes, and serialization format guaranteed to match.

Intelligent analysis determines optimal imports, derives, and patterns:

  • Anchor accounts β†’ anchor_lang::prelude::*
  • Pure Borsh β†’ borsh::{BorshSerialize, BorshDeserialize}
  • Mixed modules β†’ Smart import resolution

IR-based design makes adding new target languages straightforward.

  • 64/64 tests passing (100% success rate)
  • E2E tests with actual Rust compilation
  • Battle-tested on real-world examples
  • Published on crates.io

LUMOS is perfect for:

βœ… Solana developers building full-stack applications βœ… Teams maintaining Rust + TypeScript codebases βœ… Projects using Anchor framework βœ… Anyone tired of manual type synchronization βœ… Developers who value type safety and code generation

Not a fit for:

❌ Simple projects with only Rust or only TypeScript (no cross-language need) ❌ Projects not using Borsh serialization ❌ Non-Solana blockchain projects (though it could be adapted)


Status Quo: Write types in both languages manually.

  • ❌ Error-prone
  • ❌ Time-consuming
  • ❌ Hard to maintain
  • βœ… Full control

Common approach: Copy Rust struct to TypeScript and convert.

  • ❌ Gets out of sync quickly
  • ❌ Borsh schema still manual
  • ❌ Refactoring nightmare
  • βœ… Fast initially

Best approach: Write once, generate everywhere.

  • βœ… Always in sync
  • βœ… Borsh auto-generated
  • βœ… Refactor with confidence
  • βœ… Production-ready code
  • ⚠️ Learning curve (minimal)

Developer adds field to Rust struct
β†’ Forgets to update TypeScript
β†’ Deploys contract
β†’ Frontend breaks in production
β†’ 2 hours debugging
β†’ Rollback or hotfix
Developer adds field to .lumos schema
β†’ Runs lumos generate
β†’ TypeScript compiler errors immediately
β†’ Fix frontend before deploy
β†’ 5 minutes total
β†’ Ship with confidence

Built on syn (Rust’s official parsing library), ensuring robust and correct parsing.

Language-agnostic representation enables:

  • Easy addition of new target languages
  • Consistent transformations
  • Better testing

Specialized code generators for:

  • Rust: Context-aware imports, derive selection, Anchor integration
  • TypeScript: Interface generation, Borsh schemas, type mapping

Ready to get started?

  1. Install LUMOS β†’ - Get the CLI in 2 minutes
  2. Quick Start β†’ - Create your first schema
  3. Examples β†’ - See real-world use cases

Or dive deeper:



Built with ❀️ for the Solana community by RECTOR