Public Repository

Last pushed: a year ago
Short Description
Short description is empty for this repo.
Full Description

Friend Management API Test


For any application with a need to build its own social network, "Friends Management" is a common requirement
which usually starts off simple but can grow in complexity depending on the application's use case.

Usually, applications would start with features like "Friend", "Unfriend", "Block", "Receive Updates" etc.

Table Design


The Users table stores the email address of the users.

The table can be easily updated to include other data that is required in the future.


The Relationship table stores the relationship between 2 users.
There are 3 boolean columns to denote the following:

  • are friends
  • is blocked
  • receive updates

Every new connection will create a row in this table to keep track of the relationship between users.

API Design

Every call to the API endpoints will check if the email addresses exists in the Users table. Any email addresses that does not exists will return an error.
The only exception to this is for the create connection API call as there is no existing way to create new user.

All other API calls will validate the email addresses provided against Users table to ensure they exists.

Hibernate Validator is used to validate that the JSON requests are valid. For e.g., @Email is used to validate all email addresses.

An in-memory H2 Database is currently used as the persistent layer to keep it simple. It can be easily changed to another database of choice. The H2 database settings can be changed to write to a location, which can be mounted to a persistent volume on the host when running the docker image.

Prerequisite to run this project

To run this project

  1. Open up command prompt or shell
  2. Type "docker run -p 8080:8080 worm3/friendmanagement" and wait for it to run
  3. Open link http://localhost:8080/health in browser and it should show the below if it is up
    "status": "UP"

Endpoints for user stories

  1. http://localhost:8080/friend
  2. http://localhost:8080/friend/list
  3. http://localhost:8080/friend/list/common
  4. http://localhost:8080/friend/subscribe
  5. http://localhost:8080/friend/block
  6. http://localhost:8080/friend/list/updates
Docker Pull Command