|
2 | 2 |
|
3 | 3 | Graph repository implementations for the LiteGraph library, providing persistent storage backends for graph data structures. |
4 | 4 |
|
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```csharp |
| 8 | +// Option 1: DuckDB (SQL-based, best for analytics) |
| 9 | +var duckDb = new DuckDBGraphRepository("Data Source=mydb.duckdb"); |
| 10 | +duckDb.InitializeRepository(); |
| 11 | + |
| 12 | +// Option 2: FastDB (NoSQL, best for performance) |
| 13 | +var fastDb = new FastDBGraphRepository("./mydb.fastdb", |
| 14 | + new FastDBOptions { Serializer = SerializerType.MessagePack_Contract }); |
| 15 | +fastDb.InitializeRepository(); |
| 16 | + |
| 17 | +// Use either repository through the same LiteGraph interfaces |
| 18 | +var tenant = await repository.Tenant.Create(new TenantMetadata |
| 19 | +{ |
| 20 | + GUID = Guid.NewGuid(), |
| 21 | + Name = "My Tenant" |
| 22 | +}); |
| 23 | +``` |
| 24 | + |
5 | 25 | ## Overview |
6 | 26 |
|
7 | 27 | This library provides concrete implementations of the LiteGraph `GraphRepositoryBase` abstract class, enabling you to store and query graph data using various database backends. |
8 | 28 |
|
| 29 | +## Comparison Table |
| 30 | + |
| 31 | +| Feature | DuckDBGraphRepository | FastDBGraphRepository | LiteDBGraphRepository | |
| 32 | +|---------|----------------------|----------------------|----------------------| |
| 33 | +| **Storage Type** | SQL (Columnar) | NoSQL (Key-Value Collections) | NoSQL (Document) | |
| 34 | +| **Best For** | Analytics, Complex Queries | Simple CRUD, High Performance | General Purpose | |
| 35 | +| **ACID Compliance** | ✅ Full | ⚠️ Limited | ✅ Full | |
| 36 | +| **Schema Required** | ✅ Yes | ❌ No | ❌ No | |
| 37 | +| **Backup Support** | ✅ Native | ⚠️ Manual | ⚠️ Pending | |
| 38 | +| **In-Memory Mode** | ✅ Yes | ❌ No | ✅ Yes | |
| 39 | +| **Serialization** | SQL | MessagePack/JSON/Binary | BSON | |
| 40 | +| **File Size** | Large | Small | Medium | |
| 41 | +| **Query Performance** | Excellent (SQL) | Very Fast (Direct Key Access) | Good (Indexed) | |
| 42 | +| **Setup Complexity** | Medium | Low | Low | |
| 43 | + |
| 44 | +## When to Use Each Implementation |
| 45 | + |
| 46 | +- **DuckDBGraphRepository**: Choose when you need complex analytical queries, reporting, or data warehousing capabilities. Best for read-heavy workloads with complex joins and aggregations. |
| 47 | + |
| 48 | +- **FastDBGraphRepository**: Choose when you need lightweight embedded storage with simple key-based access patterns. Best for write-heavy workloads, caching, or when storage size is a concern. |
| 49 | + |
| 50 | +- **LiteDBGraphRepository**: *(Coming soon)* General-purpose document storage with indexing and LINQ query support. |
| 51 | + |
9 | 52 | ## Available Implementations |
10 | 53 |
|
11 | 54 | ### DuckDBGraphRepository |
@@ -178,6 +221,51 @@ Note: Most CRUD operations currently throw `NotImplementedException` and require |
178 | 221 |
|
179 | 222 | *(Documentation pending)* |
180 | 223 |
|
| 224 | +## Architecture |
| 225 | + |
| 226 | +All repository implementations follow a common pattern: |
| 227 | + |
| 228 | +``` |
| 229 | +GraphRepositoryBase (abstract) |
| 230 | +├── DuckDBGraphRepository |
| 231 | +│ ├── AdminMethods (IAdminMethods) |
| 232 | +│ ├── TenantMethods (ITenantMethods) |
| 233 | +│ ├── UserMethods (IUserMethods) |
| 234 | +│ ├── CredentialMethods (ICredentialMethods) |
| 235 | +│ ├── LabelMethods (ILabelMethods) |
| 236 | +│ ├── TagMethods (ITagMethods) |
| 237 | +│ ├── VectorMethods (IVectorMethods) |
| 238 | +│ ├── GraphMethods (IGraphMethods) |
| 239 | +│ ├── NodeMethods (INodeMethods) |
| 240 | +│ ├── EdgeMethods (IEdgeMethods) |
| 241 | +│ ├── BatchMethods (IBatchMethods) |
| 242 | +│ └── VectorIndexMethods (IVectorIndexMethods) |
| 243 | +│ |
| 244 | +├── FastDBGraphRepository |
| 245 | +│ └── (same interface structure) |
| 246 | +│ |
| 247 | +└── LiteDBGraphRepository |
| 248 | + └── (same interface structure) |
| 249 | +``` |
| 250 | + |
| 251 | +Each implementation provides the same 12 interface implementations, ensuring consistent API across all storage backends. |
| 252 | + |
| 253 | +## Performance Considerations |
| 254 | + |
| 255 | +### DuckDB |
| 256 | +- Optimized for analytical queries and aggregations |
| 257 | +- Best performance with columnar data access patterns |
| 258 | +- In-memory mode provides fastest query execution |
| 259 | +- Batch inserts significantly faster than individual inserts |
| 260 | +- Consider using COPY statements for bulk data loading |
| 261 | + |
| 262 | +### FastDB |
| 263 | +- Ultra-fast key-based lookups (O(1) complexity) |
| 264 | +- MessagePack serialization reduces I/O overhead |
| 265 | +- Best for single-entity CRUD operations |
| 266 | +- Limited support for complex queries across collections |
| 267 | +- Auto-flush may impact write-heavy workload performance |
| 268 | + |
181 | 269 | ## Installation |
182 | 270 |
|
183 | 271 | ```bash |
@@ -211,6 +299,24 @@ All 24 tests validate: |
211 | 299 | - Resource disposal |
212 | 300 | - Implementation-specific features (backup, serialization, etc.) |
213 | 301 |
|
| 302 | +## Roadmap |
| 303 | + |
| 304 | +### Current Status (v1.0) |
| 305 | +- ✅ DuckDB implementation with SQL storage |
| 306 | +- ✅ FastDB implementation with NoSQL collections |
| 307 | +- ✅ 24 passing unit tests |
| 308 | +- ✅ Basic repository lifecycle management |
| 309 | + |
| 310 | +### Planned Features |
| 311 | +- 🔄 Complete CRUD operation implementations for all entities |
| 312 | +- 🔄 LiteDB implementation |
| 313 | +- 🔄 Advanced query support (filtering, pagination, sorting) |
| 314 | +- 🔄 Transaction support across repositories |
| 315 | +- 🔄 Migration tools between storage backends |
| 316 | +- 🔄 Performance benchmarking suite |
| 317 | +- 🔄 Vector similarity search implementation |
| 318 | +- 🔄 Graph traversal algorithms |
| 319 | + |
214 | 320 | ## Contributing |
215 | 321 |
|
216 | 322 | Contributions are welcome! Please ensure all tests pass before submitting pull requests. |
|
0 commit comments