Mando Workspace

Rust Cargo workspace powering the Alpiq BESS platform.

Workspace Structure

mando/
├── Cargo.toml              # Workspace root
├── Cargo.lock
├── rust-toolchain.toml     # Rust 1.88.0
├── rustfmt.toml
├── .gitlab-ci.yml          # CI/CD pipeline
├── Dockerfile              # Production image
├── container.*.Dockerfile  # Build/base images (Linux + Windows)
│
├── mando-lib/              # Core library
├── mando-lib-macro/        # Procedural macros
├── mando-bess/             # REST API service
├── py-mando/               # Python bindings (PyO3)
│
├── assets/                 # Test/demo data
├── doc/                    # Logo, diagrams
├── docs/                   # Arrow benchmarks, plans
├── lib/libduckdb/          # Bundled DuckDB 1.4.2 (Linux amd64)
├── scripts/                # Benchmarks, load tests, seed data
└── test/                   # Integration tests

Crate Dependency Graph

graph LR
    MACRO["[[mando-lib-macro]]"] --> LIB["[[mando-lib]]"]
    LIB --> BESS["[[mando-bess]]"]
    LIB --> PY["[[py-mando]]"]
    SCRT["[[mando-scrt]]"] -.-> LIB

mando-scrt

Standalone binary (not workspace member yet). Uses PyO3 auto-initialize (embeds Python) vs py-mando’s extension-module (loaded by Python). See mando-scrt.

All crates share workspace-level dependencies defined in the root Cargo.toml.

Key Workspace Dependencies

Data & Analytics

CrateVersionPurpose
arrow56.2.0Columnar data (IPC/FFI)
polars0.49.1Lazy DataFrames, JSON, Parquet, IPC
apache-avro0.17.0Avro serialization

Databases

CrateVersionPurpose
rusqlitebundledSQLite with r2d2 pooling
deadpool-postgres / tokio-postgresPostgreSQL async
duckdb1.4.2DuckDB with Arrow appender
refineryPostgreSQL migrations

Web & API

CrateVersionPurpose
axum0.8.7Async web framework
reqwest0.12.24HTTP client
cynic3.12.0GraphQL client codegen
utoipa / utoipa-scalarOpenAPI docs

Python Integration

CrateVersionPurpose
pyo30.25.1Rust ↔ Python FFI
pyo3-polars0.22.0Polars DataFrame bridge
pyo3-arrow0.11.0Arrow bridge
maturin1.9.2Build tool

Observability

CrateVersionPurpose
opentelemetry0.30.0OTLP exporter (gRPC/tonic)
tracing0.1.43Structured logging
axum-otel-metrics0.12.0HTTP metrics

Auth & Security

CrateVersionPurpose
jsonwebtoken9.3.1JWT (RS256)
rustls0.23.35TLS with native certs

Feature Flags

The workspace uses feature flags to control compilation:

FeatureUsed ByPurpose
appmando-libEnables Axum + OpenTelemetry (for mando-bess)
codegenmando-libCode generation utilities
pythonmando-libPyO3 bindings (conditional #[pyclass])
workflowmando-libFlow execution engine

Architecture Patterns

Repository Pattern

Trait-based database abstraction with three backends:

  • PostgreSQL — primary production store
  • DuckDB — analytics/OLAP workloads
  • SQLite — lightweight/local development
  • Passthrough — optional caching layer

Service Layer

MandoService async trait provides uniform data access. Factory functions create backend-specific instances.

Flow Engine

Versioned workflows (v1, v2, v3) with strategy implementations for trading, auction, scheduling, etc.

Python Bridge

PyO3 extension module with abi3-py38 stable ABI. Uses pyo3-polars and pyo3-arrow for zero-copy data exchange.

Scripts

ScriptPurpose
cpu_bench.shCPU profiling
fargate_bench.shAWS Fargate benchmarks
load_test.shHTTP load testing
seed_data.pyTest data generation
seed_scenarios.pyScenario initialization
stress_test.pyStress testing
scenario_stress_test.pyScenario-level stress
bench_chart.pyBenchmark visualization