deno_runtime. It handles all backend logic including request execution, database operations, scripting, and the internal RPC server.
What is Tanxium?
Tanxium is a custom JavaScript runtime embedded directly into the Tauri application. Unlike traditional approaches that run Node.js or Deno as a separate process, Tanxium:- Runs in the same process as the Tauri app
- Provides a sandboxed environment for user scripts
- Offers custom APIs specific to Yasumu’s needs
- Eliminates the need for users to install Node.js or Deno
Architecture overview
Core components
Tanxium consists of several key components:1. Deno runtime integration
Tanxium is built on Deno’s runtime libraries:- TypeScript support: Native TypeScript execution without build steps
- Web APIs: Standard
fetch,Request,Response, etc. - V8 engine: The same JavaScript engine that powers Chrome
- Module resolution: ESM imports with npm package support
2. Custom Yasumu APIs
Tanxium exposes a globalYasumu object with custom APIs:
3. RPC server
The RPC server is a Hono application that handles frontend requests:- Listens on a random port (0 = OS assigns)
- Accepts JSON-RPC style requests
- Routes commands to registered handlers
- Returns type-safe responses
4. Database layer
Tanxium uses SQLite with Drizzle ORM:- Tables defined in TypeScript with Drizzle schemas
- Migrations generated with
drizzle-kit generate - Migrations run automatically on startup
5. SMTP echo server
The echo server catches test emails:Startup sequence
When Tauri launches, Tanxium goes through this initialization:Step-by-step
- Worker creation: Tauri creates a Deno worker thread
- Module loading: Loads
main.tsfrom the resources directory - Migration: Runs database migrations via Drizzle
- Server start: Starts RPC and echo servers on random ports
- Port registration: Communicates ports back to Tauri
- Ready: Frontend can now make RPC calls
Request execution flow
When executing a REST API request:Pre-request scripts
Pre-request scripts run before the HTTP request:- Set variables for the request
- Make additional HTTP calls
- Read from the database
- Generate dynamic data
Post-request scripts
Post-request scripts run after receiving the response:- Run assertions/tests
- Extract data from responses
- Chain requests together
- Update the database
Module system
Tanxium supports both ESM and npm packages:Built-in modules
npm packages
Workspace packages
Tanxium can import from the Yasumu workspace:Bundling process
Tanxium’s source code is bundled into a single JavaScript file:- Resolves all imports (workspace packages, npm packages)
- Transpiles TypeScript to JavaScript
- Bundles into a single
main.tsfile - Copies to Tauri’s resources directory
- Fast startup (no module resolution at runtime)
- Single artifact to embed
- No external dependencies
Permissions and security
Tanxium implements a permission system for user scripts:Permission types
- Network: Making HTTP requests
- Filesystem: Reading/writing files
- Environment: Accessing environment variables
- Command: Running system commands
Permission prompts
When a script requests a sensitive operation:- Tanxium pauses execution
- Sends permission request to Tauri
- Tauri shows native dialog to user
- User approves/denies
- Response sent back to Tanxium
- Script continues or throws error
Virtual modules
Tanxium supports “virtual modules” that don’t exist on disk:- Injecting runtime configuration
- Providing platform-specific APIs
- Dynamic code generation
Performance optimizations
Tanxium is optimized for fast startup and execution:Snapshots
Lazy loading
Large dependencies are imported lazily:Connection pooling
Database connections are pooled and reused:Debugging
Developers can inspect Tanxium using Chrome DevTools:- Enable devtools in development mode
- Use
console.log()from scripts - Logs appear in both Tauri logs and DevTools console
Next steps
- Frontend architecture - Learn about the Next.js UI layer
- RPC layer - Understand the type-safe communication layer
- Tech stack - See all technologies used