Skip to content

karagenit/keep-organizer

Repository files navigation

Google Keep Organizer

A Ruby Sinatra web application that helps organize Google Keep notes by automatically splitting them into categorized sub-notes using AI, with optional Google Tasks integration for seamless task management.

Features

  • AI-Powered Note Splitting: Uses LLM to intelligently split large Keep notes into focused sub-notes
  • Smart Categorization: Automatically categorizes sub-notes by topic (TODO, Projects, Shopping, etc.)
  • Interactive Organization: Drag & drop interface for recategorizing and managing sub-notes
  • Google Tasks Integration: Automatically creates Google Tasks from organized notes (optional)
  • Flexible Saving: Export organized notes to YAML files for backup and reference

Setup

Prerequisites

  • Ruby 3.0+ installed on your system
  • Bundler gem (gem install bundler)
  • An Anthropic API key (for LLM functionality)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd keep-organizer
  2. Install dependencies

    bundle install
  3. Environment configuration Create a .env file in the project root:

    touch .env

    Add your Anthropic API key to the .env file:

    ANTHROPIC_API_KEY=your_api_key_here
    

    Get your API key from Anthropic Console

  4. Google Tasks Integration (Optional) To enable automatic Google Tasks creation:

    a. Create Google Cloud Project:

    • Go to Google Cloud Console
    • Create a new project or select existing one
    • Enable the Google Tasks API

    b. Setup OAuth2 Credentials:

    • Go to "Credentials" in the Google Cloud Console
    • Create "OAuth 2.0 Client ID" credentials
    • Set application type to "Desktop application"
    • Download the credentials JSON file

    c. Install Credentials:

    • Rename the downloaded file to secret.json
    • Place it in the project root directory
    • The first run will require OAuth2 authentication in your browser

    d. Task List Mapping:

    • Notes categorized as "Todo" go to your default Google Tasks list
    • Other categories attempt to match existing task list names
    • Unmatched categories fall back to the default list
  5. Verify directories The testcases/ directory should already exist for saving organized notes.

Running the Application

Production mode (with LLM):

ruby app.rb

Development mode (mock LLM, no API calls):

ruby app.rb --mockLLM

The app will start on http://localhost:4567

Usage

  1. Input: Paste your Google Keep note content into the text area
  2. Process: Click "Process Note" to split and categorize using AI
  3. Organize: Review and edit the categorized sub-notes using:
    • Drag & drop to move notes between categories
    • Split buttons to break up multi-line notes
    • Delete buttons to remove unwanted notes
    • Add buttons to create new notes in any category
  4. Save: Click "Save to YAML" to:
    • Export organized notes to YAML files in testcases/ directory
    • Automatically create Google Tasks (if configured)
    • Get confirmation of successful task creation

Development Notes

  • Use --mockLLM flag to avoid API costs during development
  • Mock mode splits notes line-by-line and categorizes everything as TODO
  • The app uses Sinatra with vanilla JavaScript frontend

Testing

The project uses RSpec for testing Ruby code.

Install test dependencies:

bundle install

Run all tests:

# Run all tests together
bundle exec rspec

Code linting:

# Check Ruby code style and potential issues
bundle exec rubocop

# Auto-fix correctable issues
bundle exec rubocop --autocorrect

Test structure:

  • spec/unit/ - Unit tests for all Ruby components
    • app_index_spec.rb - Tests for index route (GET /)
    • app_process_spec.rb - Tests for process route (POST /process) including both LLM and mock modes
    • app_save_spec.rb - Tests for save route (POST /save) with filesystem mocking
    • llm_spec.rb - Tests for LLMService class with comprehensive API mocking
  • spec/integration/ - End-to-end integration tests
    • index_page_spec.rb - JavaScript testing with Selenium Chrome headless driver for complete workflow:
      • AJAX form submission and DOM updates
      • Add note button functionality
      • Drag and drop between categories
      • Textarea drag prevention (preserves text selection)
      • Split button appearance and functionality for multiline notes
      • Split button logic for blank lines (buttons hidden when next line is blank)
      • Delete button functionality (with confirmation for non-empty notes)

Test Safety:

  • All tests remove the ANTHROPIC_API_KEY environment variable to prevent real API calls
  • External HTTP requests are blocked using WebMock for unit tests only (doesn't interfere with integration tests)
  • LLM service calls are mocked to avoid costs and ensure reliable testing
  • Filesystem operations are mocked to prevent writing test files to disk
  • Mock LLM mode testing uses test-specific app subclasses for proper isolation
  • Integration tests use Selenium Chrome headless driver and can run alongside unit tests

About

Organizing Google Keep Notes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published