# Bundle Structure

Kwil utilizes its own bundle structure to allow for practically limitless levels of scalability.  By allowing for multiple data-moat blocks to be contained in a single bundle, and by utilizing a dynamic endpoint based indexing system, Kwil bundles allow for the easy implementation and removal of custom data-write methods while maintaining a high level of scalability and interoperability.

### Bundle Indexing

Each bundle is stored as a JSON with fields corresponding to each data-moat the node is serving.  Inside of each JSON field is each data-moat's block, which contains the new data submitted to the network over some arbitrary length of time.

Content inside each moat block is indexed by the endpoint on which it was received.  The content is submitted in some sort of standardized format to allow future nodes to verifiably un-bundle the data from Arweave.  For example, raw SQL statements are submitted to the /raw endpoint.  Image this SQL query was submitted for the data-moat "satoshi\_social":

```
INSERT INTO some_table (column_1, column_2) VALUES (value_1, value_2);
```

In the bundle, this would simply appear as:&#x20;

```
{
    "satoshi_social": [
        {
            query: `INSERT INTO some_table (column_1, column_2) VALUES (value_1, value_2);`,
            timestamp: `Mon Jan 31 2022 11:07:01 GMT-0800 (Pacific Standard Time)`
        }
    ]
}
```

### Images

Currently, Kwil supports files with no extensions and JPEGs.  All JPEGs must be BASE64 encoded.

{% hint style="info" %}
Hint: If your image won't display, make sure you are stripping any padding from the beginning.  Many libraries leave \~16 bytes of padding before the actual image data.
{% endhint %}

Now, let's imagine that an image was submitted to the data-moat "bayc\_videogame" with a file path of "images/boredApes/1455", and both of these data-moats were being served by the same node.  The bundle would now appear as:

```
{
    "satoshi_social": [
        {
            "raw":
            {
                "query": `INSERT INTO some_table (column_1, column_2) VALUES (value_1, value_2);`,
                "timestamp": `Mon Jan 31 2022 11:07:01 GMT-0800 (Pacific Standard Time)`
            }
        }
    ],
    "bayc_videogame": [
        {
            "storeJPEG":
            {
                "path": `images/boredApes/1455`,
                "image": `{some_base64_img}`
            }
        }
    ]
}
```

On any node that has synced this propagation, the photo would be accessible at the URL "https\://{node-url}/public/bayc\_videogame/images/boredApes/1455.jpeg"


---

# 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://v1docs.kwil.com/architecture/bundle-structure.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.
