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

# Basic concepts

# Satori

Control over your data doesn't have to be hard. Satori aims to give the developer superpowers without making it hard.

## Installing

1. First, download

   ### Linux

   ```bash theme={null}
   bash -c "$(curl -fsSL https://satoridb.com/linux/setup.sh)"
   ```

   ### Windows

   ```bash theme={null}
   powershell -ExecutionPolicy Bypass -NoProfile -Command "Invoke-WebRequest -Uri 'https://satoridb.com/win/setup.ps1' -OutFile 'setup.ps1'; .\setup.ps1"
   ```
2. Then run satori

   ```bash theme={null}
   satori -a root admin
   ```

## Arguments

You can run Satori with multiple arguments, this are

```bash theme={null}
-l <LICENSE_KEY> //license key for AICore
-port //set the port where satori will be executing (defaults to 2310)
-m <host> <port> //connect to a network, example: -m 127.0.0.1 2311
-pwd //set network password
-ai //run satori with ai capabilities (a ~100mb model will be downloaded)
-a <username> <password> //enable authentication and set root user
-mem //use satori as a memory-only database
-mem_t <threshold> //memory threshold at which MEMORY_BALANCE is activated, example: satori -t 80 (memory balancing will be activated at 80% memory consumption)
-emb_b <embedding_backend> //ex: ollama:model || openai:model
-b <ai_backend> //llm backend to use query and ask operations ex: ollama:model || openai:model
-ne //disable embedding generation
```

## Migration

If you already have a database with Mongo, Surreal or any other you can import it into Satori

```bash theme={null}
satori -i <format> <file>
```

Format can be `mongo` `surreal` or `json` .

Mongo format takes objects like this

```
{obj1}
{obj2}
```

All objects are separated by a `\n` . This is the standard Mongo export format. Object keys are infered from the default `oid`  property

Surreal exports are SurrealQL files. All object keys are inferred if there is a key or id property and object type is inferred from the table name.

JSON is a generic format. If you work with any other DB just export your data into this format. An array of json objects

```
[
{obj1}, {obj2}
]
```

In this format object keys are also inferred by the property `key` or `id`. If key must be inferred from any other field specify it with the `-k` arg

```
satori -i <format> <file> -k body.info.name //body.info.name
```

If the property specified with `-k` is present it will be used as key, if not, a random uuid will be asigned. There is also a `-t` parameter to set the class that works just the same as the `-k` parameter

## CLI

When you install satori you also install Satori's CLI, run

```bash theme={null}
satoridb -h
```

This way you'll receive instructions on how to use it.

### CLI quickstart

```bash theme={null}
>satoridb connect ws://127.0.0.1 admin root
satori>set user:1 {"email": "test@test.com"}
satori>get user:1
#response
```

## Objects

Objects are the only data type in Satori and these are polymorphic, these can be a node, a JSON object, a string entry or all at once. Satori allows interactions among objects without caring about their kind. All functions are avaible to all Objects. All objects have the following fields and they must be specified when an object is created **(only if you're working directly with websockets and not with the sdks)**

<ParamField body="key" type="string">
  A key for accessing the object, if not provied, an uuid will be generated
</ParamField>

<ParamField body="data" type="string, json, number, any[]" required>
  This is the body that will be associated to your key, this can be anything you want
</ParamField>

<ParamField body="vertices" type="string[]">
  This array relates your object with other nodes, relations can be keys to object or just strings with any other meaning.
</ParamField>

<ParamField body="type" type="string">
  This is used to order your data by classes like users, posts, etc...
</ParamField>

<ParamField body="expires" type="bool">
  If the objects expires it must be set to true
</ParamField>

<ParamField body="expiration_time" type="number">
  The time in milliseconds that the object must live
</ParamField>

## Operations

Operations or commands are the querys you make to the database, these are simple commands such as `SET, GET, PUT, DELETE`. Data operations modify the objects in the database and system operations modify the behavior of the system. To make a request you must

<Steps>
  <Step title="Connect to Satori via websocket" />

  <Step title="Send the request">
    The request must be a JSON object and have:

    <ParamField body="command" type="string" required>
      The operation you want to execute
    </ParamField>

    and `...request specific parameters such as (key, encryption_key, etc...)`
  </Step>
</Steps>

You can perform operations on multiple objects that meet certain conditions using the `field_array` field, objects must match all the criteria in the field\_array, example:

`[{field: "status", value: "unpaid"}]`

will return all objects that in their data have the field `status` as `unpaid`

## Users

When authentication is enabled, users are the only ones who can access the database, they can have roles that limit their capacity to access and modify the data, all users must have:

<ParamField body="username" type="string" required />

<ParamField body="password" type="string" />

<ParamField body="permissions" type="number">
  `R || W || RW`

  ###
</ParamField>

### Network Password

Is encouraged to set a network password in order to ensure a secure communication among all nodes without security flaws. All nodes in the same network must have the same network password, read all about descentralization below

<Card title="Descentralization" icon="webhook" href="https://docs.satoridb.com/descentralization">
  Lear how you can scale satori horizontally without effort
</Card>

### Memory balancing

Satori can take up a lot of your computer's RAM, so, to fix that, Satori has a built-in memory balancing system that frees up memory when it has reached a critical point, because of that, satori stores objects as separate `json` files inside the `db` folder, this allows for faster reads whenever an object is not in memory because of memory saving matters.

## Learn more

<CardGroup cols={2}>
  <Card title="Data Operations" icon="database" href="https://docs.satoridb.com/data-operations">
    Learn about Satori data operations
  </Card>

  <Card title="System Operations" icon="solar-system" href="https://docs.satoridb.com/system-operations">
    Learn about Satori system operations
  </Card>

  <Card title="Satori AI" icon="brain-circuit" href="https://docs.satoridb.com/ai">
    Learn about Satori ai operations
  </Card>

  <Card title="Comming soon" icon="clock" href="https://docs.satoridb.com/soon">
    Learn about what's comming next to Satori
  </Card>
</CardGroup>
