User management microservice based on Neo4J

User management microservice based on Neo4J

Web applications commonly require a user database and the management logic for it. Having to build such software infrastructure for each individual app would be time consuming so I designed a general-purpose user management microservice that can be easily integrated in a project.

At its core, the service consists of a Node.js + Express API which stores and manages users as nodes in a Neo4J database. here, Neo4J was chosen so that other apps could add their own nodes to it and thus benefit from the advantages of a graph database.

Additionally, the API also manages authentication. When a user is added to the database, its password his/her password is encrypted then stored, which allows the API to verify credentials during user login. Upon successful login, the API generates a JWT containing the user ID and hands it over to the client. The client can then use the JWT in the authorization header of further requests, which the API can decode to identify the user.

To interact with the API, I designed a simple GUI with Vue.js.

API definition

The API routes are fairly straightforward:

  • /users

    • POST: Create a user with properties passed in the request body

    • GET: Get all users

  • /users/:user_id

    • GET: Get a user using his/her ID

    • PATCH: Update a user

    • DELETE: delete a user

  • /users/:user_id/password

    • PUT: Password update

  • /auth/login

    • POST: Provides a JWT in exchange of valid username and password passed in the request body

Note: "self" can be used as user ID to manage data of the user currently logged in.

Source code

The source code for this service is available on GitHub: