Skip to content

kevinmichaelchen/neo4j-go-file-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

neo4j-go-file-system

A proof of concept demonstrating how to create a small graph of objects (files, folders, users, organizations, and policies) that when put together look something like a rudimentary file system.

Neo4j feels like a natural choice for database, since our goal is to represent a file system tree and users' relationships to certain nodes in that tree.

In this model, organizations (red nodes) represent file system root. The blue nodes are the users. The yellow nodes are the folders. The green nodes are the files.

screen shot 2019-01-17 at 10 49 13 am

Getting started

This guide expects your Neo4j password to be in the .env file. If you've never configured Neo4j, the default password should be neo4j.

Set that in your .env file:

$ cat .env

NEO_PASSWORD=neo4j
Command Description
make Runs containers
make rebuild Rebuilds images from scratch and runs containers
make stop Stops running containers

Once started, the Neo4j container will be accessible via http://localhost:7474.

Log in with the username neo4j and whatever password you've configured (neo4j is the default out-of-the-box password).

REST API

Creating a user

curl http://localhost:8080/user -H 'Origin: http://localhost:3000' -d '{"resourceID": 22, "emailAddress": "kevin.chen22@irisvr.com",  "fullName": "Kevin Chen22"}'

Getting a file

curl http://localhost:8080/file/9c73cde3-d8f9-4048-bfd9-00e0484fdb89 -H 'Origin: http://localhost:3000'

Moving a file

curl -X POST http://localhost:8080/move -H 'Origin: http://localhost:3000' -d '{"sourceID": "7a1ced19-5396-4c44-bc30-4953d59453d5", "destinationID": "0871b5af-4954-4d21-9e1f-3781e269374a", "newName": "cloud-auth-moved"}'

gRPC API

We can test out our gRPC API on the command line with grpcurl. It behaves like curl, but it can process binary payloads.

To install it, run

go get github.com/fullstorydev/grpcurl
go install github.com/fullstorydev/grpcurl/cmd/grpcurl

There are some calls you can make to see what kinds of methods your API supports:

grpcurl -import-path ./src/pb -proto file.proto list
grpcurl -v -plaintext localhost:50051 list pb.FileService

Files

grpcurl -v -plaintext -d '{"userID": "4", "fileID": "7a1ced19-5396-4c44-bc30-4953d59453d5"}' localhost:50052 pb.FileService/GetFile

Organizations

grpcurl -v -plaintext -d '{"organization": {"id": 1}}' localhost:50051 pb.OrganizationService/GetOrganization
grpcurl -v -plaintext -d '{"organization": {"id": 2, "name": "My Custom Org"}}' localhost:50051 pb.OrganizationService/CreateOrganization

Reading

About

Rudimentary object graph using Go and Neo4j

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published