You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A modular, high-performance headless e-commerce backend written in Rust, API-compatible with MedusaJS v2.
Implements the core Browse → Cart → Checkout flow with 49 endpoint methods across 7 domain modules, backed by PostgreSQL (primary) or SQLite (optional).
See docs/p1_additions.md for a full compliance comparison against Medusa v2 — which endpoints match, which are toko-rs additions, and what is deferred to future phases.
Quick Start
# Start PostgreSQL
docker compose up -d
# Copy config
cp .env.example .env
# Seed sample data (3 products + 1 customer)
cargo run -- --seed
# Start server
cargo run
Invoice config is stored as environment variables (not a DB table): INVOICE_COMPANY_NAME, INVOICE_COMPANY_ADDRESS, INVOICE_COMPANY_PHONE, INVOICE_COMPANY_EMAIL, INVOICE_COMPANY_LOGO, INVOICE_NOTES.
PostgreSQL is the default. SQLite is available behind a feature flag:
cargo run --features sqlite --no-default-features
Testing
make docker-up # Start PostgreSQL# Integration tests (297 tests, requires PostgreSQL)
DATABASE_URL=postgres://postgres:postgres@localhost:5432/toko_test \
cargo test -- --test-threads=1
# SQLite tests
DATABASE_URL="sqlite::memory:" \
cargo test --features sqlite --no-default-features -- --test-threads=1
# E2E tests (spawns live HTTP server)
E2E_DATABASE_URL=postgres://postgres:postgres@localhost:5432/toko_e2e \
cargo test --test e2e -- --test-threads=1
# Coverage (requires cargo-llvm-cov)
make cov
Tests run single-threaded (--test-threads=1) for database isolation. Each test cleans its own tables via clean_all_tables().
Test Organization
tests/
common/mod.rs Shared test helpers (setup_test_app, clean_all_tables)
product_test.rs Product admin + store integration tests
cart_test.rs Cart lifecycle tests
order_test.rs Order + payment tests
order_export_test.rs Order CSV export tests
customer_test.rs Customer registration + profile tests
invoice_test.rs Invoice config + generation tests
event_test.rs Event outbox integration tests
webhook_test.rs Webhook subscription CRUD + HMAC delivery tests
contract_test.rs Response shape validation against Medusa OAS
e2e/ End-to-end tests against live HTTP server
Configuration
Configured via environment variables or .env file:
make dev # cargo run
make test# cargo test
make lint # cargo clippy -- -D warnings
make fmt # cargo fmt
make seed # cargo run -- --seed
make docker-up # docker compose up -d
make docker-down # docker compose down
make test-pg # Test against PostgreSQL
make test-sqlite # Test against SQLite
make test-all # Both databases
make cov # cargo llvm-cov