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

# Supabase Storage

> Mount Supabase Storage as a virtual filesystem.

The Supabase resource mounts a Supabase Storage bucket at some prefix
such as `/supabase/`. All operations involve network I/O to the remote
object store. Uses aioboto3 against Supabase's S3-compatible API.

For credential setup, see [Supabase Setup](/home/setup/supabase).

## Config

```python theme={null}
import os

from mirage import MountMode, Workspace
from mirage.resource.supabase import SupabaseConfig, SupabaseResource

config = SupabaseConfig(
    bucket=os.environ["SUPABASE_BUCKET"],
    region=os.environ["SUPABASE_REGION"],
    project_ref=os.environ["SUPABASE_PROJECT_REF"],
    access_key_id=os.environ["SUPABASE_ACCESS_KEY_ID"],
    secret_access_key=os.environ["SUPABASE_SECRET_ACCESS_KEY"],
    # Optional:
    # endpoint_url="https://{project_ref}.storage.supabase.co/storage/v1/s3",
    # session_token="...",
    # timeout=30,
    # proxy="http://proxy:8080",
)
resource = SupabaseResource(config=config)
ws = Workspace({"/supabase": resource}, mode=MountMode.READ)
```

`SupabaseResource(config)` takes a `SupabaseConfig` object with the
bucket name, `region`, and either `project_ref` (endpoint is auto-built
as `https://{project_ref}.storage.supabase.co/storage/v1/s3`) or an
explicit `endpoint_url`. Both `READ` and `WRITE` modes are supported.

## Filesystem Layout

The Supabase resource maps object keys to virtual paths under the mount
prefix. Supabase "directories" are prefix-based — there are no real
directory objects.

For example, if bucket `my-bucket` contains:

```text theme={null}
avatars/user-001.png
avatars/user-002.png
documents/report.pdf
documents/data.csv
```

Then mounting at `/supabase/` exposes:

```text theme={null}
/supabase/
  avatars/
    user-001.png
    user-002.png
  documents/
    report.pdf
    data.csv
```

Path mapping: virtual `/supabase/avatars/user-001.png` maps to Supabase
key `avatars/user-001.png`.

## Cache

The Supabase resource uses `IndexCacheStore` with `index_ttl = 600`
(10 minutes). Directory listings are cached for up to 600 seconds before
being refreshed from Supabase.

## Example

```python theme={null}
import asyncio
import os

from dotenv import load_dotenv

from mirage import MountMode, Workspace
from mirage.resource.supabase import SupabaseConfig, SupabaseResource

load_dotenv(".env.development")

config = SupabaseConfig(
    bucket=os.environ["SUPABASE_BUCKET"],
    region=os.environ["SUPABASE_REGION"],
    project_ref=os.environ["SUPABASE_PROJECT_REF"],
    access_key_id=os.environ["SUPABASE_ACCESS_KEY_ID"],
    secret_access_key=os.environ["SUPABASE_SECRET_ACCESS_KEY"],
)

resource = SupabaseResource(config=config)


async def main() -> None:
    ws = Workspace({"/supabase/": resource}, mode=MountMode.READ)

    r = await ws.execute("ls /supabase/")
    print(await r.stdout_str())

    r = await ws.execute("cat /supabase/documents/data.csv | head -n 10")
    print(await r.stdout_str())

    r = await ws.execute("tree -L 2 /supabase/")
    print(await r.stdout_str())

    r = await ws.execute("find /supabase/ -name '*.pdf'")
    print(await r.stdout_str())

    r = await ws.execute("stat /supabase/avatars/user-001.png")
    print(await r.stdout_str())


if __name__ == "__main__":
    asyncio.run(main())
```

## Shell Commands

The Supabase resource supports the full set of shell commands since it operates
on real file content (text, binary, JSON, CSV, etc.). Large files benefit
from range reads to avoid downloading entire objects.

### Read Commands

| Command         | Notes                                      |
| --------------- | ------------------------------------------ |
| `cat`           | Read file content                          |
| `head` / `tail` | First/last N lines                         |
| `grep` / `rg`   | Pattern search (file or directory level)   |
| `jq`            | Query JSON fields                          |
| `wc`            | Line/word/byte counts                      |
| `stat`          | File metadata (name, size, type, modified) |
| `find`          | Recursive search with `-name`, `-maxdepth` |
| `tree`          | Directory tree view                        |
| `nl`            | Number lines                               |
| `du`            | Disk usage summary                         |
| `file`          | Detect file type                           |
| `strings`       | Extract printable strings from binary      |
| `xxd`           | Hex dump                                   |
| `md5`           | MD5 checksum                               |
| `sha256sum`     | SHA-256 checksum                           |

### Text Processing

| Command    | Notes                                       |
| ---------- | ------------------------------------------- |
| `awk`      | Pattern scanning and processing             |
| `sed`      | Stream editor                               |
| `tr`       | Translate or delete characters              |
| `sort`     | Sort lines                                  |
| `uniq`     | Remove duplicate lines                      |
| `cut`      | Extract fields/columns                      |
| `join`     | Join lines on a common field                |
| `paste`    | Merge lines side by side                    |
| `column`   | Columnate output                            |
| `fold`     | Wrap lines to a specified width             |
| `expand`   | Convert tabs to spaces                      |
| `unexpand` | Convert spaces to tabs                      |
| `fmt`      | Simple text formatter                       |
| `rev`      | Reverse lines                               |
| `tac`      | Concatenate and print in reverse            |
| `look`     | Display lines beginning with a given string |
| `shuf`     | Shuffle lines                               |
| `tsort`    | Topological sort                            |
| `comm`     | Compare two sorted files                    |
| `cmp`      | Compare two files byte by byte              |
| `diff`     | Compare files line by line                  |
| `patch`    | Apply a diff patch                          |
| `iconv`    | Character encoding conversion               |

### File Operations

| Command  | Notes                                 |
| -------- | ------------------------------------- |
| `cp`     | Copy files                            |
| `mv`     | Move/rename files                     |
| `rm`     | Remove files                          |
| `mkdir`  | Create directories                    |
| `touch`  | Create empty file or update timestamp |
| `ln`     | Create symbolic links                 |
| `tee`    | Write stdin to file and stdout        |
| `mktemp` | Create temporary file                 |
| `split`  | Split file into pieces                |
| `csplit` | Split file by context                 |

### Path Utilities

| Command    | Notes                      |
| ---------- | -------------------------- |
| `basename` | Strip directory from path  |
| `dirname`  | Strip filename from path   |
| `realpath` | Resolve path               |
| `readlink` | Print symbolic link target |
| `ls`       | List directory contents    |

### Compression

| Command  | Notes                 |
| -------- | --------------------- |
| `gzip`   | Compress files        |
| `gunzip` | Decompress gzip files |
| `zip`    | Create zip archives   |
| `unzip`  | Extract zip archives  |
| `tar`    | Archive files         |
| `zcat`   | Cat compressed files  |
| `zgrep`  | Grep compressed files |

### Encoding

| Command  | Notes                |
| -------- | -------------------- |
| `base64` | Base64 encode/decode |

### Data Format Support

Commands with format-specific variants for structured data files:

| Format  | Extension  | Variants                                       |
| ------- | ---------- | ---------------------------------------------- |
| Parquet | `.parquet` | cat, head, tail, wc, stat, cut, grep, ls, file |
| Feather | `.feather` | cat, head, tail, wc, stat, cut, grep, ls, file |
| ORC     | `.orc`     | cat, head, tail, wc, stat, cut, grep, ls, file |
| HDF5    | `.hdf5`    | cat, head, tail, wc, stat, cut, grep, ls, file |

These variants auto-detect the format by extension and convert to
tabular text (CSV) for processing.

## Use Cases

* **AI agents accessing Supabase data**: Mount Supabase buckets for agents to read and process datasets
* **Data pipelines**: Read and write Supabase objects with shell-like commands
* **FUSE mounting**: Expose Supabase buckets through a virtual FUSE mount for external tools
