//! High-concurrency graph store for social network operations
//!
//! This module provides a sharded, high-throughput graph store designed for
//! social network workloads with high concurrent write requirements.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │                    GraphShardRouter                          │
//! │  ┌─────────────────────────────────────────────────────┐    │
//! │  │              Backpressure Controller                 │    │
//! │  └─────────────────────────────────────────────────────┘    │
//! │                           │                                  │
//! │  ┌─────────┬─────────┬─────────┬─────────┐                  │
//! │  │ Shard 0 │ Shard 1 │ Shard 2 │ Shard N │   (hash routing) │
//! │  └────┬────┴────┬────┴────┬────┴────┬────┘                  │
//! │       │         │         │         │                        │
//! │  ┌────▼────┬────▼────┬────▼────┬────▼────┐                  │
//! │  │ Queue 0 │ Queue 1 │ Queue 2 │ Queue N │   (write queues) │
//! │  └────┬────┴────┬────┴────┬────┴────┬────┘                  │
//! │       │         │         │         │                        │
//! │  ┌────▼────┬────▼────┬────▼────┬────▼────┐                  │
//! │  │  WAL 0  │  WAL 1  │  WAL 2  │  WAL N  │   (durability)   │
//! │  └────┬────┴────┬────┴────┬────┴────┬────┘                  │
//! │       │         │         │         │                        │
//! │  ┌────▼────┬────▼────┬────▼────┬────▼────┐                  │
//! │  │ Batch 0 │ Batch 1 │ Batch 2 │ Batch N │   (aggregators)  │
//! │  └────┬────┴────┬────┴────┬────┴────┬────┘                  │
//! │       │         │         │         │                        │
//! │  ┌────▼─────────▼─────────▼─────────▼────┐                  │
//! │  │           In-Memory Storage            │                  │
//! │  │   (Entities, Relations, Indices)       │                  │
//! │  └───────────────────────────────────────┘                  │
//! └─────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Features
//!
//! - **Sharding**: Distributes data across multiple shards to reduce lock contention
//! - **Write Queues**: Async queues decouple write requests from processing
//! - **WAL**: Write-ahead logging ensures data durability and crash recovery
//! - **Batch Aggregation**: Combines multiple writes for efficient processing
//! - **Backpressure**: Prevents system overload under high load
//! - **Metrics**: Real-time monitoring of write performance
//!
//! # Example
//!
//! ```ignore
//! use aifastdb_core::social::concurrent::{
//!     GraphShardRouter, ConcurrentGraphConfig,
//! };
//! use aifastdb_core::types::graph::{Entity, Relation, entity_types};
//!
//! #[tokio::main]
//! async fn main() {
//!     // Create router with default config
//!     let config = ConcurrentGraphConfig::new("data/social")
//!         .with_shard_count(8)
//!         .high_throughput();
//!     
//!     let router = GraphShardRouter::new(config);
//!     
//!     // Add entities
//!     let alice = Entity::new("Alice", entity_types::PERSON);
//!     let bob = Entity::new("Bob", entity_types::PERSON);
//!     
//!     router.put_entity(alice.clone()).await.unwrap();
//!     router.put_entity(bob.clone()).await.unwrap();
//!     
//!     // Add relation
//!     let relation = Relation::new(&alice.id, &bob.id, "friend");
//!     router.put_relation(relation).await.unwrap();
//!     
//!     // Query
//!     let friends = router.outgoing_from(&alice.id);
//!     println!("Alice's friends: {:?}", friends);
//! }
//! ```
//!
//! # Performance Targets
//!
//! | Metric | Target |
//! |--------|--------|
//! | Write throughput | 20,000+ ops/sec |
//! | Write latency P99 | < 10ms |
//! | Max concurrent writes | 25,000+ |

pub mod types;
pub mod config;
pub mod shard;
pub mod router;
pub mod wal;
pub mod global_index;

#[cfg(test)]
mod shard_tests;

#[cfg(test)]
mod router_tests;

#[cfg(test)]
mod wal_tests;

#[cfg(test)]
mod concurrent_tests;

#[cfg(test)]
mod stress_tests;

#[cfg(test)]
mod tuning_tests;

// Re-export main types
pub use types::{
    GraphWriteOp,
    GraphWriteRequest,
    GraphWriteResult,
    GraphWriteBatch,
    GraphStoreError,
};

pub use config::{
    ConcurrentGraphConfig,
    GraphShardConfig,
    ShardStrategy,
};

pub use shard::GraphShard;
pub use router::GraphShardRouter;

pub use wal::{
    GraphWALConfig,
    GraphWALWriter,
    GraphWALReader,
    GraphWALEntry,
    GraphWALOperation,
    GraphRecoveryResult,
    GraphCompactResult,
};

pub use global_index::{
    GlobalGraphIndex,
    GlobalIndexConfig,
    GlobalIndexStats,
    CrossShardRef,
    IndexIntegrity,
    IndexIntegrityResult,
    INDEX_SCHEMA_VERSION,
};

// Re-export commonly used types from storage::concurrent
pub use crate::storage::concurrent::{
    WriteMetrics,
    MetricsSnapshot,
    BackpressureController,
    BackpressureConfig,
    BackpressureAction,
    WriteQueueConfig,
    batch_aggregator::BatchConfig,
};

// Re-export SyncMode for WAL configuration
pub use crate::storage::wal::SyncMode;
