{"id":50503528,"url":"https://github.com/meathill/mui-search","last_synced_at":"2026-06-02T13:32:17.313Z","repository":{"id":346738193,"uuid":"1191195013","full_name":"meathill/mui-search","owner":"meathill","description":"A Hybrid (Full-text + RAG) Serverless Search Engine built on TiDB Cloud and Cloudflare Worker","archived":false,"fork":false,"pushed_at":"2026-04-18T09:45:49.000Z","size":500,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-18T11:40:09.309Z","etag":null,"topics":["hybrid-search","rag","search","tidbcloud"],"latest_commit_sha":null,"homepage":"https://mui-search.meathill.com/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meathill.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-25T02:21:21.000Z","updated_at":"2026-04-18T09:45:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/meathill/mui-search","commit_stats":null,"previous_names":["meathill/mui-search"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/meathill/mui-search","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meathill%2Fmui-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meathill%2Fmui-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meathill%2Fmui-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meathill%2Fmui-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meathill","download_url":"https://codeload.github.com/meathill/mui-search/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meathill%2Fmui-search/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33824899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hybrid-search","rag","search","tidbcloud"],"created_at":"2026-06-02T13:32:16.115Z","updated_at":"2026-06-02T13:32:17.307Z","avatar_url":"https://github.com/meathill.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MUI Search\n\nAn open-source hybrid search engine powered by **Cloudflare Workers** and **TiDB Cloud**.\n\nCombines full-text keyword search with vector semantic matching, merged using Reciprocal Rank Fusion (RRF) for best-in-class relevance. Deployed at the edge with multi-layer caching for millisecond responses.\n\n## Features\n\n- **Hybrid Search** — Full-text + vector semantic search, fused with RRF ranking\n- **Edge Computing** — Runs on Cloudflare Workers with smart placement, globally low latency\n- **Multi-Layer Caching** — Worker Cache API + KV store, 7-day data cache\n- **Embeddable Widget** — Preact IIFE widget, one `data-mui-search` attribute to integrate\n- **38 Languages** — Per-locale widget bundles, auto-detect or explicit\n- **Search Analytics** — Hot queries, content trends, day/week/month segmented stats\n- **Suggest \u0026 Autocomplete** — Real-time title suggestions as you type\n- **Click Tracking** — Record user behavior for ranking optimization\n\n## Architecture\n\n```\nUser → Search Widget (Preact IIFE)\n         ↓\n   Cloudflare Worker (Hono)\n     ├── Worker Cache API (response cache)\n     ├── KV (data cache, 7-day TTL)\n     └── TiDB Cloud Serverless\n           ├── Full-Text Search (FTS index)\n           └── Vector Search (auto-embedding)\n                  ↓\n           RRF Fusion → Ranked Results\n```\n\n## Monorepo Structure\n\n```\npackages/\n├── shared/          # @mui-search/shared — TypeScript types \u0026 utilities\n├── worker/          # @mui-search/worker — Cloudflare Workers API\n├── search-widget/   # mui-search — Preact IIFE widget\n└── playground/      # @mui-search/playground — Landing page \u0026 dev tools\n```\n\n## Quick Start\n\n### Prerequisites\n\n- Node.js \u003e= 24\n- [pnpm](https://pnpm.io/)\n- A [Cloudflare](https://dash.cloudflare.com/) account\n- A [TiDB Cloud Serverless](https://tidbcloud.com/) cluster\n\n### 1. Clone \u0026 Install\n\n```bash\ngit clone https://github.com/meathill/mui-search.git\ncd mui-search\npnpm install\n```\n\n### 2. Configure Worker\n\n```bash\ncd packages/worker\n\n# Copy the example config\ncp wrangler.example.jsonc wrangler.jsonc\n```\n\nCreate Cloudflare resources and fill in the IDs:\n\n```bash\n# Create D1 database\nwrangler d1 create mui-search\n# → Copy database_id into wrangler.jsonc\n\n# Create KV namespace\nwrangler kv namespace create KV\n# → Copy id into wrangler.jsonc\n```\n\nSet TiDB connection string as a secret:\n\n```bash\nwrangler secret put TIDB_DATABASE_URL\n# Paste: mysql://user:password@host:port/database\n```\n\n### 3. Initialize Databases\n\n```bash\n# Apply D1 schema migrations\npnpm run db:d1:migrate:remote\n\n# Apply TiDB schema migrations\npnpm run db:migrate\n```\n\n### 4. Import Data\n\nPrepare a JSON file with your documents:\n\n```json\n[\n  {\n    \"slug\": \"getting-started\",\n    \"locale\": \"en\",\n    \"title\": \"Getting Started\",\n    \"description\": \"How to get started\",\n    \"content\": \"Full text content for search indexing...\"\n  }\n]\n```\n\nImport via the API:\n\n```bash\ncurl -X POST https://your-worker.dev/api/documents \\\n  -H \"Authorization: Bearer YOUR_API_SECRET_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d @data.json\n```\n\n### 5. Deploy\n\n```bash\npnpm run deploy\n```\n\nThis builds the playground static site and deploys everything (Worker + static assets) to Cloudflare.\n\n### 6. Embed the Widget\n\n```html\n\u003c!-- Include the CSS --\u003e\n\u003clink rel=\"stylesheet\" href=\"https://unpkg.com/mui-search/dist/search-widget.css\"\u003e\n\n\u003c!-- Add a mount point --\u003e\n\u003cdiv\n  data-mui-search\n  data-api-base-url=\"https://your-worker.your-domain.workers.dev\"\n  data-locale=\"en\"\n\u003e\u003c/div\u003e\n\n\u003c!-- Include the main JS (built-in English) --\u003e\n\u003cscript src=\"https://unpkg.com/mui-search/dist/search.js\"\u003e\u003c/script\u003e\n\n\u003c!-- (Optional) Load extra locales on demand, dayjs-style --\u003e\n\u003cscript src=\"https://unpkg.com/mui-search/dist/locale/zh.js\"\u003e\u003c/script\u003e\n```\n\nOr mount programmatically:\n\n```javascript\nwindow.MuiSearchWidget.mount({\n  mount: '#search-container',\n  apiBaseUrl: 'https://your-worker.your-domain.workers.dev',\n  locale: 'en',\n});\n```\n\n## API Endpoints\n\n| Endpoint | Method | Description |\n|---|---|---|\n| `/api/suggest` | GET | Autocomplete suggestions |\n| `/api/search` | GET | Hybrid search (full-text + vector) |\n| `/api/click` | POST | Record click events |\n| `/api/hot` | GET | Hot content (from external source) |\n| `/api/hot-queries` | GET | Trending search queries |\n| `/api/stats/daily-search` | GET | Daily search statistics |\n| `/api/stats/segmented-top` | GET | Day/week/month top queries \u0026 content |\n| `/api/stats/content-queries` | GET | Reverse lookup: content → queries |\n| `/api/health` | GET | Health check |\n\n## Development\n\n```bash\n# Start playground dev server\npnpm --filter @mui-search/playground dev\n\n# Run all tests\npnpm test\n\n# Format code\npnpm run format\n\n# Type check\npnpm run typecheck\n```\n\n## Tech Stack\n\n- [Cloudflare Workers](https://workers.cloudflare.com/) — Edge runtime\n- [TiDB Cloud Serverless](https://tidbcloud.com/) — MySQL-compatible database with vector search \u0026 auto-embedding\n- [Hono](https://hono.dev/) — Lightweight web framework\n- [Preact](https://preactjs.com/) — Widget UI (3KB)\n- [React](https://react.dev/) — Playground \u0026 landing page\n- [Drizzle ORM](https://orm.drizzle.team/) — TiDB schema management\n- [Vite](https://vite.dev/) — Build tool\n- [Vitest](https://vitest.dev/) — Testing framework\n- [Biome](https://biomejs.dev/) — Formatter \u0026 linter\n- [Tailwind CSS](https://tailwindcss.com/) — Styling\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeathill%2Fmui-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeathill%2Fmui-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeathill%2Fmui-search/lists"}