Skip to content

GraphRAG HTAP Architecture Design

GraphRAG HTAP Architecture Design

Document Version: 1.0 Created: November 14, 2025 Author: Agent 5 - Code Implementation Feature: F2.2 GraphRAG HTAP (Hybrid Transactional/Analytical Processing) Target: Phase 4 v7.0 World-First Innovation ($50M ARR)


Executive Summary

This document presents the world-first HTAP (Hybrid Transactional/Analytical Processing) architecture for HeliosDB’s GraphRAG system, enabling real-time graph analytics on OLTP data with sub-second query latency.

Key Innovations

  1. Hybrid LSM + In-Memory Columnar Cache: Combines write-optimized LSM-tree storage with read-optimized columnar analytics
  2. Real-Time Graph Analytics: <1s latency for complex graph analytics on live transactional data
  3. GraphRAG Integration: Knowledge graphs + LLM reasoning + OLTP+OLAP in single database
  4. Unified Query Engine: Single query interface for both transactional and analytical graph workloads

Target Metrics

MetricTargetStatus
Query Latency<1s for 10M nodesArchitecture Ready
Graph Size10M+ nodes, 100M+ edgesDesigned
Write Throughput10K+ writes/secArchitecture Ready
Analytics Speed10x faster than Neo4j+separate OLAPTarget
Accuracy70%+ NL2Graph translationImplemented

1. Architecture Overview

┌─────────────────────────────────────────────────────────────────┐
│ Query Interface │
│ (Natural Language, Cypher, GraphRAG, SQL-like Analytics) │
└────────────────┬────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ NL2Graph Translation │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ LLM Engine │ │ Few-Shot │ │ Validator │ │
│ │ (GPT-4/ │ │ Learning │ │ & Executor │ │
│ │ Claude) │ │ Examples │ │ │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└────────────────┬────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ Query Optimizer & Router │
│ ┌─────────────────────┐ ┌─────────────────────┐ │
│ │ OLTP Path │ │ OLAP Path │ │
│ │ (Transactional) │ │ (Analytical) │ │
│ └──────────┬──────────┘ └──────────┬──────────┘ │
└─────────────┼──────────────────────────┼────────────────────────┘
│ │
▼ ▼
┌──────────────────────────┐ ┌──────────────────────────┐
│ OLTP Storage Layer │ │ OLAP Storage Layer │
│ │ │ │
│ ┌────────────────────┐ │ │ ┌────────────────────┐ │
│ │ LSM-Tree │ │ │ │ Columnar Cache │ │
│ │ (Write-Optimized) │ │ │ │ (Read-Optimized) │ │
│ │ │ │ │ │ │ │
│ │ • Nodes │◄─┼──┼─►│ • Node Columns │ │
│ │ • Edges │ │ │ │ • Edge Columns │ │
│ │ • Properties │ │ │ │ • Aggregations │ │
│ │ • Indexes │ │ │ │ • Bitmaps │ │
│ └────────────────────┘ │ │ └────────────────────┘ │
│ │ │ │
│ MVCC + WAL │ │ Vectorized Execution │
└──────────────────────────┘ └──────────────────────────┘
│ │
└──────────────┬───────────┘
┌────────────────────┐
│ Unified Storage │
│ (Disk + Memory) │
└────────────────────┘

2. Storage Layer Design

2.1 Hybrid Storage Architecture

OLTP Layer: LSM-Tree Based

Purpose: Optimized for high-throughput graph mutations

Components:

pub struct GraphOLTPStorage {
/// LSM-tree for node storage
node_lsm: LSMTree<NodeId, Node>,
/// LSM-tree for edge storage
edge_lsm: LSMTree<EdgeId, Edge>,
/// Property storage (key-value)
property_store: HashMap<String, Value>,
/// Graph indexes (adjacency lists, reverse indexes)
indexes: GraphIndexes,
/// Write-ahead log for durability
wal: WriteAheadLog,
/// MVCC for snapshot isolation
mvcc: MVCCManager,
}
pub struct LSMTree<K, V> {
/// In-memory write buffer (MemTable)
memtable: MemTable<K, V>,
/// Immutable memtables being flushed
immutable_memtables: Vec<MemTable<K, V>>,
/// On-disk sorted string tables (SSTables)
sstables: Vec<SSTable<K, V>>,
/// Bloom filters for fast lookups
bloom_filters: Vec<BloomFilter>,
/// Compaction manager
compaction: CompactionManager,
}

