Skip to content

RailsChatBot is a Ruby on Rails application that provides a real-time chat interface for users. This application integrates the Gemini AI API to generate answers, and the chats are saved into the database to present the chat history for the user.

License

Notifications You must be signed in to change notification settings

nirbelelti/RailsAIChatBot

Repository files navigation

RailsChatBot

Description

RailsChatBot is a Ruby on Rails application that provides a real-time chat interface for users. This application integrates Devise for user authentication, ensuring secure access, and utilizes Turbo Rails for smooth, dynamic interactions, allowing messages to update without refreshing the page.

The core functionality of RailsChatBot demonstrates seamless communication with the Gemini API, a powerful language generation tool. Through an initializer, the application establishes a connection with the Gemini API, sending user queries and receiving intelligent, conversational responses. This setup highlights how Rails applications can efficiently leverage external APIs for enhanced functionality and user engagement within a Turbo-powered chat interface.

Additionally, RailsChatBot incorporates Sidekiq to handle background processing. By offloading API calls and other tasks to Sidekiq workers, the application maintains a fast, responsive user experience even while handling intensive operations asynchronously. This integration showcases the effective use of background jobs in Rails to optimize performance and scalability.

Features

  • User authentication with Devise
  • CRUD operations for chats utilize Turbo Rails and Hot wire
  • Integration with the Gemini API for language generation
  • Dynamic interactions with Turbo Rails
  • Real-time chat interface
  • Responsive design with Bootstrap CSS
  • Asynchronously views rendering with Hotwire
  • RSpec tests for models, requests, and routes

Requirements

  • Ruby 3.0.2
  • Rails 7.2.0
  • PostgreSQL
  • Redis
  • Gemini API key
  • Bundler
  • Yarn
  • Node.js (npm)

Setup

  1. Clone the repository:

    git clonehttps://github.com/nirbelelti/RailsAIChatBot.git
    cd RailsAIChatBot
    
  2. Install dependencies:

  3. Install dependencies:

    bundle install
    yarn install
  4. Create the database and seed:

      rails db:prepare

    FYI: This command will create the database, load the schema, and initialize it with the seed data. For demonstration purposes, the seed data includes a user with the following credentials: email: '[email protected]', password: 'Password'

  5. Set up the Gemini API key:

    • Create a .env file in the root directory.
    • Add the following line to the .env file
  6. Start the server:

    rails server OR bin/dev
  7. Start the Redis server:

     redis-server
  8. Start the Sidekiq server:

     bundle exec sidekiq
  9. Access the application: The application will be available at http://localhost:3000.

Testing

Run the RSpec tests with the following command:

   rspec

The tests include model, request, and routing specs, ensuring the application's core functionality is working as expected.

License

MIT License

About

RailsChatBot is a Ruby on Rails application that provides a real-time chat interface for users. This application integrates the Gemini AI API to generate answers, and the chats are saved into the database to present the chat history for the user.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published