Skip to content

refactor(explorer): remove the dead node read path and simplify the backend - #13

Merged
MehranMazhar merged 1 commit into
mainfrom
claude/refactor-explorer-qackzt
Oct 6, 2026
Merged

MehranMazhar merged 1 commit into
mainfrom
claude/refactor-explorer-qackzt

Conversation

@MehranMazhar

Copy link
Copy Markdown
Member

Requested by Mehran · project thread

Before: the backend carried a second read path (data_source = "node") that called a REST API clutch-node never had, three traits with one implementation each, about 50 copies of the same map_err, and the indexer fetched every block from the node twice.

After: one read path (Postgres), no single-implementation layers, one node call per block. The API's responses, the database schema and what the indexer writes are unchanged. Net about 1,200 fewer lines.

The behavior stays the same. This was checked on a local 3-validator clutch-node chain with 8 transfers: the old and new indexers wrote identical rows to every table, and 33 API requests got the same status code and JSON from both (successes, 404s and 400s). The only difference is key order in a few detail responses, which JSON ignores.

How:

  • Removed node_client.rs and node_repository.rs, plus the data_source, strict_mode and clutch_node_api_url settings. Every deployment uses postgres. clutch-deploy's configs still set those keys, and serde ignores them, so nothing has to change there before this merges.
  • Removed the ExplorerRepository trait, the ExplorerService wrapper and the NodeIngestionSource trait. Handlers now call PostgresRepository, and the indexer calls NodeSource.
  • NodeSource::fetch_block reads a block's header, transactions and effects from one get_block_by_index call. Before, there was one call for the header and another for the transactions.
  • ExplorerError now converts from sqlx::Error and builds its own JSON response. Handlers share the paging and validation helpers. The transaction filter uses QueryBuilder instead of counting $n placeholders by hand.
  • db.rs runs migrations from one list. Seq logging no longer locks a Mutex around every send.
  • Frontend: removed unused .segmented CSS and an export nothing imported.
  • Updated CLAUDE.md to match. It also fixes "ceiling" to "floor" for referrer fees, because the code floors.

Checks: cargo test --all-targets (15 pass), cargo clippy clean, tsc and vite build pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VmCzHLuviWNhDk89GeuXDF


Generated by Claude Code

…impl layers

- Remove data_source = "node" (node_client.rs, node_repository.rs): it called a REST API the
  node never had, so it could only error or, with strict_mode off, return made-up data. Every
  deployment runs postgres. strict_mode and clutch_node_api_url go with it; a config that still
  carries them is unaffected, serde ignores the keys.
- Drop the ExplorerRepository trait, ExplorerService wrapper and NodeIngestionSource trait, each
  with one implementation; handlers call PostgresRepository and the indexer calls NodeSource.
- The indexer fetches each block once instead of twice (two get_block_by_index calls per height).
- ExplorerError converts from sqlx::Error and renders its own JSON response, replacing ~50
  map_err calls and the per-handler error and paging boilerplate. Responses are unchanged.
- db.rs runs migrations from one list; Seq logging drops a Mutex that serialised every send.
- Frontend: remove the unused .segmented styles and an export nothing imports.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmCzHLuviWNhDk89GeuXDF
@MehranMazhar MehranMazhar self-assigned this Oct 6, 2026
@MehranMazhar
MehranMazhar merged commit 0d385cf into main Oct 6, 2026
4 checks passed
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.

2 participants