Skip to content

Twitter clone in Spring Boot. Allows user creation, user can follow another user, work with tweet . Application is using JWT token to authenticate and authorize users.

Notifications You must be signed in to change notification settings

MaximRom00/Twitter-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitter-app

Twitter Clone using Java 17, Spring Boot, MYSQL, Liquibase, JWT, Gradle. Application is using JWT token to authenticate and authorize users.

This project is always updated with new features.

About the project

We have three main classes - User, Tweet and Subscription.

User class represents user in this application. User can register, create, update, delete, get tweets.

We have 2 types of authority: USER and ADMIN.

User can have roles 2 roles - ROLE_USER and ROLE_ADMIN, or 1 - ROLE_USER or ROLE_ADMIN.

Tweet class represents tweet in this application. Tweet can be created by user. Only authenticated user can create tweets. You can check the time when a tweet was created or updated by looking at the createdTimestamp or updatedTimestamp.

Subscription class represents subscribe/unsubscribe fuction betwen users in this application.

Diagram database

Explore Rest APIs

AUTH requests

  • Register:

POST -> "/api/v1/auth/register"

Request parameters: NONE

Request body:

{
    "name" : "Ivan Ivanov",
    "password" : "1",
    "email" : "ivanov123@gmail.com",
    "role" :{
    "authority" : "ROLE_USER" (by default 'ROLE_USER')
}
}

Authenticated: NONE

  • Login:

POST -> "/api/v1/auth/login"

Request parameters: NONE

Request body:

{
    "name" : "Ivan Ivanov",
    "password" : "1"
}

Authenticated: NONE

  • Refresh:

POST -> "/api/v1/auth/refresh"

Request parameters: NONE

Request body:

{
    "refreshtoken": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJPbGVnIFpodWsiLCJpZCI6MywiaWF0IjoxNjk1NTg5MDk2LCJleHAiOjE2OTU1OTI2OTZ9.nK5pZjZS5cuMWq6e8A0UQX_awtSGf8eHGWHypso0NmYkkGna-CXZVbPnQkQsFkeWktONXdGN2WNtQv5mYKIgTA"
}

Authenticated: NONE

USER requests

  • Get user by id:

GET -> "/api/v1/accounts/{id}"

Request parameters: NONE

Request body: NONE

Authenticated: USER, ADMIN

ROLE requests

  • Get all roles:

GET -> "/api/v1/roles""

Request parameters: NONE

Request body: `NONE

Authenticated: ADMIN

  • Create new role:

GET -> "/api/v1/roles/create""

Request parameters: NONE

Request body:

{
    "authority" : "NEW_ROLE"
}

Authenticated: ADMIN

TWEET requests

  • Get tweet by id:

GET -> "/api/v1/tweets/{id}"

Request parameters: NONE

Request body: NONE

Authenticated: USER, ADMIN

  • Get user's tweets:

GET -> "/api/v1/tweets/list"

Request parameters: NONE

Request body:

{
    "page" : "1",
    "limit" : 10
}

Authenticated: USER, ADMIN

  • Create a new tweet:

POST -> "/api/v1/tweets/create"

Request parameters: NONE

Request body:

{
    "id" : "5",
    "message" : "my new tweet"
}

Authenticated: USER, ADMIN

  • Update tweet:

PUT -> "/api/v1/tweets"

Request parameters: NONE

Request body:

{
    "id" : "5",
    "message" : "i want to change my tweet"
}

Authenticated: USER, ADMIN

  • Delete tweet:

DELETE -> "/api/v1/tweets/{id}"

Request parameters: NONE

Request body:

{
    "id" : "5"
}

Authenticated: USER, ADMIN

SUBSCRIPTION requests

  • Subscribe user:

POST -> "/api/v1/subscriptions/subscribe"

Request parameters: NONE

Request body:

{
    "followerId" : "3"
}

Authenticated: USER, ADMIN

  • Unsubscribe user:

POST -> "/api/v1/subscriptions/unsubscribe"

Request parameters: NONE

Request body:

{
    "followerId" : "2"
}

Authenticated: USER, ADMIN

About

Twitter clone in Spring Boot. Allows user creation, user can follow another user, work with tweet . Application is using JWT token to authenticate and authorize users.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages