Skip to content

NiharP31/DIgital_Memory

Repository files navigation

Digital Memory - Web Activity Intelligence System

An Electron-based desktop application that creates a searchable visual memory of your digital life by continuously capturing screen activity and transforming it into queryable, time-aware intelligence powered by Tavily API.

🎯 Overview

Digital Memory acts as your "digital photographic memory" - capturing, indexing, and enriching your screen activity to make everything you've seen searchable. Built for the Tavily Multimodal Web Agents Hackathon, it demonstrates innovative use of Tavily's APIs to bridge local and web knowledge.

📋 Prerequisites

System Requirements

  • Node.js: v18.0.0 or higher (v23.9.0 recommended)
  • npm: v8.0.0 or higher
  • Operating System: macOS, Windows, or Linux
  • RAM: 4GB minimum, 8GB recommended
  • Storage: 2GB free space for app + captured data

API Requirements

  • Tavily API Key: Get yours at tavily.com
    • Free tier: 1,000 requests/month
    • Hackathon tier: Enhanced limits available

🚀 Development Setup

1. Clone and Install

# Clone the repository
git clone [repository-url]
cd digital-memory

# Install dependencies
npm install

# Install additional type definitions if needed
npm install --save-dev @types/better-sqlite3

2. Configure Environment (Optional)

The app works out of the box without configuration. For Tavily API integration (when implemented), create a .env file:

# Tavily API Integration (placeholder - not yet implemented)
TAVILY_API_KEY=tvly-YOUR_API_KEY_HERE

Note: Environment variables are not currently used by the application. The capture interval is dynamically adjusted based on user activity (15-60 seconds).

3. Development Commands

# Start in development mode with hot reload
npm start

# Run TypeScript compiler check
npx tsc --noEmit

# Lint the code
npm run lint

# Run tests (not yet implemented)
# npm test

4. Development Tools

The app uses Electron Forge with Webpack for optimal development experience:

  • Hot Reload: Changes to renderer process auto-reload
  • DevTools: Automatically opened in development
  • Source Maps: Full debugging support
  • TypeScript: Type checking and IntelliSense

Project Structure

digital-memory/
├── src/
│   ├── main/                 # Main process code
│   │   ├── capture.ts        # Screen capture logic
│   │   └── services/         # Main process services
│   │       └── captureCoordinator.ts # Capture coordination
│   ├── services/             # Core services
│   │   ├── database.ts       # SQLite with FTS5
│   │   ├── ocr.ts           # Tesseract.js integration
│   │   └── tavily.ts        # Tavily API client (placeholder)
│   ├── renderer/             # Renderer process code
│   │   ├── search/          # Search UI components
│   │   ├── dashboard/       # Dashboard components
│   │   └── components/      # Shared components
│   ├── types/               # TypeScript type definitions
│   │   └── index.d.ts       # Global type declarations
│   ├── utils/               # Utility functions
│   │   ├── colors.ts        # Activity color mapping
│   │   └── formatters.ts    # Time/data formatters
│   ├── index.ts             # Main process entry point
│   ├── preload.ts           # Secure IPC bridge
│   ├── renderer.ts          # Main UI logic
│   ├── index.html           # App HTML
│   └── index.css            # Styles
├── .env                     # Environment variables (optional)
├── .env.example             # Example environment config
├── forge.config.ts          # Electron Forge config
├── webpack.*.config.ts      # Webpack configurations
├── package.json             # Dependencies and scripts
└── tsconfig.json           # TypeScript config

🏗️ Building for Production

1. Package the Application

# Create packaged app for your current platform
npm run package

# Output location
# macOS: out/digital-memory-darwin-arm64/digital-memory.app
# Windows: out/digital-memory-win32-x64/digital-memory.exe
# Linux: out/digital-memory-linux-x64/digital-memory

2. Create Distributables

# Create distributable installer for current platform
npm run make

# Creates:
# macOS: .dmg installer
# Windows: .exe installer
# Linux: .deb/.rpm packages

3. Build for All Platforms

# Build for all platforms (requires appropriate toolchain)
npm run publish

# Note: Cross-platform builds may require additional setup:
# - Windows: Wine for building on macOS/Linux
# - macOS: Requires macOS for code signing
# - Linux: Native or Docker environment

4. Build Configuration

Edit forge.config.ts to customize:

  • App icons and metadata
  • Code signing certificates
  • Auto-update configuration
  • Platform-specific options

🖥️ Runtime Usage

Installation

From Built Package

  1. Download the appropriate package for your OS
  2. Install following platform conventions:
    • macOS: Drag to Applications folder
    • Windows: Run installer .exe
    • Linux: Install .deb/.rpm package

From Source

npm install
npm start

First Run Setup

  1. Launch the app: It will appear in your system tray
  2. Configure Tavily API:
    • Right-click tray icon → Settings
    • Enter your Tavily API key
    • Save settings
  3. Start capturing:
    • Right-click tray icon → Start Capture
    • Or use the dashboard toggle

Features & Shortcuts

System Tray Menu

  • Start/Pause Capture: Toggle screen capturing
  • Open Dashboard: View timeline and statistics
  • Search: Open spotlight search
  • Settings: Configure API keys and preferences
  • Quit: Exit application

