StellarRoute is an open-source DEX aggregation engine and UI for the Stellar ecosystem. It provides unified price discovery and optimal routing across both traditional Stellar DEX (SDEX) orderbooks and modern Soroban-based AMM pools.
- Purpose: Solve the gap in price discovery and routing left by the deprecation of the SDEX Explorer.
- Main Technologies:
- Backend (Rust): Tokio, Axum, SQLx (PostgreSQL), Redis.
- Smart Contracts (Rust): Soroban SDK.
- Frontend (TypeScript): Next.js 16, React 19, Tailwind CSS 4, shadcn/ui.
- SDKs: Rust and TypeScript/JavaScript.
- Architecture: Modular Rust workspace with separate crates for indexing, API, routing, and contracts.
crates/indexer: Syncs SDEX orderbooks and Soroban AMM states to PostgreSQL. Supports polling and streaming (SSE) from Horizon.crates/api: Axum-based REST and WebSocket API providing quotes, orderbook snapshots, and trading pairs.- Entry point:
crates/api/src/bin/stellarroute-api.rs.
- Entry point:
crates/routing: Multi-hop pathfinding algorithm for discovering optimal trade routes.crates/contracts: Soroban smart contracts for on-chain swap execution and router interfaces.frontend/: Modern Next.js web interface for traders with real-time price updates and wallet integration.sdk-js/: TypeScript SDK for easy integration into web applications.crates/sdk-rust/: Rust SDK for backend integrations.
- Rust 1.75+
- Docker & Docker Compose
- Node.js 18+ (for frontend/SDK development)
- Soroban CLI
Create a .env file in the root directory:
DATABASE_URL=postgresql://stellarroute:stellarroute_dev@localhost:5432/stellarroute
REDIS_URL=redis://localhost:6379
STELLAR_HORIZON_URL=https://horizon.stellar.org
SOROBAN_RPC_URL=https://soroban-rpc.testnet.stellar.orgStart PostgreSQL and Redis:
docker-compose up -d- Build all:
cargo build - Run API:
cargo run -p stellarroute-api - Run Indexer:
cargo run -p stellarroute-indexer - Run Tests:
cargo test(unit tests) - Integration Tests:
DATABASE_URL=... cargo test -- --include-ignored
Located in frontend/:
- Install:
npm install - Dev:
npm run dev - Build:
npm run build - Test:
npm run test(Vitest) - E2E Test:
npm run test:e2e(Playwright)
Located in sdk-js/:
- Install:
npm install - Build:
npm run build - Test:
npm run test
- Code Style:
- Rust: Follow idiomatic patterns; use
cargo fmtandcargo clippy. Unsafe code is strictly forbidden (enforced by workspace lint). - TypeScript: Use ESLint and Prettier. Follow existing patterns for hooks and components.
- Rust: Follow idiomatic patterns; use
- Testing:
- Backend: Use Rust's built-in testing framework (
cargo test). Integration tests that require a database should be marked with#[ignore]. - Frontend/SDK: Use
vitest.
- Backend: Use Rust's built-in testing framework (
- Workflow:
- Conventional Commits: Use
feat:,fix:,docs:,refactor:,test:,chore:. - Branching:
main(stable),feature/*,fix/*,docs/*. - CI/CD: GitHub Actions for builds, tests, and linting. Always ensure CI is green before merging.
- Conventional Commits: Use
- Technical Integrity:
- Use
thiserrorfor library errors andanyhowfor application-level errors in Rust. - Prefer
tracingoverprintln!. - Handle
window.matchMediamissing in JSDOM by providing a mock infrontend/vitest.setup.ts. - Use
frontend/__mocks__/lucide-react.tsxfor icon mocking in tests.
- Use
crates/: Rust workspace members.frontend/: Next.js application.sdk-js/: TypeScript SDK.docs/: Comprehensive architecture, API, and development guides.scripts/: Deployment and utility scripts.migrations/: SQL migrations for PostgreSQL (managed bysqlx).
- Asset Format: Stellar assets are typically represented as
nativeorCODE:ISSUER. - API Performance: Target <500ms for quote requests.
- Caching: Redis is used for pairs (10s), orderbooks (5s), and quotes (2s).
- Icon Mocking: If tests fail due to missing icons, check
frontend/__mocks__/lucide-react.tsx. - URL State: The frontend uses URL query parameters (
base,quote) for persisting trading pair selection.