Nwitter-Offline-CLI is a lightweight, terminal-based version of the Nwitter social ecosystem. Unlike its network-connected counterparts, this application runs entirely on the client machine without a backend server. It simulates a full-featured social media experience—including tweeting, messaging, and profile management—by reading and writing data directly to local JSON files (Twittes.json, Users.json, etc.).
This project serves as an excellent demonstration of Object-Oriented Programming (OOP) principles in Java and handling data persistence without a traditional database engine.
- Command-Line Interface: A retro-styled text interface enhanced with
ConsoleColorsfor better readability and navigation. - Local Persistence: All data (users, tweets, messages) is stored in readable JSON files within the project directory.
- User System: Full authentication flow including Login, Registration, and Profile Editing.
- Timeline & Explorer: View tweets in a chronological feed or explore random posts from the global pool.
- Social Interactions: Like posts, add comments, and retweet content.
- Direct Messaging: Send and receive messages (simulated locally between users stored in
Users.json). - Notifications: System alerts for likes, follows, and messages.
- Java Development Kit (JDK): Version 11 or higher.
- Build Tool: Gradle (optional, wrapper included).
- Dependencies:
gson-2.8.6.jar(for JSON parsing)log4j-core/log4j-api(for logging)
The source code is located in src/main/java/.
Main.java: The entry point. It initializes the application loop and directs the user to the Login/Register start screen.ConsoleColors.java: A utility class containing ANSI escape sequences to colorize terminal text (e.g., Red for errors, Green for success, Blue for headers).
These classes handle the display logic for specific sections of the app:
Login.java/Register.java: Handle user input for authentication and account creation.Feed.java/Home.java: Display the user's personal timeline.Expelorer.java: Shows the "Explorer" page (global tweets).Messenger.java/chatPage.java: Interfaces for listing chats and viewing conversation history.Setting.java: Menu for changing passwords, privacy settings, or deleting the account.Info.java: Displays system information or user notifications.
obj*.java(e.g.,objUser.java,objTwitte.java): Plain Java Objects representing the data models.json*.java(e.g.,jsonUsers.java,jsonTwittes.java): These classes are responsible for:- Reading the raw
.jsonfiles from the disk. - Deserializing them into
objlists using GSON. - Providing helper methods to find specific users or tweets.
- Reading the raw
submit*.java: These classes contain the business logic for user actions.submitTwitte.java: Creates a new tweet object and saves it toTwittes.json.submitLike.java: Toggles like status on a post.submitMessage.java: Appends a new message toMessage.json.submitAction.java: General handler for form submissions.
Users.json: Stores user credentials and profile info.Twittes.json: Stores all tweets created in the system.Message.json: Stores chat logs.Notifs.json: Stores pending notifications.
git clone https://github.com/nikelroid/nwitter.git
cd nwitterUse the included Gradle wrapper to build the project:
# Linux/Mac
./gradlew build
# Windows
gradlew.bat buildYou can run it directly via Gradle or by compiling the Java files manually.
Option A: Via Gradle
./gradlew runOption B: Manual Compilation (if Gradle fails)
Ensure the lib folder is in your classpath.
# Compile
javac -cp "lib/*:src/main/java" src/main/java/Main.java
# Run
java -cp "lib/*:src/main/java" MainOnce the application starts in your terminal:
- Navigation: Use the number keys (e.g.,
1,2,3) to select menu options displayed on the screen. - Login: Enter your
usernameandpasswordwhen prompted. - Posting: Select the "New Tweet" option, type your text, and press Enter.
- Exit: Usually option
4or0(depending on the specific menu) allows you to go back or exit.
Note: Since this is offline, "messaging" another user simply writes to the shared local JSON file. If you log out and log in as the other user, you will see the message.
Pull requests are welcome. Since this project relies on specific JSON structures, please ensure any changes to the obj classes are reflected in the json parsing logic to avoid corruption of the database files.
Distributed under the MIT License.
Project Maintainer - GitHub Profile