Skip to content

roALAB1/spark-v2-smart-query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Spark V2 - Smart Query Assistant (CONTEXT-AWARE)

Intelligent query validation with context-aware pattern detection for Intent and B2B search.

🎯 Features

  • Context-Aware Detection: Intelligent pattern matching instead of keyword lists
  • Smart Mode Separation: Understands context, not just keywords
  • 7-Rule Validation System: Comprehensive query quality analysis
  • Real-Time Feedback: Instant validation as you type
  • No False Positives: Distinguishes between topics and filters
  • Advanced Options: Context phrases, lens, and granularity controls

🧠 Context-Aware Intelligence

How It Works

Instead of hard-coded keyword lists, Spark V2 uses intelligent pattern detection:

Location Detection (Context-Aware)

  • βœ… Allows: "interested in San Francisco culture" (topic of interest)
  • ❌ Blocks: "people in San Francisco" (location filter)
  • Logic: Only flags when location is used to filter WHO people are

Persona Detection (Pattern-Based)

  • βœ… Detects: "software engineers", "product managers", "CEOs"
  • βœ… Handles: Plurals, compound titles, variations
  • Logic: Regex patterns match job title structures

Intent Detection (Behavioral)

  • βœ… Detects: "interested in", "passion for", "care about"
  • βœ… Context: Distinguishes intent signals from forbidden terms
  • Logic: Pattern-based behavioral signal detection

πŸ”’ Validation Rules

Intent Mode

FORBIDDEN (context-aware detection):

  • ❌ Personas: Job titles, roles (e.g., "software engineers", "CEOs")
  • ❌ Demographics: Age, gender, income, education
  • ❌ Location Filters: "people in [Location]", "based in [Location]"

ALLOWED:

  • βœ… Location Topics: "interested in San Francisco culture"
  • βœ… Behavioral Intent: "interested in", "passion for", "care about"

REQUIRED:

  • βœ… Intent Signals: Must include behavioral language

Example Good Query:

people interested in sustainable living and environmental conservation

Example Bad Query:

software engineers in San Francisco interested in AI

Fails: persona "software engineers" + location filter "in San Francisco"


B2B Mode

FORBIDDEN (pattern detection):

  • ❌ Intent Language: "interested in", "looking for", "want to"
  • ❌ Behavioral Signals: "recently", "about to", "planning to"

REQUIRED:

  • βœ… Company Attributes: "companies", "revenue", "employees", "industry"

Example Good Query:

SaaS companies with 50-200 employees generating $5M-$20M annual revenue

Example Bad Query:

companies interested in adopting AI technologies

Fails: intent language "interested in"


πŸ“Š Validation Rules (Weighted)

  1. Length Check (10% weight) - 10-500 characters optimal
  2. No Marketing Language (15% weight) - Forbid vague terms
  3. No Questions (15% weight) - Keywords only
  4. Mode Purity (30% weight) - MOST IMPORTANT - Context-aware separation
  5. Specificity (15% weight) - Concrete details
  6. No Keyword Stuffing (10% weight) - Avoid repetition
  7. Actionability (5% weight) - Clear and actionable

βš–οΈ Penalty System

Mode Purity (30% weight) has the highest impact:

  • 1 violation β†’ 40/100 score (~18-point penalty)
  • 2 violations β†’ 20/100 score (~24-point penalty)
  • 3+ violations β†’ 0/100 score (~30-point penalty)

πŸ§ͺ Test Cases

Intent Mode

βœ… Pass (97/100):

people interested in artificial intelligence and machine learning technologies

βœ… Pass (97/100):

people interested in San Francisco culture and Bay Area lifestyle

Topic, not filter - correctly allowed

❌ Fail (79/100):

software engineers interested in AI

Persona detected: "software engineers"

❌ Fail (73/100):

people in San Francisco interested in technology

Location filter detected: "people in San Francisco"

B2B Mode

βœ… Pass (100/100):

SaaS companies with 50-200 employees generating $5M-$20M annual revenue

❌ Fail (79/100):

companies interested in cloud computing technologies

Intent language detected: "interested in"


πŸš€ Quick Start

# Install dependencies
pnpm install

# Start development server
pnpm run dev

# Build for production
pnpm run build

# Preview production build
pnpm run preview

πŸ“¦ Bundle Size

  • Total (gzipped): 147.57 KB
  • JavaScript: 143.23 KB
  • CSS: 4.04 KB
  • HTML: 0.34 KB
  • Status: βœ… Under 150KB target

πŸ› οΈ Tech Stack

  • React 19.2.3 - UI framework
  • TypeScript 5.9.3 - Type safety
  • Vite 7.2.7 - Build tool
  • Tailwind CSS 4.1.18 - Styling
  • Radix UI - Accessible components
  • Lucide React - Icons
  • Wouter - Lightweight routing

πŸ“ Project Structure

src/
β”œβ”€β”€ components/              # UI components
β”‚   β”œβ”€β”€ ModeSelector.tsx     # Intent vs B2B toggle
β”‚   β”œβ”€β”€ QueryInput.tsx       # Query input with counts
β”‚   β”œβ”€β”€ ValidationDisplay.tsx # Score & rules display
β”‚   └── AdvancedOptions.tsx  # Collapsible options
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ queryValidation.ts   # Context-aware validation
β”‚   └── utils.ts             # Utility functions
β”œβ”€β”€ pages/
β”‚   └── SparkPage.tsx        # Main page
β”œβ”€β”€ App.tsx                  # Routing
β”œβ”€β”€ main.tsx                 # Entry point
└── index.css                # Global styles

🎨 Design Principles

  • Context-Aware: Intelligent pattern detection
  • Minimal Dependencies: Only 14 packages
  • Simple Components: 4 focused components
  • Performance First: Bundle under 150KB
  • Accessible: Keyboard navigation, ARIA labels
  • Responsive: Mobile-first design

πŸ“ License

MIT

πŸ™ Acknowledgments

Built with context-aware intelligence for maximum accuracy and minimal false positives.

About

🧠 Spark V2 - Smart Query Assistant with Context-Aware Validation | 147KB bundle, 14 dependencies, zero false positives

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors