Skip to content

Latest commit

 

History

History
202 lines (156 loc) · 7.69 KB

README.md

File metadata and controls

202 lines (156 loc) · 7.69 KB

Twitter-Like Application with Java and JavaFX

Description

This is a Twitter-like application built using Java and JavaFX for the client-side interface. The application follows an MVC (Model-View-Controller) architecture and interacts with a PostgreSQL database through RESTful API endpoints. The server handles incoming requests, delegates them to the appropriate controllers, which in turn interact with the data access layer to process and retrieve data from the database.

Table of Contents

Installation

To run the application, follow these steps:

  1. Clone the repository to your local machine.

    git clone git@github.com:MahdiHaeri/AP_Project.git
  2. Set up the PostgreSQL database and configure the connection details in the application. Open the DatabaseConnectionManager.java file located at com/example/server/data_access/DatabaseConnectionManager.java.

    package com.example.server.data_access;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    
    public class DatabaseConnectionManager {
        private static final String JDBC_URL = "jdbc:postgresql://your_postgresql_host:your_port/your_database_name";
        private static final String USERNAME = "your_username";
        private static final String PASSWORD = "your_password";
    
        private static Connection connection;
    
        private DatabaseConnectionManager() {
            // Private constructor to prevent instantiation
        }
    
        public static Connection getConnection() throws SQLException {
            if (connection == null || connection.isClosed()) {
                connection = DriverManager.getConnection(JDBC_URL, USERNAME, PASSWORD);
            }
            return connection;
        }
    }
  3. In the DatabaseConnectionManager.java file, modify the following lines to match your PostgreSQL database configuration:

    private static final String JDBC_URL = "jdbc:postgresql://your_postgresql_host:your_port/your_database_name";
    private static final String USERNAME = "your_username";
    private static final String PASSWORD = "your_password";
  4. Build and run the server component.

  5. Build and run the client application.

Make sure to replace the placeholders (e.g., your_username, your_database_name, etc.) with the actual values relevant to your PostgreSQL database setup.

After following these steps, users will be able to set up the database connection correctly and run your application smoothly.

Features

  1. User Management

    • Create, retrieve, update, and delete users.
    • Manage user bios and profile images.
    • Follow/unfollow other users.
    • Block/unblock other users.
  2. Tweet Management

    • Create, retrieve, and delete tweets.
    • Reply, retweet, and quote tweets.
    • Like and unlike tweets.
  3. Timeline

    • View the timeline of tweets from followed users.
  4. User Profile

    • View user profiles.
    • Edit own profile details.
  5. Messaging and Notifications

    • View and send messages.
    • View notifications.

Endpoints

Below are the available API endpoints in the server:

// User Endpoints
GET /api/users
GET /api/users/:username
POST /api/users
DELETE /api/users/:username
DELETE /api/users
PUT /api/users/:username

// Bio Endpoints
GET /api/bios
GET /api/users/:username/bio
POST /api/users/:username/bio
PUT /api/users/:username/bio
DELETE /api/users/:username/bio
DELETE /api/bios

// Follow Endpoints
POST /api/users/:username/follow
POST /api/users/:username/unfollow
GET /api/users/:username/followers
GET /api/users/:username/following
GET /api/follows

// Block Endpoints
POST /api/users/:username/block
POST /api/users/:username/unblock
GET /api/blocks
GET /api/users/:username/blockers
GET /api/users/:username/blocking

// Tweet Endpoints
POST /api/tweets
GET /api/tweets
GET /api/tweets/:tweetId
DELETE /api/tweets/:tweetId
DELETE /api/tweets
GET /api/users/:username/tweets
GET /api/timeline
POST /api/tweets/:tweetId/retweet
POST /api/tweets/:tweetId/quote
POST /api/tweets/:tweetId/reply
GET /api/tweets/:tweetId/replies
GET /api/tweets/:tweetId/retweets
GET /api/tweets/:tweetId/quotes

// Login Endpoint
POST /api/login

// Like Endpoints
GET /api/likes
GET /api/users/:username/likes
GET /api/tweets/:tweetId/likes
POST /api/tweets/:tweetId/like
POST /api/tweets/:tweetId/unlike

// Media Endpoints
GET /api/users/:username/profile-image
GET /api/users/:username/header-image
POST /api/users/:username/profile-image
POST /api/users/:username/header-image
GET /api/tweets/:tweetId/tweet-image
POST /api/tweets/:tweetId/tweet-image

Screenshots

Login Signup
login signup
Light Dark
light_timeline dark_timeline
light_notification dark_notification
light_messages dark_messages
light_bookmark dark_bookmark
light_profile2 dark_profile2
light_editProfile2 dark_editProfile2
light_follow dark_follow

Technologies Used

  • Java
  • JavaFX
  • PostgreSQL
  • HTTP Server (https://sparkjava.com/)
  • RESTful API
  • JWT authentication
  • MVC Architecture
  • JSON
  • Data Access Object (DAO) pattern

License

The Twitter Simulation project is licensed under the MIT License. You are free to modify and distribute the project according to the terms of the license.

Contributing

Contributions to the Twitter Simulation project are welcome! If you want to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and ensure that the codebase passes all tests.
  4. Submit a pull request describing your changes.