|
1 | 1 | # TFChain GraphQL |
2 | 2 |
|
3 | | -TFChain GraphQL provides a GraphQL indexing and query interface for TFChain, the ThreeFold blockchain. It uses [Subsquid](https://docs.subsquid.io) to index on-chain events and expose them through a GraphQL API. |
| 3 | +A high-performance indexing layer with a queryable GraphQL API over TFChain 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-based indexer that consumes raw blockchain events from TFChain, 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 | +TFChain => 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 v16x |
16 | | -* Docker |
17 | | -* Docker-compose |
| 39 | +- Node v16.x |
| 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 |
26 | | -- `db` - Processor db migration files |
27 | | -- `scripts` - Scripts for generating initial state and development scripts |
28 | | -- `src` - Source |
29 | | - - `mappings` - Mapper functions for the indexer data |
30 | | - - `model` - Generated models from the `schema.graphql` file |
31 | | - - `types` - Type files that require manual edit if the schema changes / or chain types change |
32 | | - - `processor.ts` - Processor entrypoint |
33 | | -- `typegen` - Where the declaration files are generated from (used for development) |
34 | | - - `tfchainVersions.jsonl` - Generated tfchain runtime versions and their data |
35 | | - - `typegen.json` - Typegen config |
36 | | - - `typesBundle.json` - Typegen bundle config |
37 | | -- `schema.graphql` - The graphql schema file, changes to this file will results in changes to the models (`src/models`) |
| 49 | +- `indexer` — Docker Compose setup for the indexer |
| 50 | +- `db` — Processor database migration files |
| 51 | +- `scripts` — Scripts for generating initial state and development scripts |
| 52 | +- `src` — Source code |
| 53 | + - `mappings` — Mapper functions for indexer data |
| 54 | + - `model` — Generated models from the `schema.graphql` file |
| 55 | + - `types` — Type files that require manual edits when the schema or chain types change |
| 56 | + - `processor.ts` — Processor entrypoint |
| 57 | +- `typegen` — Declaration file generation (used for development) |
| 58 | + - `tfchainVersions.jsonl` — Generated TFChain runtime versions and their data |
| 59 | + - `typegen.json` — Typegen config |
| 60 | + - `typesBundle.json` — Typegen bundle config |
| 61 | +- `schema.graphql` — The GraphQL schema file; changes to this file result in changes to the models in `src/models` |
38 | 62 |
|
39 | 63 | ## License |
40 | 64 |
|
41 | | -This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details. |
42 | | -Copyright (c) TFTech NV. |
| 65 | +This project is licensed under the Apache License 2.0 — see the [LICENSE](LICENSE) file for details. |
| 66 | +Copyright (c) TFTech NV. |
0 commit comments