Introduction
Write once. Deploy Everywhere.
What is LUMOS?
Section titled βWhat is LUMOS?β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.
The Problem
Section titled βThe ProblemβBuilding full-stack Solana applications is challenging because you need to maintain identical type definitions in two different languages:
Without LUMOS
Section titled βWithout LUMOSβ// 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)
The Solution
Section titled βThe SolutionβWith LUMOS
Section titled βWith LUMOSβ#[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)
How It Works
Section titled βHow It Worksβ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.)
Key Features
Section titled βKey Featuresβπ― Single Source of Truth
Section titled βπ― Single Source of TruthβDefine data structures once. Generate code for multiple languages.
π 100% Type Safety
Section titled βπ 100% Type SafetyβComplete bidirectional type mapping ensures Rust and TypeScript types are always compatible. Runtime deserialization errors are impossible.
β Anchor Framework Integration
Section titled ββ Anchor Framework IntegrationβFirst-class support for Anchor programs. LUMOS understands #[account] attributes and generates code without derive conflicts.
π¦ Borsh Serialization
Section titled βπ¦ Borsh SerializationβAutomatic Borsh schema generation for both languages. Field order, type sizes, and serialization format guaranteed to match.
π§ Context-Aware Generation
Section titled βπ§ Context-Aware GenerationβIntelligent analysis determines optimal imports, derives, and patterns:
- Anchor accounts β
anchor_lang::prelude::* - Pure Borsh β
borsh::{BorshSerialize, BorshDeserialize} - Mixed modules β Smart import resolution
π§© Extensible Architecture
Section titled βπ§© Extensible ArchitectureβIR-based design makes adding new target languages straightforward.
β Production Ready
Section titled ββ Production Readyβ- 64/64 tests passing (100% success rate)
- E2E tests with actual Rust compilation
- Battle-tested on real-world examples
- Published on crates.io
Who Should Use LUMOS?
Section titled βWho Should Use LUMOS?β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)
Comparison with Alternatives
Section titled βComparison with AlternativesβManual Synchronization
Section titled βManual SynchronizationβStatus Quo: Write types in both languages manually.
- β Error-prone
- β Time-consuming
- β Hard to maintain
- β Full control
Copy-Paste
Section titled βCopy-Pasteβ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)
Real-World Impact
Section titled βReal-World ImpactβBefore LUMOS
Section titled βBefore LUMOSβDeveloper adds field to Rust structβ Forgets to update TypeScriptβ Deploys contractβ Frontend breaks in productionβ 2 hours debuggingβ Rollback or hotfixAfter LUMOS
Section titled βAfter LUMOSβDeveloper adds field to .lumos schemaβ Runs lumos generateβ TypeScript compiler errors immediatelyβ Fix frontend before deployβ 5 minutes totalβ Ship with confidenceArchitecture Highlights
Section titled βArchitecture HighlightsβBuilt on syn (Rustβs official parsing library), ensuring robust and correct parsing.
IR (Intermediate Representation)
Section titled βIR (Intermediate Representation)βLanguage-agnostic representation enables:
- Easy addition of new target languages
- Consistent transformations
- Better testing
Generators
Section titled βGeneratorsβSpecialized code generators for:
- Rust: Context-aware imports, derive selection, Anchor integration
- TypeScript: Interface generation, Borsh schemas, type mapping
Whatβs Next?
Section titled βWhatβs Next?βReady to get started?
- Install LUMOS β - Get the CLI in 2 minutes
- Quick Start β - Create your first schema
- Examples β - See real-world use cases
Or dive deeper:
- Type Mapping β - Learn all supported types
- Anchor Integration β - Anchor-specific features
- Enum Support β - Use Rust-style enums
Community & Support
Section titled βCommunity & Supportβ- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π¦ Packages: crates.io
- β Star: GitHub Repo
Built with β€οΈ for the Solana community by RECTOR