ska1296 / clone-try1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simplified twitter clone

The project implements simplified twitter clone for:

  • User registration
  • Log in/Log out
  • Create a post of 140 characters
  • Search for users
  • Follow an user
  • Like a post
  • List all posts for an use
  • Show feeds of users who you follow and posts that you like.

The project was built and run in Windows environment in eclipse and Windows Command Prompt. The testing was done using Postman. The poject is a java project that uses PostgreSQL as database, dropwizard framework, hibernate and maven. The application launches on port 8080.

Prerequisites

  • Windows Environment
  • Apache Maven 3.6.3
  • Maven path setup in windows environment variable
  • Stable internet connection (for maven to download dependency jars)
  • PostgreSQL 4.26

Setup

  • clone the project
  • create a database called 'clone' using the "CREATE DATABASE" commands in the file setup\createTables.txt. The expected port, username, database name and password are available in the yaml file.
  • navigate to clone-try1.yaml under the project and update the fields (if needed):
    • user
    • password
    • database name in url (jdbc:postgresql://localhost/)
    • port

Build and Start

  • Open powershell and navigate to the directory where the project is cloned and run:
mvn clean install

It should return "BUILD SUCCESS".

  • run:
java -jar target/clone-try1-0.0.1-SNAPSHOT.jar server clone-try1.yml

It should return:

usage: java -jar clone-try1-0.0.1-SNAPSHOT.jar
       [-h] [-v] {server,check} ...

positional arguments:
  {server,check}         available commands

named arguments:
  -h, --help             show this help message and exit
  -v, --version          show the application version and exit
  • run:
java -jar target/clone-try1-0.0.1-SNAPSHOT.jar server clone-try1.yml

The server should start with the last line of the message similar to:

INFO  [2020-10-11 18:46:40,492] org.eclipse.jetty.server.Server: Started @5208ms

Test

Use the file setup\twitterclone.postman_collection. Import the file in Postman.

{
    "userName": "user",
    "password":"password"
}
  • Log in/Log out
    • It returns an auth code. The auth code is necessary to maintain a session and all actions from on here will need the generated auth code to proceed. If the auth code has any spaces, they need to be removed. The auth code is passed in the header with key "token".
    • POST. URL: http://localhost:8080/user/signin/user
    • The body expects data for format:
{
    "userName": "user",
    "password":"password"
}
{
    "postData": "this is 3rd post",
    "createTime":"11-10-2020 00:09"
}
{
    "postData": "this is 1st post",
    "user":"794dc6d8-eb2a-4b58-a8ec-0728a1d440e2",
    "createTime": "11-10-2020 00:09",
    "postId":"acb15cc4-8588-465d-8fd5-373f42b110cb"
}

SCHEMA

  • Users table:
| Column Name |       Data Type        |             Description             |
|-------------|------------------------|-------------------------------------|
| uuid        | uuid                   | unique identifier for users         |
| username    | character varying(255) | username chosen by the user         |
| password    | character varying(255) | hash of password chosen by the user |
  • Post table:

| Column Name |       Data Type        |           Description           |
|-------------|------------------------|---------------------------------|
| uuid        | uuid                   | unique identifier for users     |
| post_data   | character varying(140) | post created by the user        |
| createtime  | character varying(255) | time the post was created at.   |
| post_uuid   | uuid                   | unique identifier for each post 
  • Likes table:
| Column Name | Data Type |           Description           |
|-------------|-----------|---------------------------------|
| user_uuid   | uuid      | unique identifier of users     |
| post_uuid   | uuid      | unique identifier of post |
  • Follows table:
|  Column Name  | Data Type |             Description             |
|---------------|-----------|-------------------------------------|
| follower_uuid | uuid      | unique identifier of follower users |
| follows_uuid  | uuid      | unique identifier of followed user  |
  • Auth session table:
| Column Name |       Data Type        |           Description           |
|-------------|------------------------|---------------------------------|
| uuid        | uuid                   | unique identifier of user       |
| auth_token  | character varying(255) | a generated authentication hash for session |

About


Languages

Language:Java 100.0%