# Architecture

### API Architecture[​](https://docs.ternoa.network/for-developers/developer-tools/ternoa-js/introduction#api-architecture) <a href="#api-architecture" id="api-architecture"></a>

The Ternoa SDK facilitates access to the main functionalities offered by the Ternoa chain. It enables you to execute all transactions from the chain pallets/primitives, perform queries, or access constant storage. Additionally, the SDK includes various helpers and utility functions to enhance your overall experience.

#### On-chain handlers architecture[​](https://docs.ternoa.network/for-developers/developer-tools/ternoa-js/introduction#handlers-architecture) <a href="#handlers-architecture" id="handlers-architecture"></a>

For those who have experience with Polkadot, the architectural design of the features in Ternoa SDK will be familiar. If you are new to this, there's no need to worry as the fundamental concepts are straightforward to grasp. Based on the specific pallet or handler category, you can access the following:

* ***Constants*** to request the chain runtime.
* ***Storage*** to query the chain state.
* ***Extrinsics*** to execute the transactions.
* ***Utils & Helpers:*** Some powerful functions to assist you in interacting with the chain or performing off-chain operations.

{% hint style="info" %}
If you need to perform custom storage calls, constant calls, or extrinsic calls that are not readily available as dedicated helpers in the SDK, you can execute them directly through the [API using `getRawApi()`](/getting-started/javascript-sdk/ternoa-js-library/initialization.md). Further instructions on executing custom calls can be found in the  [Build section.](/build-1/javascript.md)
{% endhint %}

#### Off-chain handlers architecture[​](https://docs.ternoa.network/for-developers/developer-tools/ternoa-js/introduction#handlers-architecture) <a href="#handlers-architecture" id="handlers-architecture"></a>

* ***Helpers:*** Some user-friendly functions to facilitate performing off-chain operations like interacting with TEE SGX Clusters, connecting and storing data in the IPFS Ternoa client, and managing encryption with keys (...).

#### The main handlers are the ones below:[​](https://docs.ternoa.network/for-developers/developer-tools/ternoa-js/introduction#the-main-handlers-are-the-ones-below) <a href="#the-main-handlers-are-the-ones-below" id="the-main-handlers-are-the-ones-below"></a>

* [blockchain](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/blockchain): the CORE blockchain function. The API brain that randomly: init the API, executes transactions, queries data, batch transactions, etc.
* [account](https://github.com/capsule-corp-ternoa/ternoa-js/blob/main/src/account/): the functions that allow you to generate a new seed and a keyring
* [auction](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/auction): the Auction pallet with its extrinsics, query, and storage to create auctions and manage bids.
* [assets](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/assets): the Auction pallet with its extrinsics, query, and storage.
* [balance](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/balance): the Balance pallet with its extrinsics, query, and storage.
* [nft](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/nft): the NFT pallet with its extrinsics, query, and storage.
* [marketplace](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/nft): the Marketplace pallet with its extrinsics, query, and storage.
* [protocols](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/protocols): the Transmission protocols pallet with its extrinsics, query, and storage.
* [rent](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/rent): the Rent pallet with its extrinsics, query, and storage.
* [helpers](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/helpers): the helpers' folder that contains all the functions to perform off-chain operations:&#x20;
  * Crypto utilities
  * Encryption helpers
  * The Ternoa IPFS client
  * Some end-to-end NFT, secret NFT & Capsule NFT helpers
  * Some TEE helpers interact with clusters
  * The Utility helpers as formatters, file converters, and other useful helpers.
* [events](https://github.com/capsule-corp-ternoa/ternoa-js/blob/main/src/events.ts): the [events list ](/getting-started/javascript-sdk/ternoa-js-library/blockchain-events.md)returned when the `submitTxBlocking` function is triggered

#### Response Format[​](https://docs.ternoa.network/for-developers/developer-tools/ternoa-js/introduction#response-format) <a href="#response-format" id="response-format"></a>

In our effort to offer the most accessible tools for building on the Ternoa chain, we have also endeavored to simplify the response formats of our functions where possible. Depending on whether you can use the automated approach or the customizable one to run your extrinsics, we suggest selecting the appropriate function. Some functions will directly provide events and featured data, while others will return only the transaction hash in hexadecimal format to be signed and submitted by the external user of your dApp. *More about this automated or customizable approach in the* [*Workflow section.*](/getting-started/javascript-sdk/ternoa-js-library/workflow.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ternoa.network/getting-started/javascript-sdk/ternoa-js-library/architecture.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
