> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sqd.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Squid SDK Overview

> Squid SDK architecture overview — processor, batch handlers, schema, and Store roles in building TypeScript blockchain indexers with GraphQL APIs.

A *squid* is an indexing project built with [Squid SDK](https://github.com/subsquid/squid-sdk) to retrieve and process blockchain data from the [SQD Network](/en/network/overview)
(either permissioned or decentralized instance). The Squid SDK is a set of open source Typescript libraries that retrieve, decode, transform and persist the data. It can also make the transformed data available via an API. All stages of the indexing pipeline, from the data extraction to transformation to persistence are performed on [batches of blocks](/en/sdk/squid-sdk/resources/batch-processing) to maximize the indexing speed. Modular architecture of the SDK makes it possible to extend indexing projects (squids) with custom plugins and data targets.

<Frame>
  <img src="https://mintcdn.com/sqd-2119b3c3/jhotoTOdrFNe3s36/images/squid-flow.gif?s=c06c030d0a1307fae724cf7255f35208" alt="Animated diagram of a squid: raw data from Portal is decoded and transformed by the processor, persisted to PostgreSQL, and served through a GraphQL API" width="1284" height="394" data-path="images/squid-flow.gif" />
</Frame>

## Required squid components

### Processor

*Processor* is the word used for

1. The main NodeJS process of the squid.
2. The main object (`processor`) of this process: its method call `processor.run()` is the entry point.

Processor code handles data retrieval and transformation; data persistence is handled by a separate object called [Store](#store). Current Squid SDK data sources include:

* [`@subsquid/evm-stream`](/en/sdk/squid-sdk/reference/processors/evm-stream) with `@subsquid/batch-processor` for Portal-native EVM indexing
* [`@subsquid/solana-stream`](/en/sdk/squid-sdk/reference/processors/solana-stream) with `@subsquid/batch-processor` for Portal-native Solana indexing
* [`EvmBatchProcessor`](/en/sdk/squid-sdk/reference/processors/evm-batch) from [`@subsquid/evm-processor`](https://www.npmjs.com/package/@subsquid/evm-processor) for gateway and RPC ingestion on Ethereum-compatible networks
* [`SubstrateBatchProcessor`](/en/sdk/squid-sdk/reference/processors/substrate-batch) from [`@subsquid/substrate-processor`](https://www.npmjs.com/package/@subsquid/substrate-processor) for Substrate networks
* [`TronBatchProcessor`](/en/sdk/squid-sdk/reference/processors/tron-batch) from [`@subsquid/tron-processor`](https://www.npmjs.com/package/@subsquid/tron-processor) for Tron

The Portal-native stack uses the standalone `run(dataSource, database, handler)` function. Its handler context contains `{store, blocks, isHead}`. The older processor classes expose `.run()` and also inject `ctx.log` and, where supported, `ctx._chain`.

### Store

A *store* is an object that processors use to persist their data. SQD offers three store classes:

* [`TypeormStore`](/en/sdk/squid-sdk/resources/persisting-data/typeorm) for saving data to PostgreSQL, via

  * [`@subsquid/typeorm-store`](https://www.npmjs.com/package/@subsquid/typeorm-store)
  * [`@subsquid/typeorm-codegen`](https://www.npmjs.com/package/@subsquid/typeorm-codegen) (a code generator, install with `--save-dev`)
  * [`@subsquid/typeorm-migration`](https://www.npmjs.com/package/@subsquid/typeorm-migration)

  Install all three packages to use this store.
* [`file-store`](/en/sdk/squid-sdk/resources/persisting-data/file) via [`@subsquid/file-store`](https://www.npmjs.com/package/@subsquid/file-store) - for saving data to filesystems. It is a modular system with a variety of [extensions](/en/sdk/squid-sdk/reference/store/file) for various formats and destinations.
* [`bigquery-store`](/en/sdk/squid-sdk/resources/persisting-data/bigquery) via [`@subsquid/bigquery-store`](https://www.npmjs.com/package/@subsquid/bigquery-store) - for saving data to [Google BigQuery](https://cloud.google.com/bigquery).

You can mix and match any store class with any processor class.

## Optional squid components

### Typegen

A *typegen* is a tool for generating utility code for technology-specific operations such as decoding. Here are the typegens available:

<Tabs>
  <Tab title="On EVM">
    * [`squid-evm-typegen`](/en/sdk/squid-sdk/resources/tools/typegen/generation) via [`@subsquid/evm-typegen`](https://www.npmjs.com/package/@subsquid/evm-typegen):
      * decodes smart contract data
      * handles direct calls to contract methods
      * exposes useful constants such as event topics and function signature hashes
        The generated code imports both [`@subsquid/evm-abi`](https://www.npmjs.com/package/@subsquid/evm-abi) and [`@subsquid/evm-codec`](https://www.npmjs.com/package/@subsquid/evm-codec). Install both as direct dependencies.
  </Tab>

  <Tab title="On Substrate">
    * [`squid-substrate-typegen`](/en/sdk/squid-sdk/resources/tools/typegen/generation) via [`@subsquid/substrate-typegen`](https://www.npmjs.com/package/@subsquid/substrate-typegen):
      * general purpose pallet data decoding (aware of runtime versions)
      * handles direct storage queries
    * [`squid-ink-typegen`](/en/sdk/squid-sdk/resources/tools/typegen/generation) via [`@subsquid/ink-typegen`](https://www.npmjs.com/package/@subsquid/ink-typegen) for decoding the data of [ink!](https://use.ink) contracts
  </Tab>
</Tabs>

Install these with `--save-dev`.

### GraphQL server

Squids that store their data in PostgreSQL can subsequently make it available as a GraphQL API via a variety of supported servers. See [Serving GraphQL](/en/sdk/squid-sdk/resources/serving-graphql).

Among other alternatives, SQD provides its own server called [OpenReader](/en/sdk/squid-sdk/reference/openreader-server) via the [`@subsquid/graphql-server`](https://www.npmjs.com/package/@subsquid/graphql-server) package. The server runs as a separate process. [Core API](/en/sdk/squid-sdk/reference/openreader-server/api) is automatically derived from the schema file; it is possible to extend it with [custom queries](/en/sdk/squid-sdk/reference/openreader-server/configuration/custom-resolvers) and [basic access control](/en/sdk/squid-sdk/reference/openreader-server/configuration/authorization).

### Misc utilities

<Tabs>
  <Tab title="On EVM">
    * [Squid CLI](/en/sdk/squid-sdk/squid-cli/installation) is a utility for [retrieving squid templates](/en/sdk/squid-sdk/squid-cli/init), managing [chains of commands](https://github.com/subsquid/squid-sdk/tree/master/util/commands) commonly used in development and running [all squid processes at once](/en/sdk/squid-sdk/squid-cli/run). It can also be used for deploying to [SQD Cloud](/en/cloud).
  </Tab>

  <Tab title="On Substrate">
    * [Squid CLI](/en/sdk/squid-sdk/squid-cli/installation) is a utility for [retrieving squid templates](/en/sdk/squid-sdk/squid-cli/init), managing [chains of commands](https://github.com/subsquid/squid-sdk/tree/master/util/commands) commonly used in development and running [all squid processes at once](/en/sdk/squid-sdk/squid-cli/run). It can also be used for deploying to [SQD Cloud](/en/cloud).
    * [`@subsquid/ss58`](https://www.npmjs.com/package/@subsquid/ss58) handles encoding and decoding of SS58 addresses
    * [`@subsquid/frontier`](https://www.npmjs.com/package/@subsquid/frontier) decodes events and calls of the [Frontier EVM pallet](https://paritytech.github.io/frontier/frame/evm.html) to make them decodable with [`squid-evm-typegen`](/en/sdk/squid-sdk/resources/tools/typegen/generation)
  </Tab>
</Tabs>
