Skip to content

Commit 9f4abfc

Browse files
committed
CLAUDE.md
1 parent 9c62979 commit 9f4abfc

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed

CLAUDE.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Overview
6+
7+
This is the Graph Protocol Indexer monorepo containing the indexer agent, CLI, and common libraries. The indexer helps run infrastructure for The Graph Network by indexing subgraphs and serving queries.
8+
9+
## Repository Structure
10+
11+
- **`/packages/`** - Lerna monorepo with 4 packages:
12+
- **`indexer-agent/`** - Main indexer agent that manages allocations and monitors the network
13+
- **`indexer-cli/`** - CLI for managing indexer operations (plugin for @graphprotocol/graph-cli)
14+
- **`indexer-common/`** - Shared functionality used by other packages
15+
- **`indexer-native/`** - Listed but directory doesn't exist (deprecated)
16+
- **`/docs/`** - Documentation including network configs and setup guides
17+
- **`/k8s/`** - Kubernetes deployment configurations
18+
- **`/terraform/`** - Infrastructure as Code for GKE deployment
19+
- **`/scripts/`** - Utility scripts including test runner
20+
21+
## Essential Commands
22+
23+
### Development Setup
24+
25+
```bash
26+
# Install dependencies and build all packages
27+
yarn
28+
yarn bootstrap
29+
30+
# Clean and rebuild everything
31+
yarn clean && yarn bootstrap
32+
33+
# Compile TypeScript across all packages
34+
yarn compile
35+
```
36+
37+
### Running Tests
38+
39+
```bash
40+
# Run all tests (requires PostgreSQL container - use the script below)
41+
bash scripts/run-tests.sh
42+
43+
# Run tests in a specific package
44+
cd packages/indexer-agent && yarn test
45+
cd packages/indexer-cli && yarn test
46+
cd packages/indexer-common && yarn test
47+
48+
# Run a specific test file
49+
yarn test path/to/specific.test.ts
50+
51+
# Run tests matching a pattern
52+
yarn test --testNamePattern="specific test name"
53+
54+
# Watch mode for TDD
55+
yarn test:watch
56+
57+
# Debug mode with verbose logging
58+
yarn test:debug
59+
```
60+
61+
### Code Quality
62+
63+
```bash
64+
# In any package directory
65+
yarn lint # Lint and fix TypeScript files
66+
yarn format # Format code with Prettier
67+
yarn prepare # Run format, lint, and compile
68+
```
69+
70+
### Running the Indexer
71+
72+
```bash
73+
# From source (after building)
74+
cd packages/indexer-agent
75+
./bin/graph-indexer-agent start [options]
76+
77+
# CLI commands
78+
graph indexer [command]
79+
```
80+
81+
## Architecture
82+
83+
### Core Components
84+
85+
1. **Indexer Agent** - Autonomous agent that:
86+
- Monitors the network for subgraph deployments
87+
- Manages allocations (stake on subgraphs)
88+
- Handles query fee collection via TAP (Timeline Aggregation Protocol)
89+
- Submits POIs (Proofs of Indexing)
90+
- Manages interactions with Graph Node
91+
92+
2. **Indexer CLI** - Management interface for:
93+
- Setting indexing rules
94+
- Managing allocations manually
95+
- Configuring cost models
96+
- Monitoring disputes
97+
- Managing action queue
98+
99+
3. **Indexer Common** - Shared libraries for:
100+
- Database models (Sequelize ORM)
101+
- Ethereum interactions
102+
- Network subgraph queries
103+
- Common types and utilities
104+
105+
### Key Technical Details
106+
107+
- **Language**: TypeScript with strict type checking
108+
- **Database**: PostgreSQL (via Sequelize ORM)
109+
- **Blockchain**: Ethereum/Arbitrum (via ethers.js)
110+
- **Testing**: Jest with ts-jest
111+
- **Monorepo**: Lerna with Yarn workspaces
112+
113+
### Database Schema
114+
115+
The indexer uses PostgreSQL to store:
116+
117+
- Indexing rules
118+
- Allocation management state
119+
- Action queue
120+
- Cost models
121+
- POI dispute data
122+
- TAP receipts and RAVs (Receipt Aggregate Vouchers)
123+
124+
### Integration Points
125+
126+
- **Graph Node**: Queries subgraph data and manages deployments
127+
- **Ethereum/Arbitrum**: On-chain transactions for allocations
128+
- **Network Subgraph**: Queries protocol state
129+
- **TAP (Timeline Aggregation Protocol)**: Handles query fee collection and redemption
130+
- **TAP Subgraph**: Tracks TAP receipts and RAVs
131+
132+
## Testing Requirements
133+
134+
Tests require:
135+
136+
1. PostgreSQL database (handled by `scripts/run-tests.sh`)
137+
2. Environment variables in `.env`:
138+
139+
```
140+
INDEXER_TEST_JRPC_PROVIDER_URL=<Arbitrum Sepolia RPC>
141+
INDEXER_TEST_API_KEY=<Graph API key>
142+
```
143+
144+
## Current State
145+
146+
- Version: v0.24.3
147+
- Active branch: release-v0.24
148+
- Main branch: main
149+
- Uncommitted changes in docs/ and config/

0 commit comments

Comments
 (0)