|
1 | | -# TFChain GraphQL |
| 1 | +# Ledger GraphQL |
2 | 2 |
|
3 | | -[Subsquid](https://docs.subsquid.io) is used to index and provide a GraphQL interface on top of TFChain. |
| 3 | +A high-performance indexing layer with a queryable GraphQL API over Ledger Chain on-chain data. It enables efficient data access for dashboards, applications, and analytics tools without directly querying the blockchain. |
4 | 4 |
|
5 | | -## Concept |
| 5 | +## What this is |
6 | 6 |
|
7 | | -The substrate events are processed in a multi-step pipeline: |
| 7 | +This project provides a [Subsquid](https://docs.subsquid.io)-based indexer that consumes raw blockchain events from Ledger Chain, transforms them into a structured schema, and exposes them through a GraphQL endpoint. It replaces direct chain queries with a fast, developer-friendly API suitable for front-end applications and data analytics. |
8 | 8 |
|
9 | | - TFChain => Squid Indexer => Indexer GraphQL gateway => Squid Processor => Database => Query Node GraphQL endpoint |
| 9 | +## What this repository contains |
10 | 10 |
|
11 | | - |
| 11 | +- **Indexer** — Docker Compose setup for the Squid indexer that ingests on-chain events |
| 12 | +- **Processor** — Event processing pipeline that maps raw chain data to database models |
| 13 | +- **GraphQL schema** — `schema.graphql` defining the queryable data model |
| 14 | +- **Database migrations** — Migration files for the processor database |
| 15 | +- **Type definitions** — Chain-specific type files for decoding events |
| 16 | +- **Mapping functions** — Logic for transforming events into indexed entities |
| 17 | +- **Scripts** — Utility scripts for generating initial state and development workflows |
| 18 | + |
| 19 | +## Role in the stack |
| 20 | + |
| 21 | +The indexer sits between the blockchain and consumer applications. It decouples data access from the chain, allowing complex queries, aggregations, and historical lookups that would be inefficient or impossible via direct RPC calls. Dashboards, explorers, and third-party integrations rely on this layer for real-time and historical data. |
| 22 | + |
| 23 | +The data pipeline is: |
| 24 | + |
| 25 | +``` |
| 26 | +Ledger Chain => Squid Indexer => Indexer GraphQL gateway => Squid Processor => Database => Query Node GraphQL endpoint |
| 27 | +``` |
| 28 | + |
| 29 | +## Relation to ThreeFold |
| 30 | + |
| 31 | +This technology is used within the ThreeFold ecosystem and was first deployed on the ThreeFold Grid. The component itself is designed as reusable infrastructure technology and should be understood by its technical function first, independent of any specific deployment. |
| 32 | + |
| 33 | +## Ownership |
| 34 | + |
| 35 | +This repository is owned and maintained by TF-Tech NV, a Belgian company responsible for the development and maintenance of this technology. |
12 | 36 |
|
13 | 37 | ## Prerequisites |
14 | 38 |
|
15 | | -* Node v20+ |
16 | | -* Docker |
17 | | -* Docker Compose |
| 39 | +- Node v20+ |
| 40 | +- Docker |
| 41 | +- Docker Compose |
18 | 42 |
|
19 | 43 | ## Running |
20 | 44 |
|
21 | | -See [docs](./docs/readme.md) |
| 45 | +See [docs](./docs/readme.md) for detailed running instructions. |
22 | 46 |
|
23 | 47 | ## Project layout |
24 | 48 |
|
25 | | -- `indexer/` - Docker Compose setup for the indexer (archive) |
26 | | -- `db/` - Processor database migration files |
27 | | -- `scripts/` - Utility scripts (see [scripts/readme.md](./scripts/readme.md)) |
28 | | -- `src/` - Processor source code |
29 | | - - `mappings/` - Event handler functions that map chain events to database entities |
30 | | - - `model/` - Generated TypeORM models from `schema.graphql` |
31 | | - - `types/` - Auto-generated type definitions (do not edit manually — run `make typegen`) |
32 | | - - `processor.ts` - Processor entrypoint: event subscription and dispatch |
33 | | -- `typegen/` - Type generation infrastructure |
34 | | - - `tfchainVersions.jsonl` - Append-only log of runtime metadata from all TFChain networks |
35 | | - - `typegen.json` - Typegen config: which events to generate types for |
36 | | - - `typesBundle.json` - Frozen pre-V14 type mappings (do not edit for new runtime versions) |
37 | | -- `docs/` - Documentation |
38 | | - - [typeChanges.md](./docs/typeChanges.md) - How to handle type changes on chain (adding new runtime versions, resync guidance) |
39 | | - - [development.md](./docs/development.md) - Local development setup |
40 | | - - [production.md](./docs/production.md) - Production deployment |
41 | | - - [release_process.md](./docs/release_process.md) - Release workflow |
42 | | -- `schema.graphql` - GraphQL schema — changes here regenerate `src/model/` via `yarn codegen` |
43 | | -- `Makefile` - Common tasks: `typegen`, `typegen-add`, `typegen-seed`, `version-bump` |
44 | | -- `processor-chart/` - Helm chart for processor + query node deployment |
45 | | -- `indexer/chart/` - Helm chart for indexer stack deployment |
| 49 | +- `indexer/` — Docker Compose setup for the indexer (archive) |
| 50 | +- `db/` — Processor database migration files |
| 51 | +- `scripts/` — Utility scripts (see [scripts/readme.md](./scripts/readme.md)) |
| 52 | +- `src/` — Processor source code |
| 53 | + - `mappings/` — Event handler functions that map chain events to database entities |
| 54 | + - `model/` — Generated TypeORM models from `schema.graphql` |
| 55 | + - `types/` — Auto-generated type definitions (do not edit manually — run `make typegen`) |
| 56 | + - `processor.ts` — Processor entrypoint: event subscription and dispatch |
| 57 | +- `typegen/` — Type generation infrastructure |
| 58 | + - `tfchainVersions.jsonl` — Append-only log of runtime metadata from all Ledger Chain networks |
| 59 | + - `typegen.json` — Typegen config: which events to generate types for |
| 60 | + - `typesBundle.json` — Frozen pre-V14 type mappings (do not edit for new runtime versions) |
| 61 | +- `docs/` — Documentation |
| 62 | + - [typeChanges.md](./docs/typeChanges.md) — How to handle type changes on chain (adding new runtime versions, resync guidance) |
| 63 | + - [development.md](./docs/development.md) — Local development setup |
| 64 | + - [production.md](./docs/production.md) — Production deployment |
| 65 | + - [release_process.md](./docs/release_process.md) — Release workflow |
| 66 | +- `schema.graphql` — GraphQL schema — changes here regenerate `src/model/` via `npm run codegen` |
| 67 | +- `Makefile` — Common tasks: `typegen`, `typegen-add`, `typegen-seed`, `version-bump` |
| 68 | +- `processor-chart/` — Helm chart for processor + query node deployment |
| 69 | +- `indexer/chart/` — Helm chart for indexer stack deployment |
| 70 | + |
| 71 | +## License |
| 72 | + |
| 73 | +This project is licensed under the Apache License 2.0 — see the [LICENSE](LICENSE) file for details. |
0 commit comments