Skip to content

alwaysvivek/deepgrep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔍 DeepGrep

Lightning-fast regex meets AI-powered semantic search
Find exact patterns and contextually relevant matches with intelligent history tracking and REST API integration.


🛠️ Tech Stack

Core Development & Language

Language Caching Data Modeling

Web Application Stack

Backend Framework CORS Management Frontend JavaScript Database

Search Engines & NLP

Custom Regex Engine NLP Library SpaCy Model Lexical Data

Quality & Tools

Code Quality API Testing

License

License: MIT


📋 Table of Contents


✨ Features

Feature Description
🔄 Dual-Mode Search Regex pattern matching along with AI-powered semantic search
🧠 Semantic Intelligence Understands context, finds synonyms, and avoids antonyms
📜 History Tracking Maintains searchable history in SQLite with JSON export
🔌 REST API Full programmatic access via clean JSON endpoints
🌐 Web Interface Responsive UI for quick searches and file uploads
Optimized Performance Efficient line scanning with intelligent caching

📸 Screenshots

  • Regex Usage: Shows a complex Regex pattern matching date/time data in a log snippet.
    Regex Matching Output

  • Semantic Search Usage: Shows a Semantic search for "happy" returning "proud" with a similarity score.
    Semantic Search Result

  • Server Log: The server terminal output showing multiple successful POST /semantic calls.
    API Server Log

  • History: The history table view, displaying matches, pattern, and timestamp columns.
    History Database View

  • Postman Output: Shows the Postman interface with the JSON history response from the /search endpoint.
    Postman API History JSON

🚀 Quick Start

Installation

# Clone the repository
git clone https://github.com/yourusername/deepgrep.git
cd deepgrep

# Install dependencies
pip install -r requirements.txt

Running the Server

# Start the API server
python3 -m deepgrep.web.app

The web interface will be available at http://localhost:8000


🔌 API Usage

Regex Search

Endpoint: POST /search

Request:

{
  "pattern": "\\d+",
  "text": "User logged in at 14:32, error code 404"
}

Response:

{
  "matches": ["14", "32", "404"],
  "history": [
    {
      "pattern": "\\d+",
      "timestamp": "2025-10-26T16:00:00",
      "matches_count": 3
    }
  ]
}

Semantic Search

Endpoint: POST /semantic

Request:

{
  "keyword": "happy",
  "text": "She felt joyful and delighted after the announcement"
}

Response:

{
  "matches": [
    {"word": "joyful", "similarity": 0.88},
    {"word": "delighted", "similarity": 0.82}
  ],
  "history": [
    {
      "keyword": "happy",
      "timestamp": "2025-10-26T16:05:00",
      "matches_count": 2
    }
  ]
}

🌐 Web Interface

How to Use

  1. Open http://localhost:8000 in your browser
  2. Choose search mode: Regex or Semantic
  3. Enter your pattern/keyword and text (or upload a file)
  4. Click Search
  5. View results and search history in real-time

🏗️ Architecture

             ┌──────────────────────────┐
             │       Web Frontend       │
             │  (HTML + Tailwind + JS)  │
             │                          │
             │  • Input: Pattern/Keyword│
             │  • Output:               │
             │      - Search Results    │
             │      - Search History    │
             └─────────────┬────────────┘
                           │
                           │ HTTP/REST (JSON)
                           ▼
             ┌──────────────────────────┐
             │       Flask API          │
             │  (Endpoints: /search,    │
             │   /semantic)             │
             │  • Routes requests to    │
             │    Regex or Semantic     │
             │    Engine                │
             │  • Logs history          │
             └─────────────┬────────────┘
                           │
          ┌────────────────┴─────────────────┐
          │                                  │
          ▼                                  ▼
┌─────────────────────┐             ┌─────────────────────┐
│    Regex Engine     │             │  Semantic Engine    │
│  (Pattern Matching) │             │ (SpaCy + WordNet)   │
│  • Fast regex search│             │  • Contextual match │
│  • Backrefs, groups │             │  • Avoid antonyms   │
└─────────────┬───────┘             └─────────────┬───────┘
              │                                   │
              └──────────────┬────────────────────┘
                             ▼
                    ┌──────────────────┐
                    │  Search History  │
                    │   (SQLite DB)    │
                    │  • Logs patterns │
                    │  • Match counts  │
                    │  • Files/context │
                    └──────────────────┘

Key Components

  • Frontend: Displays search results and history with a responsive interface
  • API Layer: Single gateway routing to both search engines
  • Regex Engine: Fast exact pattern matching with support for groups and backreferences
  • Semantic Engine: AI-powered contextual matching using spaCy and WordNet
  • History Database: Persistent SQLite storage with full search history

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


About

DeepGrep – grep as an API, plus AI-powered semantic search.

Topics

Resources

License

Stars

Watchers

Forks