Skip to content

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

Merged
findolor merged 1 commit into
mainfrom
arda/market-data-rest-api
Aug 28, 2026
Merged

feat: replace REST API with Raindex market service#2847
findolor merged 1 commit into
mainfrom
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: f838c829-a36f-4be4-b812-4d7b0f25c7f5

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

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 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
@findolor
findolor requested review from 0xgleb and agryaznov August 26, 2026 18:43
Comment thread crates/rest_api/src/cache.rs
@findolor
findolor force-pushed the arda/market-data-rest-api branch from 05a5495 to f6dd9f7 Compare August 28, 2026 05:25
@findolor
findolor force-pushed the arda/registry-market-statistics branch 2 times, most recently from 6b5e3a9 to 66bbe24 Compare August 28, 2026 05:38
@findolor
findolor force-pushed the arda/market-data-rest-api branch from f6dd9f7 to 15f111f Compare August 28, 2026 05:38
@findolor
findolor requested a review from ueco-jb August 28, 2026 06:22
Comment thread crates/rest_api/src/cache.rs Outdated
Comment thread crates/rest_api/src/service.rs
Comment thread crates/rest_api/src/cache.rs Outdated
Comment thread crates/rest_api/src/routes/markets.rs Outdated
Comment thread crates/rest_api/src/service.rs Outdated
Comment thread .github/workflows/deploy-raindex-api.yaml Outdated
@findolor
findolor force-pushed the arda/market-data-rest-api branch from 15f111f to 7dae402 Compare August 28, 2026 12:32
@findolor
findolor force-pushed the arda/registry-market-statistics branch from 66bbe24 to 7cc34f7 Compare August 28, 2026 12:32
@findolor
findolor requested a review from agryaznov August 28, 2026 12:56
Comment thread infra/default.nix Outdated
Comment thread crates/rest_api/src/cache.rs Outdated

@agryaznov agryaznov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@findolor
findolor force-pushed the arda/registry-market-statistics branch from 7cc34f7 to 95b99eb Compare August 28, 2026 15:24
@findolor
findolor force-pushed the arda/market-data-rest-api branch 2 times, most recently from a598997 to 286a028 Compare August 28, 2026 15:36
@findolor
findolor force-pushed the arda/registry-market-statistics branch from 95b99eb to bd9e1da Compare August 28, 2026 16:10
@findolor
findolor force-pushed the arda/market-data-rest-api branch from 286a028 to 28b8b46 Compare August 28, 2026 16:10
@findolor
findolor changed the base branch from arda/registry-market-statistics to main August 28, 2026 16:39
@findolor
findolor merged commit 8511904 into main Aug 28, 2026
20 of 23 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

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.

3 participants