{"id":25301538,"url":"https://github.com/litegraphdb/litegraph","last_synced_at":"2025-07-23T09:36:02.666Z","repository":{"id":76080533,"uuid":"327791489","full_name":"litegraphdb/litegraph","owner":"litegraphdb","description":"Lightweight graph database with relational and vector support built using Sqlite, designed to power knowledge and artificial intelligence persistence and retrieval.","archived":false,"fork":false,"pushed_at":"2025-07-22T03:13:18.000Z","size":19935,"stargazers_count":65,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-22T05:24:04.768Z","etag":null,"topics":["ai","arangodb","database","gexf","graph","llm","neo4j","neptune","tigergraph","titan","vector","vector-database"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/litegraphdb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-01-08T03:44:41.000Z","updated_at":"2025-07-22T03:13:22.000Z","dependencies_parsed_at":"2024-12-18T15:08:03.021Z","dependency_job_id":"a6facd1d-2217-407f-9bf3-8a302092df04","html_url":"https://github.com/litegraphdb/litegraph","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"b0bd20064ef3527a6a6da46dc400973d4e2c0ed9"},"previous_names":["litegraphdb/litegraph","jchristn/litegraph"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/litegraphdb/litegraph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litegraphdb%2Flitegraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litegraphdb%2Flitegraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litegraphdb%2Flitegraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litegraphdb%2Flitegraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/litegraphdb","download_url":"https://codeload.github.com/litegraphdb/litegraph/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litegraphdb%2Flitegraph/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266495239,"owners_count":23938493,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","arangodb","database","gexf","graph","llm","neo4j","neptune","tigergraph","titan","vector","vector-database"],"created_at":"2025-02-13T06:13:02.573Z","updated_at":"2025-07-23T09:36:02.643Z","avatar_url":"https://github.com/litegraphdb.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/jchristn/LiteGraph/blob/main/assets/favicon.png\" width=\"256\" height=\"256\"\u003e\n\n# LiteGraph\n\n[![NuGet Version](https://img.shields.io/nuget/v/LiteGraph.svg?style=flat)](https://www.nuget.org/packages/LiteGraph/) [![NuGet](https://img.shields.io/nuget/dt/LiteGraph.svg)](https://www.nuget.org/packages/LiteGraph) \n\nLiteGraph is a property graph database with support for graph relationships, tags, labels, metadata, data, and vectors.  LiteGraph is intended to be a unified database for providing persistence and retrieval for knowledge and artificial intelligence applications.\n\nLiteGraph can be run in-process (using `LiteGraphClient`) or as a standalone RESTful server (using `LiteGraph.Server`).\n\n## New in v4.0.x\n\n- Major internal refactor for both the graph repository base and the client class\n- Separation of responsibilities; graph repository base owns primitives, client class owns validation and cross-cutting\n- Consistency in interface API names and behaviors\n- Consistency in passing of query parameters such as skip to implementations and primitives\n- Consolidation of create, update, and delete actions within a single transaction\n- Batch APIs for creation and deletion of labels, tags, vectors, edges, and nodes\n- Enumeration APIs\n- Statistics APIs\n- Simple database caching to offload existence validation for tenants, graphs, nodes, and edges\n- In-memory operation with controlled flushing to disk\n- Dependency updates and bug fixes\n- Minor Postman fixes\n\n## Bugs, Feedback, or Enhancement Requests\n\nPlease feel free to start an issue or a discussion!\n\n## Simple Example, Embedded \n\nEmbedding LiteGraph into your application is simple and requires no configuration of users or credentials.  Refer to the ```Test``` project for a full example.\n\n```csharp\nusing LiteGraph;\n\nLiteGraphClient graph = new LiteGraphClient(new SqliteRepository(\"litegraph.db\"));\ngraph.InitializeRepository();\n\n// Create a tenant\nTenantMetadata tenant = graph.CreateTenant(new TenantMetadata { Name = \"My tenant\" });\n\n// Create a graph\nGraph graph = graph.CreateGraph(new Graph { TenantGUID = tenant.GUID, Name = \"This is my graph!\" });\n\n// Create nodes\nNode node1 = graph.CreateNode(new Node { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, Name = \"node1\" });\nNode node2 = graph.CreateNode(new Node { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, Name = \"node2\" });\nNode node3 = graph.CreateNode(new Node { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, Name = \"node3\" });\n\n// Create edges\nEdge edge1 = graph.CreateEdge(new Edge { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, From = node1.GUID, To = node2.GUID, Name = \"Node 1 to node 2\" });\nEdge edge2 = graph.CreateEdge(new Edge { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, From = node2.GUID, To = node3.GUID, Name = \"Node 2 to node 3\" });\n\n// Find routes\nforeach (RouteDetail route in graph.GetRoutes(\n  SearchTypeEnum.DepthFirstSearch,\n  tenant.GUID,\n  graph.GUID,\n  node1.GUID,\n  node2.GUID))\n{\n  Console.WriteLine(...);\n}\n\n// Export to GEXF file\ngraph.ExportGraphToGexfFile(tenant.GUID, graph.GUID, \"mygraph.gexf\");\n```\n\n## Simple Example, In-Memory\n\nLiteGraph can be configured to run in-memory, with a specified database filename.  If the database exists, it will be fully loaded into memory, and then **must** later be `Flush()`ed out to disk when done.  If the database does not exist, it will be created.\n\n```csharp\nusing LiteGraph;\n\nLiteGraphClient graph = new LiteGraphClient(new SqliteRepository(\"litegraph.db\", true)); // true to run in-memory\ngraph.InitializeRepository();\n\n// Create a tenant\nTenantMetadata tenant = graph.CreateTenant(new TenantMetadata { Name = \"My tenant\" });\n\n// Create a graph\nGraph graph = graph.CreateGraph(new Graph { TenantGUID = tenant.GUID, Name = \"This is my graph!\" });\n\n// Create nodes\nNode node1 = graph.CreateNode(new Node { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, Name = \"node1\" });\nNode node2 = graph.CreateNode(new Node { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, Name = \"node2\" });\nNode node3 = graph.CreateNode(new Node { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, Name = \"node3\" });\n\n// Create edges\nEdge edge1 = graph.CreateEdge(new Edge { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, From = node1.GUID, To = node2.GUID, Name = \"Node 1 to node 2\" });\nEdge edge2 = graph.CreateEdge(new Edge { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, From = node2.GUID, To = node3.GUID, Name = \"Node 2 to node 3\" });\n\n// Flush to disk\ngraph.Flush();\n```\n\n## Working with Object Labels, Tags, and Data\n\nThe `Labels` property is a `List\u003cstring\u003e` allowing you to attach labels to any `Graph`, `Node`, or `Edge`, i.e. `[ \"mylabel\" ]`.\n\nThe `Tags` property is a `NameValueCollection` allowing you to attach key-value pairs to any `Graph`, `Node`, or `Edge`, i.e. `{ \"foo\": \"bar\" }`.\n\nThe `Data` property is an `object` and can be attached to any `Graph`, `Node`, or `Edge`.  `Data` supports any object serializable to JSON.  This value is retrieved when reading or searching objects, and filters can be created to retrieve only objects that have matches based on elements in the object stored in `Data`.  Refer to [ExpressionTree](https://github.com/jchristn/ExpressionTree/) for information on how to craft expressions.\n\nThe `Vectors` property can be attached to any `Graph`, `Node`, or `Edge` object, and is a `List\u003cVectorMetadata\u003e`.  The embeddings within can be used for a variety of different vector searches (such as `CosineSimilarity`).\n\nAll of these properties can be used in conjunction with one another when filtering for retrieval.\n\n### Storing and Searching Labels\n\n```csharp\nList\u003cstring\u003e labels = new List\u003cstring\u003e \n{\n  \"test\",\n  \"label1\"\n};\n\ngraph.CreateNode(new Node { TenantGUID = tenant.GUID, Name = \"Joel\", Labels = labels });\n\nforeach (Node node in graph.ReadNodes(tenant.GUID, graph.GUID, labels))\n{\n  Console.WriteLine(...);\n}\n```\n\n### Storing and Searching Tags\n\n```csharp\nNameValueCollection nvc = new NameValueCollection();\nnvc.Add(\"key\", \"value\");\n\ngraph.CreateNode(new Node { TenantGUID = tenant.GUID, Name = \"Joel\", Tags = nvc });\n\nforeach (Node node in graph.ReadNodes(tenant.GUID, graph.GUID, null, nvc))\n{\n  Console.WriteLine(...);\n}\n```\n\n### Storing and Searching Data\n\n```csharp\nusing ExpressionTree;\n\nclass Person \n{\n  public string Name { get; set; } = null;\n  public int Age { get; set; } = 0;\n  public string City { get; set; } = \"San Jose\";\n}\n\nPerson person1 = new Person { Name = \"Joel\", Age = 47, City = \"San Jose\" };\ngraph.CreateNode(new Node { TenantGUID = tenant.GUID, GraphGUID = graph.GUID, Name = \"Joel\", Data = person1 });\n\nExpr expr = new Expr \n{\n  \"Left\": \"City\",\n  \"Operator\": \"Equals\",\n  \"Right\": \"San Jose\"\n};\n\nforeach (Node node in graph.ReadNodes(tenant.GUID, graph.GUID, null, expr))\n{\n  Console.WriteLine(...);\n}\n```\n\n### Storing and Searching Vectors\n\nIt is important to note that vectors have a dimensionality (number of array elements) and vector searches are only performed against graphs, nodes, and edges where the attached vector objects have a dimensionality consistent with the input.\n\nFurther, it is strongly recommended that you make extensive use of labels, tags, and expressions (data filters) when performing a vector search to reduce the number of records against which score, distance, or inner product calculations are performed. \n\n```csharp\nusing ExpressionTree;\n\nclass Person \n{\n  public string Name { get; set; } = null;\n  public int Age { get; set; } = 0;\n  public string City { get; set; } = \"San Jose\";\n}\n\nPerson person1 = new Person { Name = \"Joel\", Age = 47, City = \"San Jose\" };\n\nVectorMetadata vectors = new VectorMetadata \n{\n  Model = \"testmodel\",\n  Dimensionality = 3,\n  Content = \"testcontent\",\n  Vectors = new List\u003cfloat\u003e { 0.1f, 0.2f, 0.3f }\n};\n\ngraph.CreateNode(new Node { Name = \"Joel\", Data = person1, Vectors = new List\u003cVectorMetadata\u003e { vectors } });\n\nforeach (VectorSearchResult result in graph.SearchVectors(\n  VectorSearchDomainEnum.Node,\n  VectorSearchTypeEnum.CosineSimilarity,\n  new List\u003cfloat\u003e { 0.1f, 0.2f, 0.3f },\n  tenant.GUID,\n  graph.GUID,\n  null,  // labels\n  null,  // tags\n  null,  // filter\n))\n{\n  Console.WriteLine(\"Node \" + result.Node.GUID + \" score \" + result.Score);\n}\n```\n\n### Enumeration Ordering\n\nA variety of `EnumerationOrderEnum` options are available when enumerating objects.\n\n- `CreatedAscending` - sort results in ascending order by creation timestamp\n- `CreatedDescending` - sort results in descending order by creation timestamp\n- `NameAscending` - sort results in ascending order by name\n- `NameDescending` - sort results in descending order by name\n- `GuidAscending` - sort results in ascending order by GUID\n- `GuidDescending` - sort results in descending order by GUID\n- `CostAscending` - for edges only, sort results in ascending order by cost\n- `CostDescending` - for edges only, sort results in descending order by cost\n- `MostConnected` - for nodes only, sort results in descending order by total edge count\n- `LeastConnected` - for nodes only, sort results in ascending order by total edge count\n\nTo enumerate, use the enumeration API for the resource you wish.\n\n```csharp\nEnumerationQuery query = new EnumerationQuery\n{\n  Ordering = EnumerationOrderEnum.CreatedDescending,\n  IncludeData = true,\n  IncludeSubordinates = true,\n  MaxResults = 5,\n  ContinuationToken = null,         // set to the continuation token from the last results to paginate\n  Labels = new List\u003cstring\u003e,        // labels on which to match\n  Tags = new NameValueCollection(), // tags on which to match\n  Expr = null,                      // expression on which to match from data property\n};\n\nEnumerationResult result = graph.Node.Enumerate(query);\n// returns\n{\n    \"Success\": true,\n    \"Timestamp\": {\n        \"Start\": \"2025-06-22T01:17:42.984885Z\",\n        \"End\": \"2025-06-22T01:17:43.066948Z\",\n        \"TotalMs\": 82.06,\n        \"Messages\": {}\n    },\n    \"MaxResults\": 5,\n    \"ContinuationToken\": \"ca10f6ca-f4c2-4040-adfe-9de3a81b9f55\",\n    \"EndOfResults\": false,    // whether or not the end of the results has been reached\n    \"TotalRecords\": 17,       // total number of matching records\n    \"RecordsRemaining\": 12,   // records remaining should you enumerate again\n    \"Objects\": [\n        {\n            \"TenantGUID\": \"00000000-0000-0000-0000-000000000000\",\n            \"GUID\": \"ebefc55b-6f74-4997-8c87-e95e40cb83d3\",\n            \"GraphGUID\": \"00000000-0000-0000-0000-000000000000\",\n            \"Name\": \"Active Directory\",\n            \"CreatedUtc\": \"2025-06-21T05:23:14.100128Z\",\n            \"LastUpdateUtc\": \"2025-06-21T05:23:14.100128Z\",\n            \"Labels\": [],\n            \"Tags\": {},\n            \"Data\": {\n                \"Name\": \"Active Directory\"\n            },\n            \"Vectors\": []\n        }, ...\n    ]\n}\n```\n\n### Gathering Statistics\n\nStatistics are available both at the tenant level and at the graph level.\n\n```csharp\nDictionary\u003cGuid, TenantStatistics\u003e allTenantsStats = graph.Tenant.GetStatistics();\nTenantStatistics tenantStatistics = graph.Tenant.GetStatistics(myTenantGuid);\n\nDictionary\u003cGuid, GraphStatistics\u003e allGraphStatistics = graph.Graph.GetStatistics(myTenantGuid);\nGraphStatistics graphStatistics = graph.Graph.GetStatistics(myTenantGuid, myGraphGuid);\n```\n\n## REST API\n\nLiteGraph includes a project called `LiteGraph.Server` which allows you to deploy a RESTful front-end for LiteGraph.  Refer to `REST_API.md` and also the Postman collection in the root of this repository for details.  By default, LiteGraph.Server listens on `http://localhost:8701` and is only accessible to `localhost`.  Modify the `litegraph.json` file to change settings including hostname and port.\n\nListening on a specific hostname should not require elevated privileges.  However, listening on any hostname (i.e. using `*` or `0.0.0.0` will require elevated privileges).\n\n```csharp\n$ cd LiteGraph.Server/bin/Debug/net8.0\n$ dotnet LiteGraph.Server.dll\n\n  _ _ _                          _\n | (_) |_ ___ __ _ _ _ __ _ _ __| |_\n | | |  _/ -_) _` | '_/ _` | '_ \\ ' \\\n |_|_|\\__\\___\\__, |_| \\__,_| .__/_||_|\n             |___/         |_|\n\n LiteGraph Server\n (c)2025 Joel Christner\n\nUsing settings file './litegraph.json'\nSettings file './litegraph.json' does not exist, creating\nInitializing logging\n| syslog://127.0.0.1:514\n2025-01-27 22:09:08 joel-laptop Debug [LiteGraphServer] logging initialized\nCreating default records in database litegraph.db\n| Created tenant     : 00000000-0000-0000-0000-000000000000\n| Created user       : 00000000-0000-0000-0000-000000000000 email: default@user.com pass: password\n| Created credential : 00000000-0000-0000-0000-000000000000 bearer token: default\n| Created graph      : 00000000-0000-0000-0000-000000000000 Default graph\nFinished creating default records\n2025-01-27 22:09:09 joel-laptop Debug [ServiceHandler] initialized service handler\n2025-01-27 22:09:09 joel-laptop Info [RestServiceHandler] starting REST server on http://localhost:8701/\n2025-01-27 22:09:09 joel-laptop Alert [RestServiceHandler]\n\nNOTICE\n------\nLiteGraph is configured to listen on localhost and will not be externally accessible.\nModify ./litegraph.json to change the REST listener hostname to make externally accessible.\n\n2025-01-27 22:09:09 joel-laptop Info [LiteGraphServer] started at 01/27/2025 10:09:09 PM using process ID 56556\n```\n\n## Running in Docker\n\nA Docker image is available in [Docker Hub](https://hub.docker.com/r/jchristn/litegraph) under `jchristn/litegraph`.  Use the Docker Compose start (`compose-up.sh` and `compose-up.bat`) and stop (`compose-down.sh` and `compose-down.bat`) scripts in the `Docker` directory if you wish to run within Docker Compose.  Ensure that you have a valid database file (e.g. `litegraph.db`) and configuration file (e.g. `litegraph.json`) exposed into your container.\n\n## Version History\n\nPlease refer to ```CHANGELOG.md``` for version history.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitegraphdb%2Flitegraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flitegraphdb%2Flitegraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitegraphdb%2Flitegraph/lists"}