⚠️ UNDER HEAVY CONSTRUCTION⚠️
This project is currently undergoing major development and refactoring. Features, APIs, and documentation may change rapidly. Please check back regularly for updates.
A high-performance, embedded, GraphQL-native database engine written in C# for .NET 9+. Define your database schema in GraphQL SDL, load data from JSON files, and query with native GraphQL - all without writing any C# table definition code.
** Prototype Status**: This is an experimental database engine. While it has comprehensive features and passes all tests, it's not yet ready for production use. Use for research, prototyping, and educational purposes.
- Quick Start
- Key Features
- Documentation
- Architecture
- SharpGraph IDE
- Performance
- Examples
- Project Structure
- Contributing
- License
- ⚡ Quick Start - Get up and running in 5 minutes with Star Wars example
- Getting Started Guide - Installation and quick start tutorials
- Filtering & Sorting Guide - Prisma-style filtering, sorting, pagination with Star Wars examples
- 🚀 Dynamic Indexing - Automatic query optimization through intelligent index creation
- Features - Schema-driven development, GraphQL support, storage engine
- Configuration - Database configuration and settings
- API Reference - Complete API documentation
- Examples - Code examples and tutorials
- Performance - Benchmarks and optimization guide
- Indexing - Index types and performance tuning
- Storage - Storage engine architecture and internals
- Relationships - Working with GraphQL relationships
- Development - Building, testing, contributing
- Roadmap - Current status, planned features, known limitations
- Troubleshooting - Common issues and solutions
- Architecture Overview - Detailed technical architecture
# schema.graphql
type User {
id: ID!
name: String!
email: String!
posts: [Post]
}
type Post {
id: ID!
title: String!
content: String!
author: User
}using SharpGraph.Core;
using SharpGraph.Core.GraphQL;
var dbPath = "my_database";
var executor = new GraphQLExecutor(dbPath);
var loader = new SchemaLoader(dbPath, executor);
// Load schema and data
loader.LoadSchemaFromFile("schema.graphql");
loader.LoadData(File.ReadAllText("data.json"));
// Query with relationships
var result = executor.Execute(@"{
users {
name
posts { title }
}
}");SharpGraph supports Prisma-style filtering and sorting through Connection types. This provides an intuitive, GraphQL-native way to query and sort data.
Filter records using field-level conditions:
query SearchCharacters {
characters {
items(where: {name: {contains: "Luke"}}) {
id
name
characterType
}
}
}Available filter operators:
equals: Exact matchcontains: String contains (case-insensitive)startsWith: String starts withendsWith: String ends withgt: Greater than (for numbers)lt: Less than (for numbers)gte: Greater than or equallte: Less than or equal
Combined filters with AND/OR/NOT:
query FindHumans {
characters {
items(where: {
AND: [
{characterType: {equals: "Human"}}
{name: {contains: "Solo"}}
]
}) {
id
name
characterType
}
}
}Sort by one or multiple fields using Prisma's intuitive syntax:
query SortedCharacters {
characters {
items(orderBy: [{name: asc}]) {
id
name
characterType
}
}
}Multiple sort fields (applied in order):
query MultiSortCharacters {
characters {
items(orderBy: [{characterType: asc}, {name: asc}]) {
id
name
characterType
height
}
}
}Paginate through results:
query PaginatedCharacters {
characters {
items(skip: 0, take: 10) {
id
name
characterType
}
}
}query AdvancedQuery {
characters {
items(
where: {characterType: {equals: "Human"}}
orderBy: [{name: asc}]
skip: 0
take: 5
) {
id
name
characterType
height
mass
}
}
}SharpGraph automatically generates Create, Update, and Delete mutations for every entity in your schema. No configuration needed!
mutation CreateCharacter {
createCharacter(input: {
name: "Luke Skywalker"
characterType: "Human"
appearsIn: ["NEWHOPE", "EMPIRE", "JEDI"]
height: 172.72
mass: 77.0
hairColor: "Blond"
skinColor: "Fair"
eyeColor: "Blue"
birthYear: "19BBY"
homePlanetId: "tatooine"
}) {
id
name
characterType
}
}mutation UpdateCharacter {
updateCharacter(
id: "luke"
input: {
name: "Luke Skywalker (Updated)"
height: 173.0
}
) {
id
name
height
}
}mutation DeleteCharacter {
deleteCharacter(id: "luke")
}mutation CreateMultiple {
c1: createCharacter(input: {
name: "Character 1"
characterType: "Human"
}) {
id
name
}
c2: createCharacter(input: {
name: "Character 2"
characterType: "Droid"
}) {
id
name
}
}# Create
mutation {
createFilm(input: {
title: "A New Hope"
episodeId: 4
openingCrawl: "It is a period of civil war..."
director: "George Lucas"
producer: "Gary Kurtz"
releaseDate: "1977-05-25"
}) {
id
title
}
}
# Read with Filtering
query {
films {
items(where: {title: {contains: "Hope"}}) {
id
title
episodeId
}
}
}
# Update
mutation {
updateFilm(id: "1", input: {
title: "Star Wars: Episode IV - A New Hope"
}) {
id
title
}
}
# Delete
mutation {
deleteFilm(id: "1")
}- ** Schema-Driven**: Define your database with GraphQL SDL - no C# classes needed
- ** High Performance**: Hash indexes (O(1)), B-tree indexes (O(log n)), LRU page cache
- ** Relationships**: Automatic foreign key resolution with batch loading (N+1 prevention)
- ** Embedded Database**: No separate server process required
- ** Page-Based Storage**: 4KB pages with MessagePack serialization
- ** Full GraphQL Support**: Queries, mutations, introspection, fragments
- ** Zero Boilerplate**: Automatic table creation from schema types
- Getting Started Guide - Installation and quick start tutorials
- SharpGraph IDE - Web-based administration interface
- Examples - Star Wars, Blog, E-Commerce, and Social Network examples
- Features - Schema-driven development, GraphQL support, storage engine
- Architecture - System design, components, and data flow
- Storage System - Page-based storage, MemTable, file format
- Indexing - Hash indexes, B-tree indexes, performance impact
- Relationships - Foreign keys, relationship types, query resolution
- Performance - Benchmarks, tuning, optimization tips
- Configuration - Database options, server settings, performance tuning
- API Reference - Complete API documentation
- Troubleshooting - Common issues and solutions
- Development Guide - Building, testing, contributing
- Roadmap - Current status, planned features, known limitations
SharpGraph is built as a layered architecture:
graph TB
subgraph "GraphQL Layer"
A[Lexer] --> B[Parser]
B --> C[Executor]
end
subgraph "Schema Layer"
D[Schema Parser] --> E[Schema Loader]
end
subgraph "Indexing Layer"
F[Hash Index] --> G[B-Tree Index]
G --> H[Index Manager]
end
subgraph "Storage Layer"
I[Table] --> J[MemTable]
J --> K[Page Cache]
K --> L[FileManager]
end
C --> E
E --> H
H --> I
For detailed architecture documentation, see ARCHITECTURE.md.
| Benchmark | Average Time | Throughput |
|---|---|---|
| Single record lookup (Hash Index) | 0.40ms | 2,500 ops/sec |
| Range queries (B-Tree) | 0.15ms | 6,667 ops/sec |
| Relationship queries | 1.86ms | 537 ops/sec |
| Full table scans | 0.74ms | 1,351 ops/sec |
Test environment: Windows 11, .NET 9.0, Star Wars dataset (8 characters, 3 films, 4 planets)
See Performance Guide for detailed benchmarks and tuning options.
SharpGraph includes a comprehensive web-based administration interface built with Blazor and AdminLTE. The IDE provides a modern, intuitive interface for managing your GraphQL database.
- Dashboard: Real-time performance metrics, database statistics, and system status
- GraphQL Playground: Interactive query editor with syntax highlighting and auto-completion
- Table Management: Browse, search, and edit table data with pagination
- Schema Viewer: Visualize and manage GraphQL schema definitions
- Performance Monitoring: Query performance metrics, cache statistics, and alerts
- Data Import/Export: JSON import and export functionality
- Index Management: Create and monitor database indexes
# Run the IDE
cd src/SharpGraph.Ide
dotnet run
# Open your browser to
https://localhost:5051The IDE features a modern AdminLTE-based interface with:
- Responsive sidebar navigation
- Real-time performance dashboards
- Interactive GraphQL query playground
- Comprehensive table and data management
# Clone the repository
git clone https://github.com/your-org/sharpgraph.git
cd sharpgraph
# Build the solution
dotnet build --configuration Release
# Run tests
dotnet test
# Run examples
cd examples/StarWars
dotnet run
# Run the IDE
cd src/SharpGraph.Ide
dotnet run
# Then open https://localhost:5051Requirements:
- .NET 9.0 or later
- Windows, macOS, or Linux
- Visual Studio 2022 or VS Code (recommended)
- Prototyping: Rapid GraphQL API development
- Embedded Applications: Desktop apps, local-first software
- Testing: Mock GraphQL backends for testing
- Education: Learning GraphQL and database internals
- Research: Experimenting with database architectures
cd examples/StarWars
dotnet runQuery example:
{
character(id: "luke") {
name
height
friends {
name
}
homePlanet {
name
climate
}
}
}See Examples for more use cases including Blog, E-Commerce, and Social Network schemas.
Contributions are welcome! Please see Development Guide for:
- Building from source
- Running tests
- Code standards
- Pull request process
MIT License - see LICENSE file for details.
- GraphQL specification from GraphQL.org
- Star Wars example based on official GraphQL tutorial
- Inspired by modern database architectures (PostgreSQL, SQLite, RocksDB)
** SharpGraph - Where GraphQL meets high-performance storage!**
Built with for the .NET community