# Vector SDK

The Vector Bot Library is a Rust-based library for creating and managing Vector Bots that can send and receive private messages using the Nostr protocol. This library provides a structured and modular approach to building bots with configurable metadata and client settings.

## Features

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="image">Cover image</th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><h4><i class="fa-robot">:robot:</i></h4></td><td><strong>Vector Bots</strong></td><td>with custom metadata.</td><td><a href="https://1017057475-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZH1sYpOLAum28xFrXUjg%2Fuploads%2FCkdlNlyG5GRGmEAhEn2q%2FVector%20Bots.png?alt=media&#x26;token=9ee405e2-66e4-4c41-8525-5a585aed2c0f">Vector Bots.png</a></td><td></td><td></td></tr><tr><td><h4><i class="fa-envelope-open-text">:envelope-open-text:</i></h4></td><td><strong>Send/Receive Files</strong></td><td>Private messages &#x26; files.</td><td><a href="https://1017057475-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZH1sYpOLAum28xFrXUjg%2Fuploads%2FaqHCc5l7ra8oB2GhOmLD%2FSend-Receive%20Files.png?alt=media&#x26;token=70f1985b-8316-4755-9633-eb5a58be0e65">Send-Receive Files.png</a></td><td></td><td></td></tr><tr><td><h4><i class="fa-bell">:bell:</i></h4></td><td><strong>Custom Notifications</strong></td><td>for Gift Wrap events.</td><td><a href="https://1017057475-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZH1sYpOLAum28xFrXUjg%2Fuploads%2FRRtlTiyAccZ07yjfpnZt%2FNotifications.png?alt=media&#x26;token=70cef876-e0cd-4c8b-bc12-684926a19fad">Notifications.png</a></td><td></td><td></td></tr><tr><td><h4><i class="fa-onion">:onion:</i></h4></td><td><strong>Proxy Settings</strong></td><td>Configure for .onion relays.</td><td><a href="https://1017057475-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZH1sYpOLAum28xFrXUjg%2Fuploads%2FWpH2ANsu1uLtrr3oVilC%2FOnion.png?alt=media&#x26;token=62d2cd01-2370-4227-a30f-8ccd98f14fb1">Onion.png</a></td><td></td><td></td></tr><tr><td><h4><i class="fa-network-wired">:network-wired:</i></h4></td><td><strong>Relays</strong></td><td>Add and manage.</td><td><a href="https://1017057475-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZH1sYpOLAum28xFrXUjg%2Fuploads%2FkDEGt481DiUIskzGysJw%2FRelays.png?alt=media&#x26;token=fe7f1994-7d4b-4e00-aa03-48f166f9db69">Relays.png</a></td><td></td><td></td></tr><tr><td><h4><i class="fa-cubes">:cubes:</i></h4></td><td><strong>Modular</strong></td><td>Easy ext. &#x26; maintenance.</td><td><a href="https://1017057475-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZH1sYpOLAum28xFrXUjg%2Fuploads%2FxBKC6cSb3EYXLatlpqF6%2FModular.png?alt=media&#x26;token=d2ca7a4d-f640-4134-9747-e8f8c15e4803">Modular.png</a></td><td></td><td></td></tr></tbody></table>

* Create Vector Bots with customizable metadata
* Send and receive private messages and files
* Handle notifications for gift wrap events
* Configure proxy settings for .onion relays
* Add and manage relays
* Modular architecture for easy extension and maintenance
* Message Layer Security (MLS) for group messaging
* Typing indicators for real-time feedback
* Reaction support for messages
* File uploads with progress tracking
* Automatic failover for media servers

***

## MLS Implementation Status

The Vector SDK includes **Message Layer Security (MLS)** support for group messaging. The following MLS features are currently implemented and ready for use:

{% tabs fullWidth="false" %}
{% tab title="Implemented Features" %}

<div align="left"><figure><img src="https://1017057475-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZH1sYpOLAum28xFrXUjg%2Fuploads%2F8Go22gver65wCcrIe5xt%2FVector-Checkmark.png?alt=media&#x26;token=4306e6d9-540d-4873-be9b-3437da03f779" alt="Vector Icon - Checkmark" width="128"><figcaption></figcaption></figure></div>

### **Implemented Features:**