Keyboard Shortcuts

  • Cmd/Ctrl + Shift + Space: Open quick search
  • Escape: Close search overlay
  • Cmd/Ctrl + ,: Open settings (when focused)

Dynamic Capture Intervals

The app intelligently adjusts capture frequency based on activity:

  • Active (< 10s idle): 15-second intervals
  • Moderate (10-60s idle): 30-second intervals
  • Idle (60-300s idle): 60-second intervals
  • Very Idle (> 5 min): Stops capturing automatically

Dashboard Features

  • Real-time Updates: Dashboard refreshes every 30 seconds
  • Secure Image Loading: Screenshots loaded via IPC for security
  • OCR Processing: Automatic text extraction from screenshots
  • Activity Detection: Categorizes activity (coding, browsing, etc.)

Search Capabilities

  • Natural Language: "Python error from this morning"
  • App Filter: "in:vscode authentication"
  • Time Range: "yesterday React hooks"
  • Error Detection: Automatically highlights errors

Data Management

Storage Locations

  • Database: ~/Library/Application Support/digital-memory/digital-memory.db
  • Screenshots: ~/Library/Application Support/digital-memory/screenshots/
  • Electron Cache: ~/Library/Application Support/digital-memory/Cache/
  • Settings: ~/Library/Application Support/digital-memory/Preferences

Privacy & Security

  • All data stored locally by default
  • Screenshots compressed with Sharp (WebP format)
  • Tavily API called only when:
    • User triggers enrichment
    • URL detected in screenshot
    • Error message found
  • Automatic cleanup of old data (configurable retention)

Troubleshooting

App Won't Start

# Check for port conflicts
lsof -i :9000

# Clear cache and restart
rm -rf ~/Library/Application\ Support/digital-memory/cache

Capture Not Working

  1. Grant screen recording permissions:
    • macOS: System Preferences → Security & Privacy → Screen Recording
    • Windows: Approve UAC prompt
    • Linux: May need X11 permissions

OCR Issues

# Clear Tesseract cache
rm -rf ~/Library/Application\ Support/digital-memory/tesseract-cache

# Reinstall Tesseract data
npm rebuild tesseract.js

Database Errors

# Backup existing database
cp ~/Library/Application\ Support/digital-memory/digital-memory.db ./backup.db

# Reset database (loses all data)
rm ~/Library/Application\ Support/digital-memory/digital-memory.db

Performance Optimization

Adjust Capture Settings

// In settings or .env
CAPTURE_INTERVAL=60000  // Increase to 60s for less CPU usage
OCR_ENABLED=false       // Disable OCR if not needed
IMAGE_QUALITY=60        // Reduce quality (default: 80)
MAX_IMAGE_WIDTH=1920    // Limit screenshot dimensions

Database Maintenance

-- Run via database tool
VACUUM;                 -- Optimize database
ANALYZE;               -- Update statistics
DELETE FROM screenshots WHERE timestamp < strftime('%s', 'now', '-30 days') * 1000;

🔌 Tavily API Integration

API Endpoints Used

  1. Search API (/search)

    • Error resolution
    • Context finding
    • Daily summaries
  2. Extract API (/extract)

    • URL content extraction
    • Full article retrieval
    • Documentation fetching

API Usage Examples

// Tavily integration is currently a placeholder
// The TavilyService class exists but methods are not implemented
// Future implementation will include:

// Enrich screenshot with URL content
// await tavilyService.enrichWithContext(screenshotId, urls);

// Search for error solutions
// await tavilyService.findSolution(errorText);

// Note: Enrichment can be triggered via the dashboard
// by clicking on a screenshot (calls enrichScreenshot IPC)

API Credit Management

  • Cache all Tavily responses (24-hour TTL)
  • Batch enrichment requests when possible
  • Use search_depth: 'basic' by default
  • Manual enrichment trigger to control usage

🐛 Development Tips

Debug Mode

# Enable debug logging
DEBUG=true npm start

# View Electron logs
~/Library/Logs/digital-memory/main.log

Testing Capture

// In DevTools console
await window.electronAPI.startCapture();
// Wait a moment
const screenshots = await window.electronAPI.getRecentScreenshots(5);
console.log(screenshots);

Mock Tavily Responses

// In development, set in tavily.ts
const MOCK_MODE = process.env.NODE_ENV === 'development';
if (MOCK_MODE) {
  return mockTavilyResponse();
}

📦 Dependencies

Core

  • electron: Desktop framework
  • electron-forge: Build toolchain
  • typescript: Type safety

Database

  • better-sqlite3: SQLite with FTS5
  • electron-store: Settings persistence

Image Processing

  • tesseract.js: OCR processing
    • Uses eng.traineddata file (included in project root)
    • Pre-trained English language model for text recognition
    • Enables text extraction from screenshots for searchability
  • screenshot-desktop: Screen capture
  • Native Electron APIs for image handling

API & Networking

  • axios: HTTP client
  • dotenv: Environment config

UI

  • bootstrap: UI components
  • jquery: DOM manipulation

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

📄 License

MIT License - Created for Tavily Hackathon 2024

🔗 Resources

🙏 Acknowledgments

Built with ❤️ for the Tavily Multimodal Web Agents Hackathon

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors