Skip to content

feat: replace REST API with Raindex market service - #2847

Open
findolor wants to merge 1 commit into
arda/registry-market-statisticsfrom
arda/market-data-rest-api
Open

feat: replace REST API with Raindex market service#2847
findolor wants to merge 1 commit into
arda/registry-market-statisticsfrom
arda/market-data-rest-api

Conversation

@findolor

@findolor findolor commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Chained PRs

Summary

  • Replace the authenticated take-orders REST API with a public, unauthenticated Raindex market-data service.
  • Serve public ticker and executable orderbook endpoints plus the SDK snapshot shape used by the webapp.
  • Back reads with the SDK persistent local indexer, a minutely last-good overview cache, and per-market executable-book caches.
  • Add the production deployment architecture: OpenTofu-managed DigitalOcean resources, encrypted state, declarative NixOS, deploy-rs profiles, persistent storage, nginx/TLS, bounded logs, and verified GitHub deployments.

Key decisions

  • Wait for every configured local index to become ready before warming the first snapshot. RAINDEX_LOCAL_DB_READY_TIMEOUT_SECONDS controls the startup deadline and defaults to 600 seconds.
  • GET /tickers publishes required 24-hour fields for every active direct quote market without quoting every order on each minute refresh.
  • GET /orderbook?ticker_id=...&depth=... quotes only the requested market and exposes up to a fixed 1,000-level SDK snapshot. Failed RPC quotes or ratio normalization return retryable 503 responses and are not cached.
  • GET /v1/markets serves lightweight cached SDK snapshots for the webapp. Filtering by ticker_id adds executable depth and bounded recent trades.
  • Keep the optional historical-trades endpoint deferred until the SDK supports arbitrary indexed ranges without silently truncating its 24-hour snapshot.
  • Enforce global and per-socket-IP rate limits, request IDs, structured errors, CORS, tracing, and readiness/freshness health checks.
  • Emit JSON logs to stdout and daily rotated files with a 14-file retention limit; production also bounds journald to 14 days and 512 MB.
  • Treat no discovered markets as a valid, cacheable snapshot: /tickers and /v1/markets return 200 []. Duplicate cross-chain ticker IDs, fatal registry/trade reads, and incomplete executable books remain errors.
  • Use reproducible Crane builds, nixos-anywhere bootstrap, a pinned SSH host key, encrypted Terraform variables/state, a persistent DigitalOcean volume, declarative firewall/nginx/systemd configuration, and atomic deploy-rs rollbacks.

Validation

  • cargo test -p raindex_rest_api --locked: 26 passed
  • cargo clippy -p raindex_rest_api --all-targets --locked -- -D warnings
  • nix build .#raindex-api --no-link
  • nix flake check --no-build --impure
  • nix shell .#opentofu -c tofu -chdir=infra validate
  • nix shell .#actionlint -c actionlint .github/workflows/raindex-api.yaml .github/workflows/deploy-raindex-api.yaml
  • Local smoke test waited for the Base index, discovered 48 active direct quote markets from local_db, and served healthy overview, ticker, detail, and orderbook responses.

Production prerequisites

  • Provision once with the documented tfEditVars, tfPlan, tfApply, and bootstrap commands, then commit the encrypted variables/state and verified host key.
  • Point the production hostname at the reserved IP. The default is api.raindex.finance; RAINDEX_API_HOSTNAME overrides it.
  • Configure the Production environment with RAINDEX_API_SSH_KEY and, optionally, CACHIX_AUTH_TOKEN and RAINDEX_API_HOSTNAME.

No issue is linked per the implementation scope.

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 62ff882d-b30c-4cc3-b5c2-fc5467f6e3a1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

findolor commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label Raindex-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@findolor
findolor marked this pull request as ready for review August 25, 2026 14:36
@findolor
findolor force-pushed the arda/market-data-rest-api branch from 21683c7 to 5fa505e Compare August 25, 2026 14:58
@findolor
findolor force-pushed the arda/market-data-rest-api branch from 5fa505e to e17c5c5 Compare August 25, 2026 15:22
@findolor
findolor force-pushed the arda/registry-market-statistics branch from 8c83ef6 to ad43904 Compare August 25, 2026 15:22
@findolor
findolor force-pushed the arda/market-data-rest-api branch 4 times, most recently from fe3aee3 to 4a399b4 Compare August 26, 2026 06:38
@findolor
findolor force-pushed the arda/registry-market-statistics branch from ad43904 to cc8464f Compare August 26, 2026 07:02
@findolor
findolor force-pushed the arda/market-data-rest-api branch from 4a399b4 to 740c1a6 Compare August 26, 2026 07:02
@findolor
findolor force-pushed the arda/registry-market-statistics branch from cc8464f to 219fdf8 Compare August 26, 2026 08:15
@findolor
findolor force-pushed the arda/market-data-rest-api branch from 740c1a6 to 32a821b Compare August 26, 2026 08:15
@findolor
findolor force-pushed the arda/registry-market-statistics branch from 219fdf8 to fe6e647 Compare August 26, 2026 08:21
@findolor
findolor force-pushed the arda/market-data-rest-api branch from 32a821b to 1961bbf Compare August 26, 2026 08:21
@findolor

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 51 minutes.

@findolor findolor self-assigned this Aug 26, 2026
@findolor
findolor requested a review from rouzwelt August 26, 2026 08:28
@findolor
findolor force-pushed the arda/market-data-rest-api branch 8 times, most recently from 3cdf6b1 to f1bcb07 Compare August 26, 2026 10:37
@findolor
findolor force-pushed the arda/market-data-rest-api branch from f1bcb07 to c5f741d Compare August 26, 2026 12:56
@findolor
findolor force-pushed the arda/registry-market-statistics branch from fe6e647 to 445c5ed Compare August 26, 2026 14:49
@findolor
findolor force-pushed the arda/market-data-rest-api branch 2 times, most recently from fd27ca7 to 8d442d7 Compare August 26, 2026 15:18
@findolor findolor changed the title feat: replace REST API with market data service feat: replace REST API with Raindex market service Aug 26, 2026
@findolor
findolor force-pushed the arda/market-data-rest-api branch from 8d442d7 to 74a54a7 Compare August 26, 2026 16:33
@findolor
findolor force-pushed the arda/registry-market-statistics branch from 445c5ed to aa31ede Compare August 26, 2026 16:33
@findolor
findolor requested a review from ueco-jb August 26, 2026 16:36
@findolor
findolor force-pushed the arda/registry-market-statistics branch from aa31ede to d176c47 Compare August 26, 2026 17:01
@findolor
findolor force-pushed the arda/market-data-rest-api branch from 74a54a7 to 05a5495 Compare August 26, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant