This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Shardeum Explorer is a blockchain data indexing and visualization platform for the Shardeum Network. It consists of three main services:
- Collector: Gathers blockchain data from the distributor
- Server: Provides REST APIs and Next.js web interface
- Aggregator: Calculates statistical data
npm install # Install dependencies
npm run prepare # Compile TypeScript (required before running)
npm run dev # Start Next.js development server
npm run server:watch # Start backend server with auto-reloadnpm run test # Run tests
npm run lint # Run ESLint
npm run format-check # Check code formatting
npm run fix # Fix linting and formatting issuesnpm run collector # Start data collector service
npm run server # Start API/UI server (default port: 6001)
npm run aggregator # Start statistics aggregatornpm run build # Build Next.js frontend
npm run build:release # Full build (TypeScript + Next.js)
npm run flush # Clean database files- Framework: Fastify.js with TypeScript
- Database: SQLite3 (db.sqlite3 for main data, statsDB.sqlite3 for statistics)
- Messaging: RabbitMQ for inter-service communication
- Real-time: Socket.io for WebSocket connections
Key backend modules:
/src/server.ts- Main API server entry point/src/collector.ts- Blockchain data collection service/src/aggregator.ts- Statistics calculation service/src/storage/- Database models and data access layer/src/stats/- Statistics calculation logic/src/routes/- API endpoint definitions
- Framework: Next.js with React and TypeScript
- Styling: SCSS modules (
.module.scss) - Data Fetching: SWR hooks for API calls
- Charts: Highcharts for visualizations
Key frontend structure:
/src/pages/- Next.js page routes/src/frontend/api/- API hooks using SWR/src/frontend/components/- Reusable UI components/src/frontend/[feature]/- Feature-specific components (account, transaction, cycle, etc.)
- Formatting: Prettier with single quotes, no semicolons, 120-char lines
- Linting: Google TypeScript Style (gts)
- Components: React functional components with TypeScript
- Imports: Use relative imports within modules
Main configuration is in /src/config/index.ts. Key settings:
distributorInfo- Connection to blockchain distributorcollectorInfo- Collector service identityrpcUrl- JSON-RPC server endpoint
- Always run
npm run prepareafter pulling changes - Use
npm run fixto auto-fix linting/formatting issues - Test files go in
/test/directory - Frontend components should have accompanying SCSS modules
- API routes follow RESTful conventions in
/src/routes/
The project uses SQLite with models defined in /src/storage/:
- Accounts, Transactions, Cycles, Receipts
- Original transaction data stored alongside decoded data
- Statistics stored in separate statsDB.sqlite3
- Requires running Shardeum distributor and JSON-RPC server
- Uses RabbitMQ for message queuing between services
- Services can be managed with PM2 in production