thinhnv98 / FriendManagement

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

S3_FriendManagement_ThinhNguyen

##Build and run App

docker-compose build
docker-compose up

##APIs

###Create an email

POST /user
  • Request body
{
    "Email":"abc@example.com"
}
  • Response body:
{
    "Success": true
}

###Create friend connection

POST /friend
  • Request body:
{ 
    "friends": [
        "andy@example.com",
        "john@example.com"
    ]
}
  • Response body:
{ 
    "success": "true"
}

Get friend list for an email address

GET /friend/friends
  • Request body:
{ 
    "email": "andy@example.com"
}
  • Response body:
{ 
    "success": "true",
    "friends": [
        "john@example.com"
    ],
    "count" : 1
}

Get common friend list between two email addresses

GET /friend/common-friends
  • Request body:
{ 
    "friends": [
        "andy@example.com",
        "john@example.com"
    ]
}
  • Response body:
{ 
    "success": "true",
    "friends": [
        "common@example.com"
    ],
    "count" : 1
}

Subscribe to update from an email address

POST /subscription
  • Request body:
{
  "requestor": "lisa@example.com",
  "target": "john@example.com"
}
  • Response body:
{ 
    "success": "true"
}

Block update from an email address

POST /block
  • Request body:
{
  "requestor": "andy@example.com",
  "target": "john@example.com"
}
  • Response body:
{ 
    "success": "true"
}

Retrieve all email addresses which can receive update from an email address

GET /friend/emails-receive-update
  • Request body:
{
  "sender": "john@example.com",
  "text": "Hello World! kate@example.com"
}
  • Response body:
{ 
    "success": "true",
    "recipients": [
        "lisa@example.com",
        "kate@example.com"
    ]
}

Project architecture

  • Workflow: Request => Handlers => Services => Repositories => Database

  • Three layers model:

    • Handlers: Get request from httpRequest, decode, validate, call services, write httpResponse
    • Services: Handle business logic, call repositories
    • Repositories: Data access layer

About


Languages

Language:Go 99.4%Language:Dockerfile 0.6%Language:Shell 0.1%