The Social Network CLI is a project originally created as an academic assignment in TypeScript. Later, it was rewritten in Ruby, bringing numerous improvements and additional features compared to the original version.
- Project Description
- Features
- Project Structure
- Installation Guide
- Testing
- Contributing
- License
- Contact
This project provided an opportunity to study and apply various programming concepts and best practices, such as:
- Object-Oriented Programming (OOP) in Ruby;
- A modular architecture that emulates the MVC pattern;
- Managing data persistence with JSON;
- Encrypting passwords with bcrypt;
- Creating terminal interfaces with tty-prompt;
- Managing dependencies with Bundler;
- Maintaining clean and organized code with Rubocop;
- Writing unit tests with RSpec;
- Ensuring clean and isolated tests with Tempfile.
- Protected login with credential validation.
- User registration functionality.
- Passwords securely stored using bcrypt.
- Create profiles during registration.
- View your own profile or other users' profiles.
- List all posts of a specific profile.
- Create posts with or without hashtags.
- Highlight hashtags, displayed in blue.
- Search posts by text or hashtags.
- Search for:
- Posts containing specific text.
- Hashtags (starting with
#). - Users (starting with
@).
- Like or dislike posts.
- Follow or unfollow profiles:
- Options dynamically change based on the current state (following or not).
- Automatically saves profiles and posts in JSON files.
- Data is loaded automatically when the program starts.
The project follows a modular architecture for better scalability and maintainability:
social-network
├── app/
│ ├── controllers/ # Controllers (flow logic)
│ ├── data/ # Persisted JSON data
│ ├── models/ # Models (business logic)
│ ├── repositories/ # Data management repositories
│ ├── services/ # Business logic encapsulation
│ └── views/ # User-facing interfaces
├── spec/ # Tests directory
│ ├── services/ # Tests for the services layer
│ └── repositories/ # Tests for the repositories layer
├── app.rb # Main entry point
├── Gemfile # Dependency manager
├── Gemfile.lock # Locked dependency versions
├── License # Project license
└── README.md # Documentation
Make sure you have the following dependencies installed:
- Version 3.0 or higher.
- Check your version with:
ruby --version
- Install from the official site: ruby-lang.org.
- Install using:
gem install bundler
-
Clone the repository:
git clone https://github.com/rsmwall/social-network-cli.git cd social-network-cli -
Install dependencies:
bundle install
-
Set up data files: Create the necessary directories and files:
mkdir -p app/data echo '[]' > app/data/profiles.json echo '[]' > app/data/posts.json
-
Run the application:
ruby app.rb
This project uses RSpec for unit testing. The test suite is designed to ensure the reliability of key functionalities like authentication and data persistence.
To run the entire test suite, execute the following command in the project's root directory:
bundle exec rspecTo run a specific test file, provide the path to the file:
bundle exec rspec spec/services/authentication_spec.rbContributions are welcome! To contribute:
-
Fork the repository.
-
Create a new branch for your feature or bug fix:
git checkout -b my-feature
-
Submit a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
Author: Rafael Silva
GitHub: rsmwall
Email: rafaelrsilva.dev@gmail.com
Bluesky: @rsmwall.bsky.social