How web3-builders-alliance/soda works
Project Type and Purpose
• Soda is both a CLI tool and a desktop app (via Tauri) backed by a Rust library (crate) and powered by a template repository.
• Purpose: read a Solana IDL, apply templates (Handlebars + Rhai), and emit client/program source code for web, mobile, or on-chain programs.
Top-Level Components from the File Structure
• assets: static visuals (logo)
• templates: multiple template sets (anchor, nextjs, react_native, seahorse, solana_flutter)
• crate: Rust library implementing the code-generation engine
• cli: Rust binary + JS glue for a terminal UI
• ui: Next.js/React frontend + Tauri (Rust) backend for the desktop GUI
Core Architecture and Flow
a. Input Sources
• Solana IDL file (idl.json)
• Template folder or packed template file (.soda)
b. Engines and Services
• Code-Generation Engine (crate):
• parse IDL
• load chosen template from templates/… via load_template.rs
• execute helpers (Rhai scripts) and render Handlebars templates
• assemble output file tree via write_project_to_fs.rs
• CLI Binary (cli/src/main.rs): invokes the crate’s public API (generate_project)
• Desktop App:
• Frontend (Next.js in ui/): user edits IDL, selects templates, previews
• Tauri Backend (ui/src-tauri): exposes Rust commands (generate, save, load) over IPC, calls into the same crate
c. Storage and I/O
• Local File System:
• Reads/writes IDL and template files
• Outputs generated project directories (programs, web client, mobile client)
• Optional: Download templates ZIP or fetch from GitHub
Relationships and Data Flow
• User (CLI or Desktop UI) → selects IDL & template
→ CLI/Tauri command → Code-Gen Engine (crate)
→ Engine loads IDL + template → renders code → writes to disk
• Template metadata (metadata.json) guides UI to display template options
• Helpers (Rhai scripts) injected by the engine at render time
Architectural Patterns and Principles
• Modular library (crate) shared by both CLI and Desktop App
• Plugin-style templates (file-based, language-agnostic)
• Clear separation of concerns:
• UI layer (React/Next.js)
• Backend commands (Tauri/Rust + CLI binary)
• Core engine (crate)
• Data store (file system)
Putting It All Together
• Layer 1 (User Layer): “Developer invokes CLI” and “Developer interacts with Desktop App.”
• Layer 4 (Storage Layer): “Templates” and “File System (IDL + Generated Code).”