/real-time-search-box

This app enables users to search for articles in real-time and provides analytics on their search queries.

Primary LanguageRuby

Rails Postgres JavaScript

Real-Time Search Box

📗 Table of Contents

📖 Real-time Search Box

Real-Time Search Box is an app that enables users to search for articles in real-time and provides analytics on their search queries.

🛠 Built With

Tech Stack

Client
Server
Database

Key Features

  • Search for articles and view results as you type
  • Automatically save search history
  • Access previous searches on the Latest Search page

The user interface for the search box and search results was designed using erb and JavaScript. JavaScript was chosen because it's difficult to listen to user typing with only erb. By utilizing JavaScript events, the search function can respond immediately to user input. When a search query matches an article, the corresponding article is immediately displayed. In cases where the user stops typing for more than 5 seconds, the search query is recorded and sent to the backend for processing.

(back to top)

🚀 Live Demo

(back to top)

💻 Getting Started

To get a local copy up and running, follow these steps.

Prerequisites

  • Ruby version: 3.2.1
  • Ruby on Rails version: 7.0.3.1

Setup

Clone this repository to your desired folder:

  cd my-folder
  git clone https://github.com/medaminedev66/real-time-search-box.git
  cd real-time-search-box

Install

Install this project with:

bundle install

# create migrations with activerecord
rails db:migrate

# if you would like to use seed data
rails db:seed

Usage

To run the project, execute the following command:

# start server
rails s

RoR uses port 3000 by default

Run tests

To run tests, run the following command:

# run tests with
rspec spec

Deployment

Heroku has been used to deploy this project. You can use it as well or use other alternatives such as Render, Fly...

(back to top)

👤 Author

Amine Smahi

(back to top)

🔭 Future Features

  • Add sessions using Devise to record searches for each user.
  • Create a backend algorithm that searches for articles and displays them on another page.

(back to top)

🤝 Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page.

(back to top)

⭐️ Show your support

Give a ⭐️ if you like this project!

(back to top)

🙏 Acknowledgments

I would like to thank ChatGpt, StackOver flow community for the help and support.

(back to top)

❓ FAQ

  • Why are the rspec tests failing?

    • I'm using capybara and selenium gems that help me to write and run tests. Selenium is a popular tool for automating web browser interactions. You will need to have a web browser installed on your local machine. We recommend using Mozilla Firefox, as that is the browser I use in my testing environment. If you already have Firefox and you still have errors, these errors occurs when the Firefox driver is unable to find the Firefox binary location. By default, the driver will look for the Firefox binary in a set of default locations, but if it is not found, you will see this error. To fix these errors, you can specify the location of the Firefox binary using the :firefox_binary option in the Capybara configuration in spec/rails_helper.rb or spec/spec_helper.rb:

(back to top)

📝 License

This project is MIT licensed.

(back to top)