Sharing Knowledge Graphs
The Nexarag graph manager feature allows users to export, save, and switch between different Neo4j knowledge graphs in the Nexarag platform.
Overview
The Knowledge Graph Management feature provides:
- Export Current KG: Save the current knowledge graph to a dump file.
- Import/Load KG: Switch to a previously saved knowledge graph.
- List Available KGs: View all saved knowledge graphs with metadata.
- Delete KGs: Remove unwanted knowledge graph dumps.
- Quick Selector: Dropdown menu to quickly switch between knowledge graphs.
Quick Start
Exporting Knowledge Graphs
- Click the cog menu item to access the projects workspace.
- Enter a name for your export.
- [Optional] Add a description.
- Click "Export Knowledge Graph"
- The current Neo4j database will be saved as a dump file to
kg_dumpsin the same folder as the Docker compose file.
Import Knowledge Graphs
- Copy the
kg_dumpsfile to the target, in the same folder as the Docker compose file. - Run
docker compose restart. - In the Nexarag frontend, open the projects workspace.
- Identify the desired export and click "Load".
Switching Knowledge Graphs
Option 1: Quick Selector
- Use the dropdown at the top of the screen.
- Select a knowledge graph from the list.
- The system will automatically load the selected KG.
Option 2: Management Interface
- Open the projects workspace.
- Click "Load" button on any knowledge graph card.
- Confirm the action.
Deleting Knowledge Graphs
- Open the projects workspace.
- Click "Delete" button on the knowledge graph card
- Confirm the deletion in the popup dialog.
Backend Implementation
API Endpoints
GET /kg/list/- List all available knowledge graph dumpsPOST /kg/export/- Export current knowledge graphPOST /kg/import/- Import/load a knowledge graphDELETE /kg/delete/- Delete a knowledge graph dumpGET /kg/current/- Get current knowledge graph information
Docker Changes
Added kg_dumps volume to all docker-compose files:
docker-compose.cpu.ymldocker-compose.gpu.ymldocker-compose.macos.yml
This volume is mounted at /dumps in the Neo4j container and shared with API and KG services.
KnowledgeGraphManager Class
Located in backend/src/kg/db/kg_manager.py, this class handles:
- Exporting databases using
neo4j-admin database dump - Loading databases using
neo4j-admin database load - Managing metadata for saved knowledge graphs
- File operations for dump files
Frontend Implementation
New Components
- KgManagementComponent (
frontend/src/app/kg/kg-management.component.ts) - Full knowledge graph management interface
- Export form with name and description
- Grid view of available knowledge graphs
- Load/delete actions for each KG
- KgSelectorComponent (
frontend/src/app/kg/kg-selector.component.ts) - Compact dropdown selector
- Quick switching between knowledge graphs
- Positioned at top of main viewport
- KnowledgeGraphService (
frontend/src/app/kg/kg.service.ts) - HTTP service for KG API calls
- TypeScript interfaces for API responses
UI Integration
- Added new "Knowledge Graphs" tab to the main menu (database icon)
- Added KG selector dropdown at the top of the main viewport
- Toast notifications for all operations
- Confirmation dialogs for destructive actions
Technical Notes
Neo4j Commands
The system uses Neo4j 5.x admin commands:
- Export:
neo4j-admin database dump --to-path=/dumps --database=<name> --overwrite-destination=true - Import:
neo4j-admin database load --from-path=/dumps --database=<name> --overwrite-destination=true
Database Operations
When loading a knowledge graph:
- Neo4j database is stopped
- Dump file is loaded
- Database is restarted
This ensures data consistency but causes a brief service interruption.
Metadata Storage
Knowledge graph metadata is stored in kg_metadata.json within the dumps volume:
{
"kg_name": {
"created_at": "ISO datetime",
"description": "User description",
"database": "neo4j database name"
}
}
Volume Persistence
The kg_dumps volume persists knowledge graphs across container restarts. However, if you remove the volume, all saved knowledge graphs will be lost.
Limitations
- Single Database: Currently supports one active database at a time
- Service Interruption: Loading a KG briefly stops the Neo4j service
- Storage Space: Large knowledge graphs require significant storage
- No Compression: Dump files are stored uncompressed
Future Enhancements
- Parallel Databases: Support multiple concurrent databases
- Compression: Compress dump files to save space
- Import/Export Progress: Show progress bars for large operations
- KG Comparison: Compare differences between knowledge graphs
- Scheduled Exports: Automatic periodic backups
- Cloud Storage: Upload/download KGs to/from cloud storage