Skip to main content
Version: Next

Architecture

EchoMirror SDK is a multi-language, multi-platform SDK built on a shared Rust core. This page shows exactly how the pieces fit together — which crates depend on which, how compiled artifacts cross language boundaries, and which package you need for a given use case.

Dependency graph​

The diagram below is derived directly from the Cargo.toml and package.json dependency declarations in this monorepo.

Key observations​

echomirror-wasm is independent of the other crates. It uses wasm-bindgen directly and implements its own crypto (sha2, hex). It is the WASM build target — not a wrapper around echomirror-core.

@echomirror/core is a pure TypeScript package. It is a REST API client for the EchoMirror backend, not a wrapper around @echomirror/wasm. The two serve different purposes: /core handles mood, auth, and social API calls; /wasm exposes cryptographic utilities (address validation, hashing) that run entirely in the browser without an API call.

@echomirror/analytics is standalone. It has no dependency on other @echomirror/* packages and can be dropped into any existing app without pulling in the rest of the SDK.

Three distinct FFI surfaces. The Rust codebase produces three compiled artifacts for non-Rust callers:

ArtifactOutput typeConsumed by
echomirror-wasm.wasm via wasm-pack@echomirror/wasm (JS/TS)
echomirror-ffi .so/.dylib/.dllcdylib + staticlibFlutter (dart:ffi), Swift (xcframework)
echomirror-ffi .a / .xcframeworkstaticlibSwift SPM binary target
echomirror-python _echomirror.socdylib (PyO3)Python (echomirror package)

Which package do I need?​

Use this table to find the right starting point. Most use cases need only one or two packages.

I'm building a web app (browser)​

GoalInstall
Log moods, get streaks, AI reflections@echomirror/core + @echomirror/mood
Add Stellar wallet + ECHO balance@echomirror/stellar
React hooks and Provider@echomirror/react (includes @echomirror/core)
Drop-in floating mood widget@echomirror/widget
Raw crypto utilities (address validation, hashing) with no backend call@echomirror/wasm
Track emotional UX events@echomirror/analytics (standalone, no SDK needed)
Social feed, leaderboard, follows@echomirror/social

Typical React app → @echomirror/react + @echomirror/mood + @echomirror/stellar

I'm building a React Native / Expo app​

Use the JS packages above. The @echomirror/wasm package works in React Native with Metro's WASM support. For native crypto performance, you can also use echomirror-ffi via a native module.

I'm building a Flutter / Dart app​

Install echomirror_sdk from pub.dev. The Flutter package already bundles the FFI bridge to echomirror-ffi — you do not need to add the Rust crates separately.

dependencies:
echomirror_sdk: ^0.1.0

I'm building an iOS or macOS app in Swift​

Add packages/swift/EchoMirrorSDK as a Swift Package Manager local dependency, or wait for the SPM registry release. Build the XCFramework first:

packages/swift/EchoMirrorSDK/Scripts/build-xcframework.sh

I'm building a Python backend​

pip install echomirror-sdk

This installs the PyO3 native extension (echomirror-python) with full asyncio support.

I'm building a Rust backend / server​

Add whichever crates you need:

[dependencies]
echomirror-core = "0.1" # always needed: client, types, auth
echomirror-stellar = "0.1" # Stellar balance, Friendbot, TX building
echomirror-sync = "0.1" # streaming ledger sync with resumable cursors

Add the postgres feature to echomirror-sync if you want the built-in cursor store:

echomirror-sync = { version = "0.1", features = ["postgres"] }

I need Stellar payments only (no mood, no social)​

  • TypeScript/JS → @echomirror/stellar alone (it depends on @echomirror/core but that's a lightweight API client)
  • Rust → echomirror-stellar + echomirror-core
  • Flutter → echomirror_sdk (the Flutter package is unified; you only call the stellar APIs)
  • Python → pip install echomirror-sdk then use sdk.stellar.*

I need address validation or hashing with no backend​

Use @echomirror/wasm directly. It runs entirely in the browser (or Node.js) — no API key, no backend call:

import { isValidStellarAddress, hashPublicKey } from '@echomirror/wasm'
console.log(isValidStellarAddress('GPUBLIC_KEY')) // true
console.log(hashPublicKey('GPUBLIC_KEY')) // sha256 hex

Decision flowchart​


Layer summary​

┌──────────────────────────────────────────────────────────────────┐
│ EchoMirror Platform API │
│ auth · mood · AI reflections · social feed │
└───────────────────────────┬──────────────────────────────────────┘
│ HTTP / REST
┌───────────────────────────▼──────────────────────────────────────┐
│ Rust Core Layer │
│ │
│ echomirror-core echomirror-stellar echomirror-sync │
│ types · client · auth Horizon · balance SSE · cursors │
│ Friendbot · TX gap backfill │
└──────────┬────────────────────────┬──────────────────────────────┘
│ │
wasm-bindgen C-ABI + PyO3
│ │
┌──────▼──────┐ ┌────────────┴──────────────────────┐
│ WASM target │ │ FFI targets │
│ (.wasm) │ │ echomirror-ffi echomirror-python│
└──────┬──────┘ │ (.so/.dylib (_echomirror.so) │
│ │ .xcframework) │
│ └──────────┬────────────────────────┘
│ │
┌──────▼──────┐ ┌──────────┴────────────────────────┐
│ @echomirror │ │ Native packages │
│ /wasm │ │ echomirror_sdk (Flutter/Dart) │
└──────┬──────┘ │ EchoMirrorSDK (Swift) │
│ │ echomirror (Python) │
│ └───────────────────────────────────┘
┌──────▼──────────────────────────────────────────────┐
│ JS / TS packages │
│ @echomirror/core · mood · stellar · social │
│ react · analytics · widget │
└─────────────────────────────────────────────────────┘