Skip to content

Simplified version of LinkedIn, focusing on account management, posts, comments, and interactions.

Notifications You must be signed in to change notification settings

victorvcruz/social-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Social Network Project

This project is an inspiration from the social business network Linkedin. Built on a monolithic architecture, it uses rest API, cache, sql and message-broker.


Diagram of Database


Built With

  • gin-gonic
  • PostegreSQL
  • redis
  • redis

Pre-requisites

  • go

    sudo snap install go --classic
  • install docker

  • install docker-compose

    docker-compose -v
    docker version

Installation

  1. Clone the repository
    git clone https://github.com/victorvcruz/social_network_project.git
  2. Install go packages
    go mod download
  3. Run docker-compose
    sudo docker-compose up -d

Usage

The project is a CRUD application of four operations

  • Account
  • Post
  • Comment
  • Interaction

To create operations define your API_PORT in .env file for use by endpoints

To start execution

  • run
    go run main.go

Account Operations

  • The http://localhost:8080/accounts endpoint is used for creating new accounts
  • The http://localhost:8080/accounts/auth endpoint is used for creating new token
  • The http://localhost:8080/accounts/follows endpoint is used to follow other accounts
  • The http://localhost:8080/accounts/following endpoint is used to find which accounts are following
  • The http://localhost:8080/accounts/follower endpoint is used to find which accounts follow it

1️⃣ Request:

curl -iX POST \
  --url 'http://localhost:8080/accounts' \
  --header 'Content-Type: application/json' \
  --data ' {
    "username": "jonh",
    "name": "Jonh Deep",
    "description": "my name is Jonh",
    "email": "jonh.deep@gmail.com",
    "password": "jonh1x3"
  }'

This endpoint contains get, update and delete which need auth-token

2️⃣ Request:

curl -iX POST \
  --url 'http://localhost:8080/accounts/auth' \
  --header 'Content-Type: application/json' \
  --data ' {
    "email": "jonh.deep@gmail.com",
    "password": "jonh1x3"
  }'

Token created: eyJhbGciOiJIUzI1NiIsInR5.example

3️⃣ Request:

curl -iX POST \
  --url 'http://localhost:8080/accounts/follows' \
  --header 'Content-Type: application/json' \ 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5.example' \
  --data ' {
    "id": "8216385e-730b-40a7-8fbd-a37889feac7d"
  }'

Insert id to follow

Post Operations

  • The http://localhost:8080/posts endpoint is used for creating new posts
  • The http://localhost:8080/accounts/follows endpoint is used for find post by accounts are following

4️⃣ Request:

curl -iX POST \
  --url 'http://localhost:8080/posts' \
  --header 'Content-Type: application/json' \ 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5.example' \
  --data ' {
    "content": "yes, my name is Jonh?"
  }'

This endpoint contains get, update and delete

5️⃣ Request:

curl -X GET \
  --url 'http://localhost:8080/accounts/follows/posts?page=1' \
  --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5.example'

Insert search pages

Comment Operations

  • The http://localhost:8080/comments/:id endpoint is used for creating new comments

6️⃣ Request:

curl -iX POST \
  --url 'http://localhost:8080/comments/52ba9bd3-e7e2-47fc-8ef4-99a24b32f888?comment_id=5e4a643c-befc-4854-bbe5-c7bbbb67ca2f' \
  --header 'Content-Type: application/json' \ 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5.example' \
  --data ' {
    "content": "no, your name not is Jonh."
  }'

Insert post_id in params of endpoint and comment_id in query. This endpoint contains get, update and delete

Interaction Operations

  • The http://localhost:8080/interaction endpoint is used for creating new interaction

7️⃣ Request:

curl -iX POST \
  --url 'http://localhost:8080/interaction' \
  --header 'Content-Type: application/json' \ 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5.example' \
  --data ' {
    "comment_id": "b166452d-9194-4b67-935b-4138428eb3d8",
    "type": "LIKE"
  }'

This endpoint contains update and delete

To stop execution

  • run
    sudo docker-compose down

About

Simplified version of LinkedIn, focusing on account management, posts, comments, and interactions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages