Skip to content

Twitter-like backend application built using Spring Boot and Maven. It provides RESTful APIs to perform various Twitter-like functionalities such as posting tweets, following/unfollowing users, and fetching timelines.

License

Notifications You must be signed in to change notification settings

vishwaravi/twitter-rest-api

Repository files navigation

Twitter backend

This project is a Twitter-like backend application built using Spring Boot and Maven. It provides RESTful APIs to perform various Twitter-like functionalities such as posting tweets, following/unfollowing users, and fetching timelines.

This project has Two Branches :

  • the main branch uses local db and stores images in project folder
  • the another branch built used cloud db to store images and data

Technologies Used

Backend :

  • Java (version : JDK 21 LTS)
  • Spring Boot (version 3.4.1)
  • Dependencies
    • Spring Web
    • Spring Security
    • Spring Data Jpa
    • MySQL Driver
    • Lombok
    • JJWT (JWT Authentication)

Database :

  • Maria DB

TESTING

Installation :

Step 1 : Clone the Repo.
Step 2 : rename the ".env.example" file to ".env"
Step 3 : Setup the Environment variables using .env file by Your db url and password
Example :

DB_URL= "Write Your DB URL starts With JDBC"
DB_USERNAME= "username here"
DB_PASSWORD= "password here"
JWT_SECRET="enter the secret"

step 4 : Run the application


Key Features :

User :

  • Creating Accounts
  • Deleting Accounts
  • Following Users
  • Followers

Content :

  • Posts
  • Tweets
  • Likes
  • comments

other Featues

  • Authentication and Authorization ( username and password )
  • JWT Authentication and Authorization

ER - Diagram

Schema image

DDL commands

USER TABLE

    CREATE TABLE users_table (
    id bigint NOT NULL AUTO_INCREMENT,
    user_id varchar(50) NOT NULL UNIQUE,
    user_name varchar(50) NOT NULL,
    user_dob date DEFAULT NULL,
    user_email varchar(50) NOT NULL,
    user_passwd varchar(100) NOT NULL,
    time_stamp varchar(255) DEFAULT NULL,
    user_pic varchar(255) DEFAULT NULL,
    banner_pic varchar(255) DEFAULT NULL,
    followers bigint DEFAULT NULL,
    following bigint DEFAULT NULL,
    PRIMARY KEY (id)
);

TWEET TABLE

    CREATE TABLE tweets_table (
    tweet_id bigint NOT NULL AUTO_INCREMENT,
    user_id varchar(255) DEFAULT NULL,
    tweet_filepath varchar(255) DEFAULT NULL,
    hashtags varchar(255) DEFAULT NULL,
    time_stamp varchar(255) DEFAULT NULL,
    tweet_content varchar(255) DEFAULT NULL,
    likes_count bigint DEFAULT NULL,
    PRIMARY KEY (tweet_id)
);

COMMENTS TABLE

    CREATE TABLE comments_table (
    id bigint NOT NULL AUTO_INCREMENT,
    comment_content varchar(255) DEFAULT NULL,
    time_stamp varchar(255) DEFAULT NULL,
    tweet_id bigint DEFAULT NULL,
    user_id varchar(255) DEFAULT NULL,
    PRIMARY KEY (id)
);

LIKES TABLE

    CREATE TABLE likes_table (
    id bigint NOT NULL AUTO_INCREMENT,
    liked_by varchar(255) DEFAULT NULL,
    tweet_id bigint DEFAULT NULL,
    time_stamp varchar(255) DEFAULT NULL,
    PRIMARY KEY (id)
);

FOLLOWERS TABLE

    CREATE TABLE followers_table (
    id bigint NOT NULL AUTO_INCREMENT,
    followed_by varchar(255) DEFAULT NULL,
    time_stamp varchar(255) DEFAULT NULL,
    user_id varchar(255) DEFAULT NULL,
    PRIMARY KEY (id)
);

FOLLOWING TABLE

    CREATE TABLE following_table (
    id bigint NOT NULL AUTO_INCREMENT,
    following varchar(255) DEFAULT NULL,
    time_stamp varchar(255) DEFAULT NULL,
    user_id varchar(255) DEFAULT NULL,
    PRIMARY KEY (id)
);

API ENDPOINTS

USER

POST - localhost:8080/register - REGISTER USER
GET - localhost:8080/{userId} - GET USER DETAILS
DELETE - localhost:8080/{userId} - DELETE USER
PUT - localhost:8080/{userId}/follow - FOLLOW USER
PUT - localhost:8080/{userId}/unfollow - UNFOLLOW USER

TWEET

GET - localhost:8080/home - FEED POSTS
POST - localhost:8080/home - POST TWEET
DELETE - localhost:8080/home/{tweetId} - DELETE TWEET
PUT - localhost:8080/home/{tweetId}/comment - POST COMMENT
DELETE - llocalhost:8080/home/{tweetId}/comment - DELETE COMMENT
PUT - localhost:8080/home/{tweetId}/like - LIKE POST
PUT - localhost:8080/home/{tweetId}/dislike - DISLIKE POST

About

Twitter-like backend application built using Spring Boot and Maven. It provides RESTful APIs to perform various Twitter-like functionalities such as posting tweets, following/unfollowing users, and fetching timelines.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages