aviladb

Crates.ioaviladb
lib.rsaviladb
version0.1.0
created_at2025-11-23 08:15:26.334423+00
updated_at2025-11-23 08:15:26.334423+00
descriptionAvilaDB - Globally distributed NoSQL database optimized for Brazil and LATAM
homepagehttps://avila.cloud
repositoryhttps://github.com/avilaops/arxis
max_upload_size
id1946283
size236,679
Nรญcolas รvila (avilaops)

documentation

https://docs.rs/aviladb

README

๐Ÿ—„๏ธ AvilaDB

The Distributed Fortress. The Data Engine.

AVILA (fortress) + DB (database) = AvilaDB

Where data finds solid ground and engines drive queries

Crates.io Documentation License: MIT License: Apache 2.0 Rust AVL Cloud

๐Ÿ‡ง๐Ÿ‡ท Latency 5-10ms in Brazil | ๐ŸŒ Multi-region writes FREE | ๐Ÿ“ฆ 4 MB documents (2x competitors)


๐ŸŽฏ What is AvilaDB?

AvilaDB is the distributed NoSQL database for the AVL Cloud Platform - built as a fortress for your data and an engine for your queries.

Like Arxis provides the mathematical citadel, AvilaDB provides the data citadel:

  • ๐Ÿ›๏ธ Solid Foundation: Consistent, durable, ACID-compliant storage
  • โš™๏ธ Query Engine: High-performance queries with vector search
  • ๐Ÿ›ก๏ธ Protection: Encryption, backups, multi-region replication
  • ๐Ÿš€ Performance: 5-10ms latency in Brazil, sub-50ms in LATAM

๐ŸŒŸ Key Features

๐Ÿ‡ง๐Ÿ‡ท Optimized for Brazil & LATAM

  • 5-10ms latency in Sรฃo Paulo, Rio, Brasรญlia
  • Sub-50ms throughout Latin America
  • 40-60% cheaper than AWS DynamoDB or Azure Cosmos DB
  • Native Portuguese documentation and support

๐Ÿ“ฆ Large Documents

  • 4 MB per document (vs 400 KB DynamoDB, 2 MB Cosmos DB)
  • 50 GB per partition (vs 10 GB DynamoDB, 20 GB Cosmos DB)
  • Hierarchical Partition Keys (HPK) overcome limits

๐Ÿ” Native Vector Search

  • Built-in HNSW index for embeddings
  • Semantic search without external services
  • Perfect for AI/Chat/RAG applications
  • Low-cost compared to Pinecone/Weaviate

๐ŸŒ Multi-region Writes (FREE)

  • Global distribution included
  • No extra cost (unlike AWS/Azure)
  • Automatic conflict resolution
  • Active-active replication

โšก High Performance

  • Compression: LZ4 via avila-compress (>500 MB/s)
  • Throughput Units (TUs): Elastic scaling
  • Connection pooling: Reuse clients
  • Batch operations: Bulk writes/reads

๐Ÿ’ฐ Pricing (Brazil)

  • R$ 0,50 per 1M operations
  • R$ 0,20 per GB/month storage
  • FREE multi-region writes
  • FREE vector search (built-in)

๐Ÿ—๏ธ Architecture

AvilaDB follows the Arxis philosophy - solid as a fortress, powerful as an engine.

Built on top of world-class libraries from the Arxis ecosystem:

Core Dependencies

  • ๐Ÿ—œ๏ธ avila-compress

    • Native LZ4/Zstd compression (100% Rust, zero external deps)
    • 3x faster than standard implementations (>500 MB/s)
    • Optimized for columnar data and time-series
    • Production-ready โœ…
  • ๐Ÿ“Š avila-telemetry

    • Time series analysis, anomaly detection, forecasting
    • NASA-grade data quality metrics (โ‰ฅ0.95 threshold)
    • Observability and performance monitoring
    • 22 tests passing โœ…
  • ๐Ÿงฎ avila-math

    • Mathematical kernel for vectors and tensors
    • Shared across entire AVL ecosystem
    • High-performance linear algebra
    • 26 tests passing โœ…
  • ๐Ÿ“ก avx-http

    • Native HTTP client/server for AVL Platform
    • Optimized for Brazil and LATAM latency
    • Built on Tokio + Axum

Architecture Layers

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚        AvilaDB - Data Citadel           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  ๐Ÿ›๏ธ Storage Layer (RocksDB)             โ”‚
โ”‚     - ACID transactions                  โ”‚
โ”‚     - LSM-tree storage                   โ”‚
โ”‚     - avila-compress (LZ4/Zstd)         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โš™๏ธ Query Engine                        โ”‚
โ”‚     - SQL-like queries                   โ”‚
โ”‚     - Vector search (HNSW + avila-math) โ”‚
โ”‚     - Partition-aware routing           โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  ๐Ÿ›ก๏ธ Distribution Layer                  โ”‚
โ”‚     - Raft consensus                     โ”‚
โ”‚     - Multi-region replication          โ”‚
โ”‚     - Automatic failover                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  ๐Ÿš€ API Layer (avx-http + Axum)         โ”‚
โ”‚     - REST + gRPC                        โ”‚
โ”‚     - WebSocket subscriptions           โ”‚
โ”‚     - avila-telemetry observability     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฆ Installation

Add to your Cargo.toml:

[dependencies]
aviladb = "0.1"
tokio = { version = "1", features = ["full"] }

Using the CLI

# Install via curl
curl -sSL https://avila.cloud/install.sh | sh

# Connect to AvilaDB
avila db connect --account my-account

# Query data
avila db query "SELECT * FROM users WHERE active = true"

Local Emulator (Docker)

docker run -p 8000:8000 avilacloud/aviladb-emulator:latest

๐Ÿš€ Quick Start

Basic Operations

use aviladb::{AvilaClient, Document};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Connect to AvilaDB
    let client = AvilaClient::connect("http://localhost:8000").await?;
    let db = client.database("gamedb").await?;
    let players = db.collection("players").await?;

    // Insert document (4 MB limit)
    let player = Document::new()
        .set("userId", "player123")
        .set("username", "CoolGamer")
        .set("level", 42)
        .set("inventory", vec!["sword", "shield"])
        .set("stats", json!({
            "hp": 100,
            "mp": 50,
            "attack": 25
        }));

    let result = players.insert(player).await?;
    println!("Inserted: {}", result.id);

    // Query with filters
    let high_level = players
        .query("SELECT * FROM players WHERE level > @min_level")
        .param("min_level", 40)
        .execute()
        .await?;

    for doc in high_level {
        println!("Player: {}", doc.get("username")?);
    }

    // Update
    players.update()
        .set("level", 43)
        .where_eq("userId", "player123")
        .execute()
        .await?;

    // Delete
    players.delete()
        .where_eq("userId", "player123")
        .execute()
        .await?;

    Ok(())
}

Vector Search (AI/RAG)

use aviladb::{AvilaClient, VectorIndex};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = AvilaClient::connect("http://localhost:8000").await?;
    let db = client.database("aidb").await?;
    let memories = db.collection("chat_memory").await?;

    // Create vector index (HNSW)
    memories.create_vector_index("embedding", 1536, "cosine").await?;

    // Store with embedding
    let memory = Document::new()
        .set("userId", "user123")
        .set("message", "Tell me about quantum physics")
        .set("embedding", vec![0.1, 0.2, 0.3, /* ... 1536 dims */])
        .set("timestamp", chrono::Utc::now());

    memories.insert(memory).await?;

    // Semantic search
    let query_embedding = vec![0.15, 0.18, 0.29, /* ... */];
    let similar = memories
        .vector_search("embedding", query_embedding)
        .top_k(5)
        .execute()
        .await?;

    for doc in similar {
        println!("Similar: {} (score: {})",
            doc.get("message")?,
            doc.similarity_score()
        );
    }

    Ok(())
}

Hierarchical Partition Keys (HPK)

use aviladb::{AvilaClient, HierarchicalKey};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = AvilaClient::connect("http://localhost:8000").await?;
    let db = client.database("multitenantdb").await?;

    // Create collection with HPK
    let orders = db.create_collection("orders")
        .partition_key(HierarchicalKey::new()
            .add_level("tenantId")
            .add_level("userId")
            .add_level("orderId")
        )
        .build()
        .await?;

    // Query within tenant
    let tenant_orders = orders
        .query("SELECT * FROM orders WHERE tenantId = @tenant")
        .param("tenant", "acme-corp")
        .execute()
        .await?;

    // Query specific user
    let user_orders = orders
        .query("SELECT * FROM orders WHERE tenantId = @tenant AND userId = @user")
        .param("tenant", "acme-corp")
        .param("user", "user456")
        .execute()
        .await?;

    Ok(())
}

๐Ÿ“Š Use Cases

๐ŸŽฎ Game Development

  • Player profiles and session data
  • Leaderboards and rankings
  • In-game chat and social features
  • Real-time matchmaking queues
  • 5-10ms latency for Brazilian players

๐Ÿค– AI/Chat/RAG Applications

  • Chat history with vector embeddings
  • User context and memory
  • Semantic search for retrieval
  • Multi-user isolation
  • Native vector search (no extra services)

๐Ÿ›’ E-commerce

  • Product catalogs
  • Shopping carts
  • Order management
  • User profiles and wishlists
  • Real-time inventory

๐Ÿ“ก IoT & Scientific

  • Sensor data ingestion
  • Device twins and profiles
  • Time-series storage
  • Telemetry aggregation
  • LIGO/LISA data storage

๐Ÿ†š Comparison with Competitors

Feature AvilaDB AWS DynamoDB Azure Cosmos DB
Max document size 4 MB โœ… 400 KB 2 MB
Partition size 50 GB โœ… 10 GB 20 GB
Multi-region writes FREE โœ… Extra cost Extra cost
Vector search Native โœ… Requires OpenSearch Limited
Brazil latency 5-10ms โœ… 80-120ms 40-60ms
Pricing (1M ops) R$ 0,50 โœ… USD 1.25 USD 0.85
Storage (GB/month) R$ 0,20 โœ… USD 0.25 USD 0.25

AvilaDB is 40-60% cheaper for Brazilian workloads! ๐Ÿ‡ง๐Ÿ‡ท


๐Ÿ› ๏ธ Best Practices

Data Modeling

// โœ… GOOD: Embed related data
let user = Document::new()
    .set("userId", "user123")
    .set("profile", json!({
        "name": "Joรฃo Silva",
        "email": "joao@example.com"
    }))
    .set("preferences", json!({
        "theme": "dark",
        "language": "pt-BR"
    }));

// โŒ BAD: Too many separate documents for always-together data
// users -> profiles -> preferences (3 queries instead of 1)

Partition Key Choice

// โœ… GOOD: High cardinality, even distribution
.partition_key("userId")  // userId, tenantId, deviceId, sessionId

// โŒ BAD: Low cardinality, hot partitions
.partition_key("status")  // "active", "inactive" (only 2 values!)

Diagnostics

// Log diagnostic info when latency is high
let result = players.query("SELECT * FROM players")
    .execute()
    .await?;

if result.latency_ms() > 100 {
    tracing::warn!(
        "High latency: {} ms\nDiagnostics: {}",
        result.latency_ms(),
        result.diagnostics()
    );
}

๐Ÿงช Development Tools

CLI

# Connect to account
avila db connect --account my-account

# List databases
avila db list

# Query interactively
avila db query "SELECT * FROM users LIMIT 10"

# Create collection
avila db create-collection players --partition-key userId

# Import data
avila db import players data.json

# Export data
avila db export players --output backup.json

Emulator

# Run locally (no cloud costs!)
docker run -p 8000:8000 avilacloud/aviladb-emulator:latest

# Update connection string
export AVILADB_ENDPOINT=http://localhost:8000

๐Ÿ“š Documentation


๐Ÿ›๏ธ Philosophy - The Data Citadel

AvilaDB embodies the Arxis philosophy:

๐Ÿ›๏ธ ARX - Fortress

  • Solid storage: ACID transactions, durability guarantees
  • Protection: Encryption at rest and in transit
  • Reliability: Multi-region replication, automatic backups

โš™๏ธ AXIS - Engine

  • Query power: Fast SQL-like queries, vector search
  • Scalability: Elastic throughput units, auto-scaling
  • Performance: Optimized for Brazil and LATAM

๐Ÿ‡ง๐Ÿ‡ท Built for Brazil

  • Local presence: Data centers in Sรฃo Paulo, Rio
  • Low latency: 5-10ms for Brazilian users
  • Fair pricing: R$ instead of USD, 40-60% cheaper
  • Portuguese-first: Docs, support, community

๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/awesome-feature)
  3. Commit your changes (git commit -m 'Add awesome feature')
  4. Push to the branch (git push origin feature/awesome-feature)
  5. Open a Pull Request

๐Ÿ“ž Support

Email: nicolas@avila.inc WhatsApp: +55 17 99781-1471 GitHub: https://github.com/avilaops/arxis Docs: https://docs.avila.cloud/aviladb


๐Ÿ“œ License

Dual-licensed under MIT OR Apache-2.0 - See LICENSE-MIT and LICENSE-APACHE for details.


๐Ÿ›๏ธ Built by Avila

AvilaDB - The Distributed Fortress Part of the AVL Cloud Platform

๐Ÿ›๏ธ Solid as a fortress โš™๏ธ Fast as an engine ๐Ÿ‡ง๐Ÿ‡ท Built for Brazil

Built with โค๏ธ in Rust for the Brazilian and LATAM tech community.

Commit count: 0

cargo fmt