# Redundancy and Data Repair

DÆTA implements advanced redundancy and data repair mechanisms to ensure high data availability and durability.

> **`Redundancy Strategy`**
>
> * **Reed-Solomon Erasure Coding**: Enables data recovery with fewer shards than the original total.
> * **Geographic Distribution**: Shards are stored on nodes in different physical locations.
> * **Dynamic Redundancy**: Adjusts based on file importance and network conditions.

> **`Redundancy Configuration`**

{% tabs %}
{% tab title="Example" %}

```
{
  "file_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "total_shards": 30,
  "required_shards": 20,
  "distribution": {
    "continent": {
      "max_shards_per_continent": 10,
      "min_continents": 3
    },
    "country": {
      "max_shards_per_country": 5,
      "min_countries": 6
    }
  }
}
```

{% endtab %}
{% endtabs %}

> **`Data Repair Process`**
>
> * **Continuous Monitoring**: Satellites regularly check shard availability.
> * **Threshold Detection**: Repair process initiated when available shards approach the minimum threshold.
> * **Shard Regeneration**: Missing shards are reconstructed using available data.
> * **Replication**: New shards are distributed to maintain desired redundancy.

{% tabs %}
{% tab title="Repair Algorithm (Simplified)" %}
{% code overflow="wrap" %}

```
def repair_file(file_id):
    shards = get_file_shards(file_id)
    available_shards = [s for s in shards if s.is_available()]
    
    if len(available_shards) <= file.required_shards:
        reconstruct_and_redistribute(file_id, available_shards)
    elif len(available_shards) < file.total_shards:
        regenerate_missing_shards(file_id, available_shards)

def reconstruct_and_redistribute(file_id, available_shards):
    original_data = reconstruct_data(available_shards)
    new_shards = generate_new_shards(original_data, file.total_shards)
    distribute_shards(new_shards)

def regenerate_missing_shards(file_id, available_shards):
    missing_shard_count = file.total_shards - len(available_shards)
    new_shards = generate_additional_shards(available_shards, missing_shard_count)
    distribute_shards(new_shards)
```

{% endcode %}
{% endtab %}
{% endtabs %}

By implementing this architecture, DÆTA ensures a robust, scalable and resilient decentralized storage network that can adapt to changing conditions and maintain high data integrity and availability.


---

# 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.daeta.xyz/daeta-framework/redundancy-and-data-repair.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.
