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.
To run the application, follow these steps:
-
Clone the repository to your local machine.
git clone [email protected]:MahdiHaeri/AP_Project.git
-
Set up the PostgreSQL database and configure the connection details in the application. Open the
DatabaseConnectionManager.java
file located atcom/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; } }
-
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";
-
Build and run the server component.
-
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.
-
User Management
- Create, retrieve, update, and delete users.
- Manage user bios and profile images.
- Follow/unfollow other users.
- Block/unblock other users.
-
Tweet Management
- Create, retrieve, and delete tweets.
- Reply, retweet, and quote tweets.
- Like and unlike tweets.
-
Timeline
- View the timeline of tweets from followed users.
-
User Profile
- View user profiles.
- Edit own profile details.
-
Messaging and Notifications
- View and send messages.
- View notifications.
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
Login | Signup |
---|---|
Light | Dark |
- Java
- JavaFX
- PostgreSQL
- HTTP Server (https://sparkjava.com/)
- RESTful API
- JWT authentication
- MVC Architecture
- JSON
- Data Access Object (DAO) pattern
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.
Contributions to the Twitter Simulation project are welcome! If you want to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and ensure that the codebase passes all tests.
- Submit a pull request describing your changes.