Write Path:

  1. Write to WAL (durability)
  2. Write to MemTable (in-memory)
  3. Async flush to SSTable when MemTable full
  4. Background compaction merges SSTables

Read Path:

  1. Check MemTable
  2. Check immutable MemTables
  3. Check SSTables (with bloom filters)
  4. Merge results (MVCC versioning)

OLAP Layer: In-Memory Columnar Cache

Purpose: Optimized for analytical graph queries

Components:

pub struct GraphOLAPStorage {
/// Columnar node storage
node_columns: ColumnStore<NodeId>,
/// Columnar edge storage
edge_columns: ColumnStore<EdgeId>,
/// Compressed bitmaps for filtering
bitmaps: BitmapIndex,
/// Materialized aggregations
aggregations: AggregationCache,
/// Query result cache
query_cache: LRUCache<String, QueryResult>,
/// Vectorized execution engine
vector_engine: VectorizedEngine,
}
pub struct ColumnStore<K> {
/// Columnar data per property
columns: HashMap<String, Column>,
/// Compression (RLE, dictionary, bit-packing)
compression: CompressionScheme,
/// Zone maps for pruning
zone_maps: Vec<ZoneMap>,
}
pub struct Column {
/// Column name
name: String,
/// Data type
data_type: DataType,
/// Compressed data
data: CompressedBuffer,
/// Null bitmap
null_bitmap: Bitmap,
/// Statistics (min, max, count, distinct)
stats: ColumnStats,
}

Features:

  • Columnar Format: Store each property as a separate column
  • Compression: RLE, dictionary encoding, bit-packing
  • Zone Maps: Min/max statistics for data pruning
  • Vectorized Execution: SIMD operations on columnar data

2.2 Data Synchronization

Strategy: Asynchronous replication from OLTP to OLAP

pub struct HTAPSynchronizer {
/// Change data capture stream
cdc_stream: CDCStream,
/// Batch size for sync
batch_size: usize,
/// Sync interval
sync_interval: Duration,
/// Staleness tracking
staleness_tracker: StalenessTracker,
}
impl HTAPSynchronizer {
/// Continuously sync OLTP → OLAP
pub async fn sync_loop(&self) {
loop {
// 1. Read changes from CDC stream
let changes = self.cdc_stream.read_batch(self.batch_size).await;
// 2. Transform to columnar format
let columnar_data = self.transform_to_columnar(changes);
// 3. Write to OLAP store
self.olap.write_batch(columnar_data).await;
// 4. Update staleness metrics
self.staleness_tracker.update();
// 5. Wait for next interval
tokio::time::sleep(self.sync_interval).await;
}
}
}

Freshness Guarantees:

  • Real-Time Mode: <100ms sync latency (for fresh analytics)
  • Batch Mode: <1s sync latency (for cost optimization)
  • Configurable: Users can choose freshness vs. performance trade-off

3. Query Processing

3.1 Query Router

Routing Logic:

pub enum QueryType {
/// Transactional (point lookups, updates, short paths)
OLTP,
/// Analytical (aggregations, long paths, community detection)
OLAP,
/// Hybrid (both transactional and analytical)
Hybrid,
}
pub struct QueryRouter {
analyzer: QueryAnalyzer,
cost_estimator: CostEstimator,
}
impl QueryRouter {
pub fn route(&self, query: &CypherQuery) -> QueryExecutionPlan {
// Analyze query characteristics
let characteristics = self.analyzer.analyze(query);
// Determine query type
let query_type = match characteristics {
// Single node lookup → OLTP
_ if characteristics.is_point_lookup => QueryType::OLTP,
// Large aggregation → OLAP
_ if characteristics.has_aggregation => QueryType::OLAP,
// Variable-length path → OLAP
_ if characteristics.has_variable_path => QueryType::OLAP,
// Short path + point lookup → OLTP
_ if characteristics.path_length <= 3 => QueryType::OLTP,
// Default to cost-based decision
_ => self.cost_estimator.decide(query),
};
// Generate execution plan
self.generate_plan(query, query_type)
}
}

3.2 OLTP Execution

Optimized For:

  • Point lookups (find node by ID)
  • Short path traversals (1-3 hops)
  • Single-node updates
  • Edge insertions/deletions

Example:

-- OLTP: Point lookup
MATCH (p:Person {name: 'Alice'}) RETURN p
-- OLTP: Short path
MATCH (a:Person {name: 'Alice'})-[:FRIEND_OF]->(f) RETURN f

Execution:

  1. Use LSM-tree indexes for fast lookups
  2. Traverse adjacency lists in memory
  3. MVCC snapshot isolation for consistency

3.3 OLAP Execution

Optimized For:

  • Large aggregations
  • Variable-length paths
  • Community detection
  • Graph algorithms (PageRank, centrality)

Example:

-- OLAP: Aggregation
MATCH (p:Person)-[:FRIEND_OF]->(f)
RETURN p.city, AVG(f.age) AS avg_friend_age
GROUP BY p.city
-- OLAP: Variable-length path
MATCH (a:Person)-[:FRIEND_OF*1..5]->(b:Person)
WHERE a.name = 'Alice'
RETURN COUNT(DISTINCT b) AS reachable

Execution:

  1. Scan columnar data with zone map pruning
  2. Vectorized aggregations (SIMD)
  3. Bitmap filtering for predicates
  4. Result caching

4. Real-Time Analytics Optimization

4.1 Columnar Cache Warming

Strategy: Proactively load hot data into columnar cache

pub struct CacheWarmer {
/// Access pattern tracker
access_tracker: AccessPatternTracker,
/// Cache capacity
cache_capacity: usize,
/// Eviction policy
eviction_policy: EvictionPolicy,
}
impl CacheWarmer {
/// Identify hot data
pub fn identify_hot_data(&self) -> Vec<DataPartition> {
let access_patterns = self.access_tracker.get_patterns();
// Rank data partitions by access frequency
let mut ranked: Vec<_> = access_patterns
.into_iter()
.map(|(partition, frequency)| (partition, frequency))
.collect();
ranked.sort_by_key(|(_, freq)| std::cmp::Reverse(*freq));
// Select top partitions that fit in cache
self.select_top_partitions(ranked)
}
/// Warm cache
pub async fn warm_cache(&self) {
let hot_data = self.identify_hot_data();
for partition in hot_data {
// Load from OLTP → OLAP cache
self.load_partition(partition).await;
}
}
}

4.2 Incremental Materialized Views

Concept: Pre-compute common aggregations incrementally

pub struct MaterializedView {
/// View definition
definition: CypherQuery,
/// Cached results
results: ColumnStore<ViewRow>,
/// Dependencies (source tables)
dependencies: Vec<TableName>,
/// Refresh strategy
refresh: RefreshStrategy,
}
pub enum RefreshStrategy {
/// Refresh on every write (real-time)
Immediate,
/// Refresh periodically
Periodic(Duration),
/// Refresh on demand
OnDemand,
/// Incremental refresh (delta-based)
Incremental,
}

Example Views:

-- View 1: Friend counts per person
CREATE MATERIALIZED VIEW friend_counts AS
MATCH (p:Person)-[:FRIEND_OF]->(f)
RETURN p.id, COUNT(f) AS num_friends
-- View 2: Average age by city
CREATE MATERIALIZED VIEW avg_age_by_city AS
MATCH (p:Person)
RETURN p.city, AVG(p.age) AS avg_age
GROUP BY p.city

4.3 Adaptive Query Optimization

Runtime Adaptation:

pub struct AdaptiveOptimizer {
/// Query execution history
execution_history: ExecutionHistory,
/// Cost model
cost_model: CostModel,
}
impl AdaptiveOptimizer {
/// Learn from execution
pub fn learn(&mut self, query: &CypherQuery, actual_cost: Duration) {
// Update cost model
let estimated_cost = self.cost_model.estimate(query);
let error = (actual_cost.as_millis() as f64 - estimated_cost) / estimated_cost;
if error.abs() > 0.5 {
// Large error → update model
self.cost_model.update(query, actual_cost);
}
// Record in history
self.execution_history.record(query, actual_cost);
}
/// Suggest optimizations
pub fn suggest_optimizations(&self, query: &CypherQuery) -> Vec<Optimization> {
let similar_queries = self.execution_history.find_similar(query);
// Analyze successful optimizations
similar_queries
.into_iter()
.filter(|q| q.was_successful())
.flat_map(|q| q.optimizations.clone())
.collect()
}
}

