Overview
UI/UX Pro Max uses a custom-built BM25 ranking algorithm to search across multiple CSV databases containing UI styles, color palettes, typography, UX guidelines, and more. The search engine is implemented in pure Python with no external dependencies, making it fast, lightweight, and easy to deploy across all AI coding platforms.Architecture
The search engine consists of two main components:1. Core Search Engine (core.py)
Implements the BM25 algorithm and provides domain-specific search functions.
2. Design System Generator (design_system.py)
Orchestrates multi-domain searches and applies reasoning rules. See Design System Generation.
BM25 Algorithm
What is BM25?
BM25 (Best Matching 25) is a probabilistic ranking function used by search engines. It ranks documents based on the query terms appearing in each document, considering:- Term Frequency (TF): How often a term appears in the document
- Inverse Document Frequency (IDF): How rare a term is across all documents
- Document Length Normalization: Adjusts for longer documents having more term matches
Implementation
Fromcore.py:src/ui-ux-pro-max/scripts/core.py:96:
k1=1.5: Controls term frequency saturation (higher = more weight on term frequency)b=0.75: Controls document length normalization (0 = no normalization, 1 = full normalization)
Tokenization
Fromcore.py:src/ui-ux-pro-max/scripts/core.py:109:
- Converts text to lowercase
- Removes all punctuation
- Splits on whitespace
- Filters out words with 2 or fewer characters
Index Building
Fromcore.py:src/ui-ux-pro-max/scripts/core.py:114:
- Tokenized corpus: All documents split into terms
- Document lengths: For normalization
- Average document length: For length penalty
- Document frequencies: How many documents contain each term
- IDF scores: Inverse document frequency for each term
Scoring
Fromcore.py:src/ui-ux-pro-max/scripts/core.py:133:
D= documentQ= queryqi= query termtf(qi, D)= frequency of term qi in document D|D|= length of document Davgdl= average document length
Domain Configuration
The search engine supports 10 different domains, each with its own CSV file and search configuration. Fromcore.py:src/ui-ux-pro-max/scripts/core.py:17:
Available Domains
| Domain | CSV File | Search Columns | Purpose |
|---|---|---|---|
style | styles.csv | Style Category, Keywords, Best For, AI Prompt Keywords | Find UI styles (67 total) |
color | colors.csv | Product Type, Notes | Find color palettes (96 total) |
typography | typography.csv | Font Pairing Name, Mood/Style Keywords, Best For | Find font pairings (57 total) |
chart | charts.csv | Data Type, Keywords, Best Chart Type | Find chart recommendations (25 types) |
landing | landing.csv | Pattern Name, Keywords, Section Order | Find landing page patterns (24 patterns) |
product | products.csv | Product Type, Keywords, Primary Style | Match product types (100 categories) |
ux | ux-guidelines.csv | Category, Issue, Description | UX best practices (99 guidelines) |
icons | icons.csv | Category, Icon Name, Keywords | Icon recommendations |
react | react-performance.csv | Category, Issue, Keywords | React/Next.js performance |
web | web-interface.csv | Category, Issue, Keywords | Web interface guidelines |
Auto-Domain Detection
If you don’t specify a--domain flag, the search engine automatically detects the most relevant domain.
From core.py:src/ui-ux-pro-max/scripts/core.py:190:
If no keywords match any domain, it defaults to
style domain.Stack-Specific Search
The search engine also supports stack-specific guidelines for 13 different technology stacks. Fromcore.py:src/ui-ux-pro-max/scripts/core.py:70:
Stack Search Example
stacks/react.csv for React-specific form validation guidelines.
Search Functions
Core Search Function
Fromcore.py:src/ui-ux-pro-max/scripts/core.py:165:
- Only returns results with score > 0 (must have at least one matching term)
- Returns only the specified output columns (not all CSV columns)
- Sorted by relevance (highest BM25 score first)
Main Search API
Fromcore.py:src/ui-ux-pro-max/scripts/core.py:212:
Performance Characteristics
Time Complexity
- Index building: O(n × m) where n = documents, m = average document length
- Query scoring: O(n × q) where n = documents, q = query terms
- Overall: Linear in the number of documents
Memory Usage
- Corpus storage: ~500KB for all CSV files
- Index storage: ~200KB for tokenized corpus and IDF scores
- Total: < 1MB in memory
Why No Persistent Index?
The search engine doesn’t persist the BM25 index to disk because:- Fast rebuild: Indexing 500KB of CSV data takes < 50ms
- Simplicity: No cache invalidation or version management needed
- Portability: Works across all platforms without file system writes
- Fresh results: Always uses the latest CSV data
Example Search Flows
Example 1: Style Search
- Tokenize query:
["glassmorphism", "dark", "mode"] - Load
styles.csv(67 rows) - Build BM25 index from search columns: Style Category, Keywords, Best For, Type, AI Prompt Keywords
- Score all 67 documents
- Return top 3 results with highest BM25 scores
Example 2: Auto-Domain Detection
- Detect domain from keywords:
color(matches “color”, “palette”) - Load
colors.csv(96 rows) - Build BM25 index from search columns: Product Type, Notes
- Score all 96 documents
- Return top 3 results
Example 3: Stack Search
- Load
stacks/html-tailwind.csv - Build BM25 index from search columns: Category, Guideline, Description, Do, Don’t
- Score all documents
- Return top 3 results with code examples
Configuration
Fromcore.py:src/ui-ux-pro-max/scripts/core.py:14:
- DATA_DIR: Relative path to CSV data files
- MAX_RESULTS: Default number of results to return (can be overridden with
-nflag)
See Also
- Design System Generation - How search powers design system generation
- Reasoning Rules - Industry-specific rules that guide search result selection