Priority: P1
Source
Senior Architect Code Review (2026-04-03)
Problem
apps/indexer/src/main.rs is an 849-line monolith containing:
- Configuration parsing (
IndexerConfig)
- Database connection and schema management (
Database)
- Sui RPC client and all API call methods (
SuiRpcClient)
- Event processing pipeline (
process_page, poll_until_caught_up)
- Cursor/state management (
CursorState, merge_state)
- Health check HTTP server (
start_health_check_server)
- All RPC response deserialization types (
RpcEnvelope, RpcEventPage, etc.)
- Utility functions (
parse_i64, parse_timestamp_ms, etc.)
- ~150 lines of inline tests
Meanwhile, handlers.rs and models.rs exist but the actual database interactions bypass the TurretEventStore trait entirely — main.rs has its own Database struct with direct tokio_postgres calls.
Recommendation
Extract into focused modules:
| Module |
Contents |
config.rs |
IndexerConfig, env parsing helpers |
database.rs |
Database struct, schema management, cursor CRUD, event insertion |
rpc.rs |
SuiRpcClient, all RPC types (RpcEnvelope, RpcEventPage, etc.) |
pipeline.rs |
process_page, poll_until_caught_up, PollSummary, PageOutcome |
health.rs |
start_health_check_server |
main.rs |
Entrypoint only — config, wiring, tokio::spawn |
Also reconcile the TurretEventStore trait in handlers.rs with the actual database operations in main.rs.
Acceptance Criteria
Priority: P1
Source
Senior Architect Code Review (2026-04-03)
Problem
apps/indexer/src/main.rsis an 849-line monolith containing:IndexerConfig)Database)SuiRpcClient)process_page,poll_until_caught_up)CursorState,merge_state)start_health_check_server)RpcEnvelope,RpcEventPage, etc.)parse_i64,parse_timestamp_ms, etc.)Meanwhile,
handlers.rsandmodels.rsexist but the actual database interactions bypass theTurretEventStoretrait entirely —main.rshas its ownDatabasestruct with directtokio_postgrescalls.Recommendation
Extract into focused modules:
config.rsIndexerConfig, env parsing helpersdatabase.rsDatabasestruct, schema management, cursor CRUD, event insertionrpc.rsSuiRpcClient, all RPC types (RpcEnvelope,RpcEventPage, etc.)pipeline.rsprocess_page,poll_until_caught_up,PollSummary,PageOutcomehealth.rsstart_health_check_servermain.rstokio::spawnAlso reconcile the
TurretEventStoretrait inhandlers.rswith the actual database operations inmain.rs.Acceptance Criteria
main.rsis under 100 lines (entrypoint and wiring only)TurretEventStoretrait is either used by the production path or removed