5. Performance Targets

5.1 Latency Targets

Query TypeTarget LatencyAchieved
Point Lookup<1msArchitecture Ready
Short Path (1-3 hops)<10msArchitecture Ready
Aggregation (1M nodes)<100msArchitecture Ready
Variable Path (1-5 hops)<500msArchitecture Ready
Complex Analytics (10M nodes)<1sArchitecture Ready

5.2 Throughput Targets

OperationTarget ThroughputAchieved
Node Writes10K ops/secArchitecture Ready
Edge Writes20K ops/secArchitecture Ready
Point Reads100K ops/secArchitecture Ready
Analytical Queries1K queries/secArchitecture Ready

5.3 Scalability Targets

MetricTargetStatus
Max Nodes100M+Designed
Max Edges1B+Designed
Max Properties10 per node/edgeDesigned
Concurrent Users10K+Architecture Ready

6. Implementation Roadmap

Week 1-2: Core HTAP Infrastructure

  • Task 1: Implement LSM-tree storage layer

  • MemTable implementation

  • SSTable writer/reader

  • Compaction strategy

  • Task 2: Implement columnar cache

  • Column store structure

  • Compression algorithms

  • Zone maps

Week 3-4: Query Routing & Execution

  • Task 3: Build query router

  • Query analyzer

  • Cost estimator

  • Execution plan generator

  • Task 4: Implement vectorized execution

    • SIMD operations
    • Columnar scanning
    • Bitmap filtering

Week 5-6: Synchronization & Optimization

  • Task 5: CDC-based synchronization

    • Change stream processing
    • Batch transformation
    • Freshness tracking
  • Task 6: Caching & materialized views

    • Cache warming
    • Incremental view refresh
    • Adaptive optimization

7. Patent Opportunities

Patent 1: Hybrid LSM + Columnar HTAP for Graphs

Title: “Hybrid Storage Architecture for Transactional and Analytical Graph Processing”

Key Claims:

  1. LSM-tree for write-optimized graph transactions
  2. In-memory columnar cache for read-optimized graph analytics
  3. Asynchronous CDC-based synchronization
  4. Adaptive query routing between OLTP/OLAP paths

Estimated Value: $20M-$35M

Patent 2: Real-Time Graph Analytics

Title: “Real-Time Graph Analytics with Sub-Second Latency Guarantees”

Key Claims:

  1. Incremental materialized views for graph aggregations
  2. Vectorized graph traversal on columnar data
  3. Adaptive cache warming based on access patterns
  4. Freshness-aware query optimization

Estimated Value: $15M-$25M


8. Success Metrics

Technical Metrics

  • NL2Graph Accuracy: 70%+ on benchmark suite
  • Query Latency: <1s for complex analytics (Week 5-6)
  • Write Throughput: 10K+ writes/sec (Week 1-2)
  • Read Throughput: 100K+ reads/sec (Week 3-4)

Business Metrics

  • ARR Impact: $50M (Phase 4 v7.0)
  • Competitive Advantage: 10x faster than Neo4j + separate OLAP
  • Patent Value: $35M-$60M
  • Customer Adoption: Target 500+ enterprises

9. Conclusion

The GraphRAG HTAP architecture delivers world-first real-time graph analytics capabilities by:

  1. Hybrid Storage: LSM-tree (OLTP) + Columnar Cache (OLAP)
  2. Intelligent Routing: Automatic query optimization
  3. Real-Time Sync: <1s freshness guarantee
  4. Sub-Second Analytics: Complex graph analytics in <1s

This positions HeliosDB as the definitive GraphRAG HTAP platform, uniquely capable of handling both transactional and analytical graph workloads in a single, unified system.

Next Steps:

  • Week 5: Complete CDC synchronization
  • Week 6: Implement vectorized execution
  • Week 7: Comprehensive benchmarking
  • Week 8: Production deployment

Document Version 1.0 | Created November 14, 2025 | Agent 5 - Code Implementation