https://github.com/makomo/mongo2neo4j
MongoDB Mongoose to Neo4j Importer
https://github.com/makomo/mongo2neo4j
conversion exploration mongodb mongoose neo4j semspect
Last synced: 6 months ago
JSON representation
MongoDB Mongoose to Neo4j Importer
- Host: GitHub
- URL: https://github.com/makomo/mongo2neo4j
- Owner: MAKOMO
- License: gpl-3.0
- Created: 2023-07-24T09:47:21.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-20T20:06:51.000Z (11 months ago)
- Last Synced: 2025-03-25T03:27:12.557Z (7 months ago)
- Topics: conversion, exploration, mongodb, mongoose, neo4j, semspect
- Language: Python
- Homepage: https://makomo.github.io/mongo2neo4j/
- Size: 1.57 MB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# [mongo2neo4j](https://makomo.github.io/mongo2neo4j/)
[MongoDB](https://www.mongodb.com/) [Mongoose](https://mongoosejs.com/) to [Neo4j](https://neo4j.com/) Importer

[](https://github.com/MAKOMO/mongo2neo4j/actions/workflows/pylint.yaml)
[](https://github.com/MAKOMO/mongo2neo4j/actions/workflows/ruff.yaml)
[](https://github.com/MAKOMO/mongo2neo4j/actions/workflows/mypy.yml)
[](https://github.com/artisan-roaster-scope/artisan/actions/workflows/pytest.yaml)
## What is mongo2neo4j?
Imports object relations generated by Object Relation Mappers (ORMs) like [Mongoose](https://mongoosejs.com/) and stored in [MongoDB](https://www.mongodb.com/) into the graph database management system [Neo4j](https://neo4j.com/) for exploration with the no-code graphical querying tool [SemSpect](https://www.semspect.de/). Further relations between objects can be specified via options.

_References_
[Graph Exploration By All MEANS With mongo2neo4j and SemSpect](https://neo4j.com/developer-blog/mean-stack-mongo2neo4j-semspect/); Neo4j Developer Blog (6/2024)
[NODES 2024 - Exploration of Your MEAN Stack With mongo2neo4j and SemSpect](https://www.youtube.com/watch?v=Ini2nTIix_Q); Presentation at NODES 2024 Developer Conference (11/2024)## What for?
Imagine you just released your latest [MEAN-stack](https://en.wikipedia.org/wiki/MEAN_(solution_stack)) app and want to learn how it is used. You could write some [MongoDB](https://www.mongodb.com/) queries to find out _"how many users of the free tier are at all producing some data?", "which feature is used most by subscribers?",_ ... But maybe you never find time to write those queries or you do not know exact what to look for. A graphical large-data exploration tool like [SemSpect](https://www.semspect.de/) comes in handy, which allows you to discover patterns in your data by simple navigation.

As [SemSpect](https://www.semspect.de/) is layered on top of the graph database system [Neo4j](https://neo4j.com/) as graph app, your [MongoDB](https://www.mongodb.com/) data needs first to be established in [Neo4j](https://neo4j.com/). This can be easily achieved using the `mongo2neo4j` tool.
## How does it work?
The `mongodb2neo4j` script creates a label (class of nodes) in [Neo4j](https://neo4j.com/) for each collection in the given [MongoDB](https://www.mongodb.com/) and adds nodes in [Neo4j](https://neo4j.com/) for all documents. Cross-references between [MongoDB](https://www.mongodb.com/) documents using unique `ObjectId` identifiers are turned into [Neo4j](https://neo4j.com/) relations, nicely rendered by [SemSpect](https://www.semspect.de/).

## Installation
### Install Neo4j
The free Neo4j Desktop works well (see [Neo4j](https://neo4j.com/))
### Install SemSpect Plugin
The free SemSpect Graph App for Neo4j works well (see [SemSpect](https://www.semspect.de/))
### Install `mongo2neo4j`
Note: mongo2neo4j requires [Python 3.11](https://www.python.org/) or newer.
```sh
% pip3 install mongo2neo4j
```## Run the importer
You can run the `mongo2neo4j`importer from the shell by providing at least the name of the [MongoDB](https://www.mongodb.com/) DB the data should be imported from. If not specified the default `neo4j` DB is targeted with the default `neo4j` user. It is likely that you will have to add passwords.
```sh
% mongo2neo4j \
[--mongo_host mongodb://:@] \
[--neo4j_user=] [--neo4j_password=] \
```Further configuration options are listed on calling
```sh
% mongo2neo4j -h
```See [Script Arguments](https://github.com/MAKOMO/mongo2neo4j/wiki/Script-Arguments) for the full list of available arguments and the [example](https://github.com/MAKOMO/mongo2neo4j/blob/main/example/README.md) documenting the workflow of mongo2neo4j using randomly generated sample data.
NOTE: *if the [APOC plugin](https://neo4j.com/docs/apoc/) is installed in the Neo4j DB, the faster and memory-effective `apoc.periodic.iterate` method is used to generate nodes and sublabels.*