{"id":33319442,"url":"https://github.com/szktty/rinne-graph","last_synced_at":"2026-05-06T09:43:06.857Z","repository":{"id":324583594,"uuid":"1093017793","full_name":"szktty/rinne-graph","owner":"szktty","description":"An embedded graph database library for Dart and Flutter applications, using SQLite as its backend.","archived":false,"fork":false,"pushed_at":"2025-11-16T19:31:13.000Z","size":171,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2025-11-16T20:10:51.925Z","etag":null,"topics":["dart","embedded","flutter","graph-database","library","property-graph","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szktty.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-09T18:45:20.000Z","updated_at":"2025-11-16T19:31:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/szktty/rinne-graph","commit_stats":null,"previous_names":["szktty/rinne-graph"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/szktty/rinne-graph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szktty%2Frinne-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szktty%2Frinne-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szktty%2Frinne-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szktty%2Frinne-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szktty","download_url":"https://codeload.github.com/szktty/rinne-graph/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szktty%2Frinne-graph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285319005,"owners_count":27151474,"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-11-19T02:00:05.673Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["dart","embedded","flutter","graph-database","library","property-graph","sqlite"],"created_at":"2025-11-19T20:01:00.058Z","updated_at":"2025-11-19T20:03:01.301Z","avatar_url":"https://github.com/szktty.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RinneGraph\n\n## Overview\n\nRinneGraph is an embedded graph database library for Dart and Flutter applications, using SQLite as its backend. It provides a property graph model with vertices and edges, and offers a Gremlin-inspired traversal API for querying graph data.\n\n## Features\n\n*   **Embedded \u0026 Lightweight**: Runs directly within your Dart or Flutter application with no separate server process.\n*   **Traversal API**: Build complex graph queries with a chained, Gremlin-style API (`g.V().out('knows').values('name')`).\n*   **Property Graph Model**: Supports vertices and edges with arbitrary properties.\n\n## Installation\n\nAdd this to your `pubspec.yaml` file:\n\n```yaml\ndependencies:\n  rinne_graph: ^0.7.0\n```\n\nThen run `dart pub get` or `flutter pub get`.\n\n## Quick Start\n\nRun locally:\n\n```bash\ndart run example/example.dart\n```\n\n\nHere's a simple example of creating a small graph and querying it.\n\n```dart\nimport 'package/rinne_graph/rinne_graph.dart';\n\nvoid main() async {\n  // 1. Open an in-memory graph database\n  final graph = await Graph.openInMemory();\n  final g = graph.traversal();\n\n  // 2. Create vertices and edges within a transaction\n  await graph.transaction((txn) async {\n    final v1 = await txn.createVertex(Vertex(\n      labels: {'person'},\n      properties: {'name': 'Alice', 'age': 30},\n    ));\n    final v2 = await txn.createVertex(Vertex(\n      labels: {'person'},\n      properties: {'name': 'Bob', 'age': 25},\n    ));\n    await txn.createEdge(Edge(\n      fromVertexId: v1.id!,\n      toVertexId: v2.id!,\n      labels: {'knows'},\n      properties: {'since': 2021},\n    ));\n  });\n\n  // 3. Traverse the graph to find people Alice knows\n  final names = await g.V()\n      .hasLabel(['person'])\n      .hasKey('name', 'Alice')\n      .out('knows')\n      .values(['name'])\n      .toList();\n\n  // 4. Print the results\n  print(\"Alice knows: $names\"); // Output: Alice knows: [Bob]\n\n  // 5. Close the database\n  await graph.close();\n}\n```\n\n## Samples (optional)\n\nYou can quickly spin up sample graphs for testing and exploration.\n\n```dart\nimport 'package:rinne_graph/rinne_graph_samples.dart';\n\nfinal graph = await Samples.simpleGraph();\n// or\nfinal movies = await Samples.movies();\n```\n\n\n## Usage Examples\n\nBelow are minimal examples to complement the Quick Start.\n\nTransaction \u0026 CRUD:\n\n```dart\nawait graph.transaction((txn) async {\n  final v = await txn.createVertex(Vertex(labels: {'note'}, properties: {'title': 'T'}));\n  await txn.updateVertexProperties(v.id!, {'title': 'New Title'});\n  await txn.deleteVertex(v.id!);\n});\n```\n\nBasic traversal patterns:\n\n```dart\nfinal g = graph.traversal();\nfinal names = await g.V().hasLabel(['person']).hasKey('age', 30).values(['name']).toList();\nfinal neighbors = await g.V().hasKey('name', 'Alice').out('knows').toList();\n```\n\n\n## Index Management (Experimental)\n\nRinneGraph provides a user-managed property index API to help optimize query performance at the SQLite level. Indexes can be created for property keys on vertices or edges.\n\nImportant: managing indexes is the user's responsibility; create indexes only for properties that are frequently queried. Indexes can improve read performance but may increase write cost and disk usage.\n\nAvailable APIs:\n- `createPropertyIndex(String propertyKey, {IndexEntityType entityType = IndexEntityType.vertices, String? indexName})`\n- `dropPropertyIndex(String indexName)`\n- `listPropertyIndexes() -\u003e Future\u003cList\u003cPropertyIndexInfo\u003e\u003e`\n- `hasPropertyIndex(String propertyKey, {IndexEntityType entityType = IndexEntityType.vertices}) -\u003e Future\u003cbool\u003e`\n\nEntity types:\n- `IndexEntityType.vertices` (vertex properties)\n- `IndexEntityType.edges` (edge properties)\n\nIndex name generation:\n- If `indexName` is omitted, a name is auto-generated:\n  - Vertices: `idx_user_v_{propertyKey}`\n  - Edges: `idx_user_e_{propertyKey}`\n\nExample:\n\n```dart\nfinal graph = await Graph.open('my_graph.db');\n\nawait graph.createPropertyIndex('name'); // vertex property\nawait graph.createPropertyIndex('weight', entityType: IndexEntityType.edges); // edge property\n\nfinal indexes = await graph.listPropertyIndexes();\nfor (final idx in indexes) {\n  print('${idx.name}: ${idx.propertyKey} (${idx.entityType})');\n}\n\nawait graph.dropPropertyIndex('idx_user_v_name');\n```\n\nStatus:\nThis feature is under active development. In current releases, some methods may not be fully implemented yet and may throw `UnimplementedError` or return placeholders. The API surface is intended to be stable, but behavior may evolve.\n\n\n## Database Validation\n\nBefore opening an existing SQLite file with RinneGraph, you can safely validate whether it’s properly initialized for this library.\n\n- API: `DatabaseManager.validateDatabaseFile(String path, { DatabaseValidationOptions options = DatabaseValidationOptions.defaultOptions })`\n- Read-only validation: the file is opened in read-only mode and not modified\n- Returns: `DatabaseValidationResult` (e.g., `isValid`, `isInitialized`, `isFullyInitialized`, `missingTables`, `missingIndexes`, `missingTriggers`, `schemaVersion`, `errorMessage`)\n\nExample:\n\n```dart\nfinal manager = DatabaseManager();\nfinal result = await manager.validateDatabaseFile('my_graph.db');\nif (result.isFullyInitialized) {\n  final graph = await Graph.open('my_graph.db');\n  // ... use the graph\n  await graph.close();\n} else {\n  print('Database issues: ${result.description}');\n}\n```\n\nOptions:\n- `DatabaseValidationOptions.basic` (tables only)\n- `DatabaseValidationOptions.defaultOptions` (tables, indexes, triggers, schema version)\n- `DatabaseValidationOptions.strict` (stricter checks)\n- Custom via `DatabaseValidationOptions(checkTables: ..., checkIndexes: ..., checkTriggers: ..., checkSchemaVersion: ...)`\n\n\n## Label Events \u0026 Callbacks\n\nYou can subscribe to label-related events fired during transactions. Convenience methods are provided on `Graph` and the underlying `eventManager` is also available.\n\nEvent types:\n- `VertexLabelEvent` and `EdgeLabelEvent` (both extend `LabelEvent`)\n- `LabelEventType`: `added`, `removed`, `updated`\n\nRegister listeners:\n\n```dart\nfinal graph = await Graph.openInMemory();\n\ngraph.onVertexLabelEvent((e) {\n  // e.vertexId, e.label, e.eventType, e.allLabels, e.timestamp\n});\n\ngraph.onEdgeLabelEvent((e) {\n  // e.edgeId, e.label, e.eventType, e.allLabels\n});\n\ngraph.onLabelEvent((e) {\n  // handle both vertex/edge label events if desired\n});\n```\n\nNotes:\n- Callbacks run safely; errors in callbacks are logged and do not break transactions.\n- Internal details (event dispatch) are not part of the public API.\n\n\n## Label Statistics \u0026 Analysis\n\nGet quick, high-level statistics or run deeper analysis.\n\nQuick statistics:\n\n```dart\nfinal graph = await Graph.openInMemory();\nfinal stats = await graph.getStatistics();\n// stats.totalVertices, stats.totalEdges, stats.labelCounts, ...\n```\n\nDeeper analysis with `LabelAnalyzer`:\n\n```dart\nfinal analyzer = graph.labelAnalyzer;\nfinal report = await analyzer.generateReport();\n// e.g., report.popularLabels, co-occurrence, distributions\n```\n\n\n## Command-line Tool: `rinne`\n\n\n\nRinneGraph ships with a small CLI for common tasks. Run:\n\n```bash\nrinne --help\n```\n\nCommon subcommands:\n- `create --output \u003cfile\u003e`: create a new SQLite database file\n- `validate --database \u003cfile\u003e`: check if a database file is properly initialized\n- `info --database \u003cfile\u003e`: show basic information/statistics\n- `sample --output \u003cfile\u003e`: generate a small sample dataset\n- `import json -i \u003cinput.json\u003e -d \u003cdatabase.db\u003e` or `import csv -n \u003cnodes.csv\u003e -e \u003cedges.csv\u003e --database \u003cdatabase.db\u003e [--config \u003cconfig.csv\u003e]`\n- `export json --database \u003cdatabase.db\u003e -o \u003coutput.json\u003e [--pretty --include-metadata --filter-labels L1,L2 --limit N]`\n- `export csv --database \u003cdatabase.db\u003e --nodes-output \u003cnodes.csv\u003e --edges-output \u003cedges.csv\u003e [--no-header --filter-labels L1,L2 --limit N --encoding utf-8]`\n- `query --database \u003cfile\u003e --sql \u003cSQL\u003e`: run a raw SQL query (advanced)\n\nImport/Export formats (brief):\n- JSON: a single file with metadata, nodes, and links\n- CSV: separate files (nodes.csv, edges.csv, optional config.csv)\n\nNotes:\n- The CLI uses the current working directory by default and supports both relative and absolute paths.\n- Files are created in the specified (or working) directory; hidden system directories are not used.\n\n\n## Data Import/Export\n\nUse the `rinne` CLI for importing and exporting data.\n\nImport (JSON):\n```bash\nrinne import json -i data.json -d graph.db\n```\n\nImport (CSV):\n```bash\nrinne import csv -n nodes.csv -e edges.csv --database graph.db [-c config.csv]\n```\n\nExport (JSON):\n```bash\nrinne export json --database graph.db -o out.json [--pretty --include-metadata --filter-labels person,knows --limit 100]\n```\n\nExport (CSV):\n```bash\nrinne export csv --database graph.db --nodes-output nodes.csv --edges-output edges.csv [--no-header --filter-labels person,knows --limit 100 --encoding utf-8]\n```\n\nNotes:\n- JSON: single file containing metadata, nodes, links\n- CSV: separate files (nodes.csv, edges.csv, optional config.csv)\n- Paths can be relative or absolute; the CLI resolves relative paths against the current working directory.\n\n## Related Projects\n\n- [plough](https://pub.dev/packages/plough) — a graph drawing/rendering library for Flutter, self-authored by the same developer.\n\nYou can combine RinneGraph for local graph storage and traversal, and plough for visualization in Flutter apps.\n\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszktty%2Frinne-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszktty%2Frinne-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszktty%2Frinne-graph/lists"}