* Group joining via welcome events
* Group message sending and processing
* Group typing indicators
* Group file attachments
* Group reactions
* Persistent SQLite-backed storage for group state
  {% endtab %}

{% tab title="Placeholder Functions" %}

<div align="left"><figure><img src="https://1017057475-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZH1sYpOLAum28xFrXUjg%2Fuploads%2F6rjfJMSIrO5eCvOR4Bbc%2FVector-Warning.png?alt=media&#x26;token=78095101-653f-4cd2-897b-2c95af8db8e0" alt="Vector Icon - Warning" width="128"><figcaption></figcaption></figure></div>

### **Placeholder Functions (Not Yet Implemented):**&#x20;

The following MLS functions exist as stubs and will be implemented in future versions when needed:

* `create_group()` - Group creation functionality
* `add_member_device()` - Adding members to groups
* `leave_group()` - Leaving groups
* `remove_member_device_from_group()` - Removing members
* `send_group_message()` - Direct group message sending (use `Group::send_group_message()` instead)

These placeholder functions are available in the API but will return errors if called. They are included to provide a complete API surface for future expansion.
{% endtab %}
{% endtabs %}

***

## Documentation

For comprehensive documentation, see:

* [**CONTRIBUTING**](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/docs/contributing) - Development guidelines and contribution process
* [**SECURITY**](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/docs/security) - Security features, best practices, and threat model
* [**ADVANCED**](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/docs/advanced) - Advanced features including MLS, typing indicators, and debugging
* [**TROUBLESHOOTING**](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/docs/troubleshooting) - Common issues and solutions
* [**CHANGELOG**](https://changelog.mdhttps/github.com/VectorPrivacy/Vector-SDK/blob/mls-groups/CHANGELOG.md) - Release history and changes

***

## Examples

For practical examples and working code demonstrations, see the [Vector-SDK-Example](https://github.com/Luke-Larsen/Vector-SDK-Example) repository, which contains:

* Basic bot setup examples
* Direct messaging implementations
* Group messaging examples
* File handling demonstrations
* Advanced use cases
* Complete working applications

***

## Architecture

The library is organized into several modules, each responsible for a specific aspect of the bot's functionality:

1. [**VectorBot**](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/basics/components#vectorbot): The main struct representing the bot, containing metadata and client configuration.
2. [**Channel**](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/basics/components#channel): A struct for managing communication with specific recipients.
3. [**Client**](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/basics/components#client): Functions for building and configuring the Nostr client.
4. [**Metadata**](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/basics/components#metadata): Functions for creating and managing bot metadata.
5. [**Subscription**](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/basics/components#subscription): Functions for setting up event subscriptions.
6. [**Crypto**](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/basics/components#crypto): Functions for encryption and decryption.
7. [**Upload**](https://vector-privacy.gitbook.io/vector-privacy/vector-sdk/basics/components#upload): Functions for handling file uploads.

### High Level Architecture

```
+---------------------+
|     VectorBot       |
|---------------------|
| - keys              |
| - name              |
| - display_name      |
| - about             |
| - picture           |
| - banner            |
| - nip05             |
| - lud16             |
| - client            |
|---------------------|
| + quick()           |
| + new()             |
| + get_chat()        |
+---------------------+
          |
          v
+---------------------+
|      Channel        |
|---------------------|
| - recipient         |
| - base_bot          |
|---------------------|
| + new()             |
| + send_private_msg()|
+---------------------+

+---------------------+
|      Client        |
|---------------------|
| + build_client()   |
+---------------------+

+---------------------+
|     Metadata       |
|---------------------|
| + create_metadata()|
+---------------------+

+---------------------+
|   Subscription     |
|---------------------|
| + create_gift_wrap_|
|   subscription()    |
+---------------------+

+---------------------+
|      Crypto        |
|---------------------|
| + generate_encryption_params() |
| + encrypt_data()   |
+---------------------+

+---------------------+
|      Upload        |
|---------------------|
| + upload_data_with_progress() |
+---------------------+
```

For more detailed information about the architecture and advanced features, see [ADVANCED.md](https://github.com/VectorPrivacy/Vector-SDK/blob/mls-groups/ADVANCED.md).

***

## License

This project is licensed under the MIT License. See the [LICENSE](https://github.com/VectorPrivacy/Vector-SDK/blob/mls-groups/LICENSE) file for details.
