[
  {
    "path": ".gitignore",
    "content": "/node_modules/\n/.idea/"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License."
  },
  {
    "path": "NOTICE.txt",
    "content": "Copyright 2024 AskAITools\n\nIn addition to the terms of the Apache License 2.0, any derivative works or projects based on this open-source project must prominently acknowledge that they are derived from or based on this project. This acknowledgement must be made in at least one of the following places: in the derivative project's documentation, or user interface."
  },
  {
    "path": "README.md",
    "content": "# AskAITools Community Edition\n\n## Overview\n\nAskAITools (https://askaitools.ai) is a cutting-edge search engine project tailored specifically for the AI product domain. Our mission is to revolutionize the way users discover AI products by providing the most accurate, comprehensive, lightning-fast, and intelligent search experience. With AskAITools, finding the perfect AI solution has never been easier.\n\n**AskAITools Desktop Web Screenshot:**\n\n[![AskAITools Desktop Web Screenshot](https://public-files.askaitools.ai/MainScreenshot.png)](https://askaitools.ai)\n\n**AskAITools Mobile Web Screenshot:**\n\n[![AskAITools Mobile Web Screenshot](https://public-files.askaitools.ai/MobileScreenshot.png)](https://askaitools.ai)\n\nThis project comes in two flavors: a feature-rich commercial edition and a community edition. The community edition offers a solid foundation with a basic front-end interface and search functionality, and its code is completely open-source in this repository. Developers can effortlessly integrate their own data on top of this framework, enabling them to swiftly build specialized vertical search engines or internal document search systems for their organizations.\n\nUnder the hood, AskAITools employs a hybrid search engine architecture, seamlessly combining keyword search (full-text search) and semantic search (vector search/embedding search) capabilities. By leveraging statistical data and weighted fusion techniques, it achieves a balance between relevance and popularity.\n\n## Project Architecture and Tech Stack\n\n- Front-end: Next.js\n- Deployment: Vercel\n- Styling: Tailwind CSS\n- Database: Supabase\n- Keyword Search: PostgreSQL / Supabase Full-Text Search Engine\n- Semantic Search: Pgvector / Supabase Vector Database\n- Semantic Vector Generation: OpenAI text-embedding-3 model\n\n## Getting Started\n\n1. Gather and structure your niche data. Refer to [our data table schema](./supabase/migrations/20240506_init.sql) for guidance on the required fields.\n2. Modify the `item` table schema as needed. Create the table and import the data into Supabase.\n3. Duplicate the environment variable template `.env.local.example` and rename it to `.env.local`. Fill in your Supabase and OpenAI configuration details. If needed, provide proxy information.\n4. Tailor the search parameters and strategies in `./app/pages/index.tsx`, `./app/pages/api/embedding_search.ts`, and `./supabase/migrations/20240506_init.sql` to suit your requirements.\n5. Refer to `20240506_init.sql` and create two search functions in Supabase.\n6. In the `app` directory, run `yarn install` to install dependencies, followed by `yarn dev` to initiate the local development environment and conduct code debugging.\n7. Follow the Vercel official documentation to deploy your project on Vercel.\n8. Once deployed, celebrate your accomplishment 🎉\n\n## Usage Restrictions\n\n1. All projects that are derivatives of this project must prominently acknowledge AskAITools by displaying its name and open-source address on the user interface homepage or documentation homepage. The easiest way to comply with this requirement is to keep the \"Powered by AskAITools\" component intact in the footer.\n2. When deploying projects derived from this open-source project, please avoid using the AskAITools brand name as your product/project name. This restriction does not apply to the [\"AskAITools Commercial Edition\"](https://askaitools.ai) (https://askaitools.ai).\n3. If you want to develop AI product search platforms, AI product directory sites, or other projects that closely resemble the AskAITools Commercial Edition using this open-source project as a foundation, please redesign and redevelop the front-end pages. Failure to do so may result in Google identifying the later-launched website as plagiarism due to similar formatting and content, potentially hindering its ability to attract search traffic."
  },
  {
    "path": "README_CN.md",
    "content": "# AskAITools 开源社区版\n\n## 概述\n\nAskAITools (https://askaitools.ai) 是专为 AI 产品领域设计的顶级搜索引擎项目，致力于打造 AI 产品领域中最卓越的搜索引擎。我们的目标是为用户提供最精准、最全面、最快速、最智能的搜索体验，使其成为用户寻找 AI 产品时的首选。\n\n**AskAITools 桌面版网页截图：**\n\n[![AskAITools 桌面版网页截图](https://public-files.askaitools.ai/MainScreenshot.png)](https://askaitools.ai)\n\n**AskAITools 移动版网页截图：**\n\n[![AskAITools 移动版网页截图](https://public-files.askaitools.ai/MobileScreenshot.png)](https://askaitools.ai)\n\n此项目包括商业版与社区版两个版本，社区版提供基础前端界面和搜索功能，代码完全开源。开发者可以在此基础上，轻松添加自己的数据，迅速构建专业的垂域搜索引擎或用于企业内部文档搜索。\n\n本搜索引擎是一种混合型搜索引擎，具备关键词搜索（全文搜索）和语义搜索（向量搜索/嵌入搜索）功能，结合统计数据进行加权融合，实现了在相关性和热度两方面的平衡。\n\n## 项目架构与技术栈\n\n- 前端：Next.js\n- 部署：Vercel\n- 样式：Tailwind CSS\n- 数据库：Supabase\n- 关键词搜索：Postgresql / Supabase 全文搜索引擎\n- 语义搜索：Pgvector / Supabase 向量数据库\n- 语义向量生成：OpenAI text-embedding-3 模型\n\n## 使用步骤\n\n1. 收集并整理你的垂域数据，详细字段可参照[我的数据表结构](./supabase/migrations/20240506_init.sql)。\n2. 根据你的数据需要调整 `item` 表结构，在 Supabase 中创建并导入数据表。\n3. 将环境变量模板 `.env.local.example` 复制为 `.env.local` 并填入你的 Supabase 和 OpenAI 配置信息，必要时填写代理信息。\n4. 根据需求，调整 `./app/pages/index.tsx`、`./app/pages/api/embedding_search.ts` 与 `./supabase/migrations/20240506_init.sql` 中的搜索参数和搜索策略。\n5. 参考 `20240506_init.sql`，在 Supabase 中创建两个搜索函数。\n6. 在 `app` 目录下执行 `yarn install` 安装依赖，之后运行 `yarn dev` 启动本地开发环境并进行代码调试。\n7. 遵循 Vercel 官方文档将项目部署至 Vercel。\n8. 部署成功后，庆祝成果🎉\n\n## 使用限制\n\n1. 基于本项目进行二次开发的项目，必须在用户界面首页或文档首页的显著位置，注明本开源项目的名称和开源地址。最简单的做法是，保留页脚中的 \"Powered by AskAITools\" 组件。\n2. 基于本项目进行二次开发并部署上线的项目，除 [AskAITools 商业版](https://askaitools.ai)（https://askaitools.ai ）外，请勿使用 AskAITools 品牌名作为产品 / 项目名称。\n3. 如果基于本项目二次开发 AI 产品搜索站或 AI 产品导航站等和 AskAITools 商业版接近的项目，请重新设计、开发前端页面。否则相同格式、相似内容，后上线的网站很可能被谷歌判定为抄袭，从而无法获得搜索流量。\n"
  },
  {
    "path": "app/.gitignore",
    "content": "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pnp\n.pnp.js\n# lockfile\npackage-lock.json\nyarn.lock\n\n# testing\n/coverage\n\n# next.js\n/.next/\n/out/\n\n# production\n/build\n\n# misc\n.DS_Store\n*.pem\n\n# debug\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# local env files\n.env.local\n.env.development.local\n.env.test.local\n.env.production.local\n\n# vercel\n.vercel\n\n# typescript\n*.tsbuildinfo\n"
  },
  {
    "path": "app/components/Footer.tsx",
    "content": "import GitHubButton from 'react-github-btn'\n\nconst Footer = () => {\n    return (\n            <footer className=\"flex flex-col items-center justify-center w-full border-t bg-scale-300 p-4 text-sm\">\n                <div className=\"text-gray-700 mb-2\">Powered by\n                    <a href=\"https://github.com/askaitools/askaitools-community-edition\" target=\"_blank\" rel=\"noopener\" className=\"text-blue-500 underline ml-1\">AskAITools</a>\n                </div>\n                <GitHubButton href=\"https://github.com/askaitools/askaitools-community-edition\" data-color-scheme=\"no-preference: light; light: light; dark: dark;\" data-size=\"small\" data-show-count=\"true\" aria-label=\"Star askaitools/askaitools-community-edition on GitHub\">Star</GitHubButton>\n            </footer>\n    )\n}\n\nexport default Footer\n"
  },
  {
    "path": "app/components/ItemsTileGrid.tsx",
    "content": "import Link from 'next/link'\nimport {Items} from '~/types/items'\nimport LogoImage from './LogoImage';\n\nexport default function PartnerTileGrid({\n                                            searchResults\n                                        }: {\n    searchResults: Items[]\n}) {\n\n    function formatVisitsCount(countNumber : bigint, language = 'en_US') {\n        const count = Number(countNumber);\n        if (count < 1_000) {\n            return count.toString();\n        } else if (count < 1_000_000) {\n            return (count / 1_000).toFixed(1) + 'K';\n        } else if (count < 1_000_000_000) {\n            return (count / 1_000_000).toFixed(1) + 'M';\n        } else {\n            return (count / 1_000_000_000).toFixed(1) + 'B';\n        }\n    }\n\n    return (\n        <>\n            <div className=\"not-prose space-y-0\">\n                <div className=\"grid gap-2 grid-cols-1 md:grid-cols-1 lg:max-w-none\">\n                    {searchResults.map((p) => (\n                        <a key={p.id} href={p.url} target=\"_blank\" rel=\"noopener dofollow\">\n                            <div\n                                className=\"bg-[#fcfcfc]\n                                hover:bg-gray-100 hover:dark:bg-scale-400\n                                group flex flex-col w-full h-full px-5 py-1 transition-all\n                                border rounded-l\n                                shadow\n                                hover:shadow-lg\"\n                            >\n                                <div className=\"flex w-full items-center space-x-4\">\n                                    <div className=\"flex-none transition-all group-hover:scale-110\">\n                                        <LogoImage logo={p.logo} title={p.title} />\n                                    </div>\n                                    <div className=\"flex-1 min-w-0 py-1\">\n                                        <h3 className=\"text-sm font-bold transition-colors group-hover:text-blue-500 whitespace-nowrap overflow-hidden text-ellipsis  mt-0\"\n                                            title={p.url}\n                                        >\n                                            {p.title}\n                                        </h3>\n                                        <p\n                                            className=\"text-xs whitespace-nowrap overflow-hidden text-ellipsis mb-1\"\n                                            title={p.brief}\n                                        >\n                                            {p.brief}\n                                        </p>\n                                        <div className=\"flex flex-wrap items-center mt-0\">\n                                            {p.visitstotalcount&& (\n                                                <span\n                                                    className=\"text-xs text-gray-600 mr-2 mb-1\"\n                                                >\n                                                    👥 {formatVisitsCount(p.visitstotalcount)}\n                                                </span>\n                                            )}\n                                            {p.visitsavgdurationformatted && (\n                                                <span\n                                                    className=\"text-xs text-gray-600 mr-2 mb-1\"\n                                                >\n                                                    ⏱️ {p.visitsavgdurationformatted.startsWith(\"00:\")\n                                                    ? p.visitsavgdurationformatted.substring(3)\n                                                    : p.visitsavgdurationformatted}\n                                                </span>\n                                            )}\n                                            {p.bouncerate && (\n                                                <span\n                                                    className=\"text-xs text-gray-600 mb-1\"\n                                                >\n                                                    🤝 {Math.round((1 - p.bouncerate) * 100)}%\n                                                </span>\n                                            )}\n                                        </div>\n                                    </div>\n                                </div>\n                            </div>\n                        </a>\n                    ))}\n                </div>\n            </div>\n        </>\n    )\n}"
  },
  {
    "path": "app/components/Layout.tsx",
    "content": "import {PropsWithChildren, useEffect, useState} from 'react'\nimport Nav from './Nav'\nimport Footer from './Footer'\n\ntype LayoutProps = {}\n\nconst Layout = ({\n                    children,\n                }: PropsWithChildren<LayoutProps>) => {\n    const [navHeight, setNavHeight] = useState(0);\n    useEffect(() => {\n        document.documentElement.className = 'light'\n        const nav = document.querySelector('nav');\n        if (nav) {\n            setNavHeight(nav.offsetHeight);\n        }\n    }, [])\n\n    return (\n        <>\n            <div className=\"flex flex-col min-h-screen\">\n                <div className=\"fixed top-0 w-full z-10\"><Nav/></div>\n                <div className=\"flex-1\" style={{paddingTop: `${navHeight}px`}}>\n                    <main>{children}</main>\n                </div>\n                <Footer/>\n            </div>\n        </>\n    )\n}\n\nexport default Layout\n"
  },
  {
    "path": "app/components/LogoImage.tsx",
    "content": "import React, { useState } from 'react';\nimport Image from 'next/image';\n\nconst LogoImage: React.FC<{ logo: string | undefined; title: string }>  = ({ logo, title }) => {\n    const [imageError, setImageError] = useState(false);\n\n    const handleImageError = () => {\n        setImageError(true);\n    };\n\n    if (!logo) {\n        return (\n            <Image\n                width={40}\n                height={40}\n                className=\"bg-gray-300 rounded-full\"\n                src=\"/images/logo-wordmark--light.svg\"\n                alt={title}\n            />\n        );\n    }\n\n    const fileExtension = logo?.split('.').pop()?.toLowerCase() ?? '';\n    const logoUrl = `https://example.com/${logo}`;  // Replace with your actual logo URL\n\n    if (fileExtension === 'svg') {\n        return (\n            <div className=\"bg-gray-300 rounded-full w-10 h-10 flex items-center justify-center\">\n                {imageError ? (\n                    <img src=\"/images/logo-wordmark--light.svg\" alt={title} />\n                ) : (\n                    <img src={logoUrl} alt={title} onError={handleImageError} />\n                )}\n            </div>\n        );\n    }\n\n    return (\n        <Image\n            width={40}\n            height={40}\n            className=\"bg-gray-300 rounded-full\"\n            src={imageError ? '/images/logo-wordmark--light.svg' : logoUrl}\n            alt={title}\n            onError={handleImageError}\n        />\n    );\n};\n\nexport default LogoImage;\n"
  },
  {
    "path": "app/components/Nav.tsx",
    "content": "import Image from 'next/image';\nimport Link from 'next/link';\nimport {useState} from 'react';\nimport { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline';\n\ninterface LogoProps {\n    isDarkMode: boolean | undefined;\n}\n\nconst Logo = ({ isDarkMode }: LogoProps) => {\n    return (\n        <Link href=\"https://askaitools.ai\" className=\"flex items-center justify-center md:justify-start\">\n                <Image\n                    src={isDarkMode ? '/images/logo-wordmark--dark.svg' : '/images/logo-wordmark--light.svg'}\n                    alt=\"Logo\"\n                    height={30}\n                    width={30}\n                />\n                <span className={`ml-3 font-bold text-lg ${isDarkMode ? 'text-white' : 'text-black'}`}>\n                  Your Product Name\n                </span>\n        </Link>\n    );\n};\n\nconst SocialMediaLinks = ({ isDarkMode }: LogoProps) => {\n    return (\n        <>\n            {/* Replace with your actual social media links */}\n            <a className=\"flex mr-3\" href=\"https://askaitools.ai\" target=\"_blank\" rel=\"noopener\">\n                <Image src='/images/Gmail_logo.svg' alt=\"Email\" height={24} width={30}/>\n            </a>\n            <a className=\"flex mr-3\" href=\"https://askaitools.ai\" target=\"_blank\" rel=\"noopener\">\n                <Image\n                    src={isDarkMode ? '/images/TwitterX_logo--dark.png' : '/images/TwitterX_logo--light.png'}\n                    alt=\"Twitter (X)\"\n                    height={24}\n                    width={24}\n                />\n            </a>\n            <a className=\"flex\" href=\"https://askaitools.ai\" target=\"_blank\" rel=\"noopener\">\n                <Image src='/images/Jike_logo.png' alt=\"Jike\" height={24} width={24}/>\n            </a>\n        </>\n    );\n};\n\nconst Nav = () => {\n    const [isMenuOpen, setIsMenuOpen] = useState(false);\n    return (\n        <nav className=\"relative flex w-full items-center border-b bg-white px-6 lg:px-16 xl:px-20\">\n            <div className=\"flex-1 flex justify-center md:justify-start p-4 pr-10\">\n                <Logo isDarkMode={false} />\n            </div>\n            <div className=\"hidden md:flex flex-1 justify-end\">\n                <SocialMediaLinks isDarkMode={false} />\n            </div>\n            <div className=\"md:hidden flex items-center\">\n                <button onClick={() => setIsMenuOpen(!isMenuOpen)}>\n                    {isMenuOpen ? <XMarkIcon className=\"h-6 w-6\" /> : <Bars3Icon className=\"h-6 w-6\" />}\n                </button>\n            </div>\n            <div className={`${isMenuOpen ? 'fixed' : 'hidden'} overflow-hidden inset-0 w-screen h-screen bg-white shadow-md z-50`}>\n                <div className=\"flex flex-col w-full h-full\">\n                    <div className=\"flex justify-between items-center border-b bbg-scale-300\">\n                        <div className=\"flex justify-center w-full p-4\">\n                            <Logo isDarkMode={false} />\n                        </div>\n                        <button onClick={() => setIsMenuOpen(false)} className=\"pr-10\">\n                            <XMarkIcon className=\"h-6 w-6\" />\n                        </button>\n                    </div>\n                    {/* Replace with your actual social media links */}\n                    <div className=\"flex flex-col overflow-y-auto p-4\">\n                        <a href=\"https://askaitools.ai\" target=\"_blank\" rel=\"noopener\" className=\"p-4 border-b border-gray-600 text-center\">Email</a>\n                        <a href=\"https://askaitools.ai\" target=\"_blank\" rel=\"noopener\" className=\"p-4 border-b border-gray-600 text-center\">Twitter</a>\n                        <a href=\"https://askaitools.ai\" target=\"_blank\" rel=\"noopener\" className=\"p-4 border-b border-gray-600 text-center\">Jike</a>\n                    </div>\n                </div>\n            </div>\n        </nav>\n    );\n};\n\nexport default Nav;\n"
  },
  {
    "path": "app/components/SectionContainer.tsx",
    "content": "import classNames from 'classnames'\nimport { PropsWithChildren } from 'react'\n\ninterface SectionContainerProps {\n  className?: string\n}\n\nconst SectionContainer = ({ children, className }: PropsWithChildren<SectionContainerProps>) => (\n  <div\n    className={classNames(\n      `container prose prose-sm dark:prose-invert mx-auto max-w-full md:prose-base xl:prose-lg px-6 lg:px-16 xl:px-20 relative py-16 sm:py-18 md:py-24 lg:py-24`,\n      className\n    )}\n  >\n    {children}\n  </div>\n)\n\nexport default SectionContainer\n"
  },
  {
    "path": "app/lib/supabase.ts",
    "content": "import { createClient } from '@supabase/supabase-js'\n\nconst supabase = createClient(\n  process.env.NEXT_PUBLIC_SUPABASE_URL!,\n  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!\n)\n\nexport default supabase\n"
  },
  {
    "path": "app/lib/theme.tsx",
    "content": "import { createContext, useContext, useEffect, useState } from 'react'\n\ninterface UseThemeProps {\n  toggleTheme: () => void\n}\n\ninterface ThemeProviderProps {\n  children?: any\n}\n\nexport const ThemeContext = createContext<UseThemeProps>({\n  toggleTheme: () => {},\n})\n\nexport const useTheme = () => useContext(ThemeContext)\n\nexport const ThemeProvider = ({ children }: ThemeProviderProps) => {\n  const [isDarkMode, setIsDarkMode] = useState(false)\n\n  useEffect(() => {\n    const key = localStorage.getItem('darkMode')\n    setIsDarkMode(key === 'true')\n  }, [])\n\n  const toggleTheme = () => {\n    setIsDarkMode(!isDarkMode)\n  }\n\n  return (\n    <ThemeContext.Provider\n      value={{\n        toggleTheme,\n      }}\n    >\n      {children}\n    </ThemeContext.Provider>\n  )\n}\n"
  },
  {
    "path": "app/next-env.d.ts",
    "content": "/// <reference types=\"next\" />\n/// <reference types=\"next/image-types/global\" />\n\n// NOTE: This file should not be edited\n// see https://nextjs.org/docs/basic-features/typescript for more information.\n"
  },
  {
    "path": "app/next.config.js",
    "content": "/** @type {import('next').NextConfig} */\nmodule.exports = {\n  reactStrictMode: true,\n  images: {\n    remotePatterns: [\n      {\n        protocol: 'https',\n        hostname: 'example.com',\n      },\n    ],\n  },\n}\n"
  },
  {
    "path": "app/package.json",
    "content": "{\n  \"name\": \"askaitools-community-edition\",\n  \"version\": \"0.1.0\",\n  \"description\": \"A cutting-edge search engine project tailored specifically for the AI product\",\n  \"license\": \"Apache License Version 2.0\",\n  \"scripts\": {\n    \"dev\": \"next dev\",\n    \"build\": \"next build\",\n    \"start\": \"next start\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/askaitools/askaitools-community-edition.git\"\n  },\n  \"dependencies\": {\n    \"@heroicons/react\": \"^2.1.1\",\n    \"@next/third-parties\": \"^14.1.0\",\n    \"@supabase/supabase-js\": \"^1.33.3\",\n    \"@vercel/speed-insights\": \"^1.0.7\",\n    \"classnames\": \"^2.3.1\",\n    \"https-proxy-agent\": \"^7.0.4\",\n    \"marked\": \"^4.0.12\",\n    \"next\": \"^13.5.6\",\n    \"openai\": \"^4.38.2\",\n    \"react\": \"^18.2.0\",\n    \"react-dom\": \"^18.2.0\",\n    \"react-github-btn\": \"^1.4.0\",\n    \"react-inlinesvg\": \"^4.1.3\",\n    \"use-debounce\": \"^7.0.1\"\n  },\n  \"devDependencies\": {\n    \"@mertasan/tailwindcss-variables\": \"^2.2.2\",\n    \"@radix-ui/colors\": \"^0.1.8\",\n    \"@tailwindcss/forms\": \"^0.5.0\",\n    \"@tailwindcss/typography\": \"^0.5.2\",\n    \"@types/marked\": \"^4.0.3\",\n    \"@types/node\": \"^17.0.23\",\n    \"@types/react\": \"^17.0.43\",\n    \"autoprefixer\": \"^10.4.4\",\n    \"deepmerge\": \"^4.2.2\",\n    \"mini-svg-data-uri\": \"^1.4.4\",\n    \"postcss\": \"^8.4.12\",\n    \"prettier\": \"^2.6.2\",\n    \"prettier-plugin-tailwindcss\": \"^0.1.8\",\n    \"tailwindcss\": \"^3.0.23\",\n    \"tailwindcss-radix\": \"^1.6.0\",\n    \"typescript\": \"^4.6.3\"\n  }\n}\n"
  },
  {
    "path": "app/pages/_app.tsx",
    "content": "import type { AppProps } from 'next/app'\nimport { ThemeProvider } from '~/lib/theme'\nimport '../styles/globals.css'\nimport React from \"react\";\n\nfunction MyApp({ Component, pageProps }: AppProps) {\n  return (\n    <>\n        <ThemeProvider>\n            <Component {...pageProps} />\n        </ThemeProvider>\n    </>\n  )\n}\n\nexport default MyApp\n"
  },
  {
    "path": "app/pages/api/embedding_search.ts",
    "content": "import type { NextApiRequest, NextApiResponse } from 'next';\nimport OpenAI from 'openai';\n// import { HttpsProxyAgent } from 'https-proxy-agent';\n\nexport default async function handler(req: NextApiRequest, res: NextApiResponse) {\n    if (req.method === 'POST') {\n        try {\n            const openai = new OpenAI({\n                apiKey: process.env['OPENAI_API_KEY'],\n                // httpAgent: new HttpsProxyAgent(process.env.HTTP_PROXY!),\n            });\n            const search = req.body.search;\n            const embeddingResponse = await openai.embeddings.create({\n                input: search,\n                model: 'text-embedding-3-small',\n                encoding_format: \"float\",\n                dimensions: 512,\n            });\n            const embedding = embeddingResponse.data[0].embedding;\n            res.status(200).json({ embedding });\n        } catch (error) {\n            res.status(500).json({ error: 'Error processing your request' });\n        }\n    } else {\n        res.setHeader('Allow', ['POST']);\n        res.status(405).end(`Method ${req.method} Not Allowed`);\n    }\n}\n"
  },
  {
    "path": "app/pages/index.tsx",
    "content": "import Head from 'next/head'\nimport React, {useState} from 'react'\nimport Layout from '~/components/Layout'\nimport ItemsTileGrid from '~/components/ItemsTileGrid'\nimport SectionContainer from '~/components/SectionContainer'\nimport supabase from '~/lib/supabase'\nimport {Items} from '~/types/items'\n\ninterface Props {\n    items: Items[]\n}\n\nfunction normalizeSearch(search:string) {\n    let result = search.substring(0, 256).replace(/[\\p{P}\\p{S}]/gu, ' ').toLowerCase();\n    result = result.trim().replace(/\\s+/g, ' ');\n    return result;\n}\n\nasync function embeddingSearch(search:string) {\n    try {\n        const response = await fetch('/api/embedding_search', {\n            method: 'POST',\n            headers: {\n                'Content-Type': 'application/json',\n            },\n            body: JSON.stringify({ search }),\n        });\n\n        if (response.ok) {\n            const embeddingData = await response.json();\n            const searchEmbedding = embeddingData.embedding;\n            const { error: matchError, data: embeddingItems } = await supabase.rpc(\n                'match_items',\n                {\n                    query_embedding: searchEmbedding,\n                    match_threshold: 0,  // Fill in an appropriate value based on your requirements\n                    match_count: 10,  // Fill in an appropriate value based on your requirements\n                }\n            );\n\n            if (matchError) {\n                return [];\n            } else {\n                return embeddingItems;\n            }\n        } else {\n            return [];\n        }\n    } catch (error) {\n        return [];\n    }\n}\n\nasync function ftsSearch(search:string) {\n    const { error: matchError, data: FTSitems } = await supabase.rpc(\n        'fts_match_items_ranked', {\n            query_string: search.replace(/ /g, ' & '),  // Modify the query string as needed\n            match_count: 10,  // Fill in an appropriate value based on your requirements\n        })\n    if (matchError) {\n        return [];\n    } else {\n        return FTSitems;\n    }\n}\n\nfunction asyncFunctionWithTimeout(asyncFunction: (...args: any[]) => Promise<any>, timeout:number, ...args :any[]) {\n    const timeoutPromise = new Promise((_, reject) => {\n        setTimeout(() => {\n            reject(new Error('Async function timed out'));\n        }, timeout);\n    });\n\n    return Promise.race([asyncFunction(...args), timeoutPromise]);\n}\n\nfunction dedupeSortedItemsByDomain(sortedItems: Items[]): Items[] {\n    const uniqueDomains = new Set();\n    return sortedItems.filter((item) => {\n        const url = new URL(item.url);\n        const domain = url.hostname;\n        if (uniqueDomains.has(domain)) {\n            return false;\n        } else {\n            uniqueDomains.add(domain);\n            return true;\n        }\n    });\n}\n\n\nfunction Home(props: Props) {\n    const [items, setItems] = useState<Items[]>([])\n\n    const metaTitle = 'Your meta title'\n    const metaDescription = `Your meta description`\n\n    const [search, setSearch] = useState('')\n    const [isSearching, setIsSearching] = useState(false)\n    const [afterSearch, setAfterSearch] = useState(false)\n\n    const handleSearchSubmit = async (e: { preventDefault: () => void }) => {\n        e.preventDefault();\n        if (search.trim() === '') {\n            setIsSearching(false)\n            setItems([])\n            return\n        }\n\n        setIsSearching(true);\n\n        const normalizedSearch = normalizeSearch(search);\n\n        const [embeddingResult, ftsResult] = await Promise.allSettled([\n            asyncFunctionWithTimeout(embeddingSearch, 3000, normalizedSearch),\n            asyncFunctionWithTimeout(ftsSearch, 3000, normalizedSearch),\n        ]);\n\n        const embeddingItems = embeddingResult.status === 'fulfilled' ? embeddingResult.value : [];\n        const FTSitems = ftsResult.status === 'fulfilled' ? ftsResult.value : [];\n\n        // Modify the scoring function according to your requirements.\n        function calculateScore(item: any, isFTS: boolean, isEmbedding: boolean) {\n            const keywordMatchScore = isFTS ? item.rank : 0;\n            const semanticMatchScore = isEmbedding ? item.similarity : 0;\n            const trafficScore = Math.log10(item.visitstotalcount > 5000 ? item.visitstotalcount : 2500);\n            return trafficScore * (semanticMatchScore + keywordMatchScore);\n        }\n\n        const mergedItemsMap = new Map();\n\n        embeddingItems.forEach((item:Items) => {\n            mergedItemsMap.set(item.url, { ...item, score: calculateScore(item, false, true) });\n        });\n\n        FTSitems.forEach((item:Items) => {\n            if (mergedItemsMap.has(item.url)) {\n                const existingItem = mergedItemsMap.get(item.url);\n                const updatedItem = { ...existingItem, rank: item.rank };\n                updatedItem.score = calculateScore(updatedItem, true, true);\n                mergedItemsMap.set(item.url, updatedItem);\n            } else {\n                mergedItemsMap.set(item.url, { ...item, score: calculateScore(item, true, false) });\n            }\n        });\n\n        const sortedItems = Array.from(mergedItemsMap.values()).sort((a, b) => b.score - a.score)\n        const dedupedSortedItems = dedupeSortedItemsByDomain(sortedItems);\n        const page1 = dedupedSortedItems.slice(0, 100);\n\n        if (page1) {\n            setItems(page1)\n        }\n\n        setIsSearching(false)\n        setAfterSearch(true)\n\n    };\n\n    return (\n        <>\n            <Head>\n                <title>{`${metaTitle} | Your Product's Name`}</title>\n                <meta name=\"description\" content={metaDescription}></meta>\n                <link rel=\"icon\" href=\"/favicon.ico\" type=\"image/x-icon\"/>\n            </Head>\n            <Layout>\n                <SectionContainer className=\"space-y-4\">\n                        <div className=\"text-center\">\n                            <h1 className=\"h1\">\n                                {metaTitle}\n                                <div className=\"mt-4\">\n                                    <span className=\"text-blue-500\">{metaDescription}</span>\n                                </div>\n                            </h1>\n                        </div>\n\n                        <form className=\"md:w-2/3 mx-auto\" onSubmit={handleSearchSubmit}>\n                            <label\n                                className=\"mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white\"\n                                htmlFor=\"search\"\n                            >\n                                Search\n                            </label>\n                            <div className=\"relative\">\n                                <div className=\"absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none\">\n                                    <svg\n                                        aria-hidden=\"true\"\n                                        className=\"w-5 h-5 text-gray-600 dark:text-gray-400\"\n                                        fill=\"none\"\n                                        viewBox=\"0 0 20 20\"\n                                        xmlns=\"http://www.w3.org/2000/svg\"\n                                    >\n                                        <path\n                                            d=\"m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z\"\n                                            stroke=\"currentColor\"\n                                            strokeLinecap=\"round\"\n                                            strokeLinejoin=\"round\"\n                                            strokeWidth=\"1\"\n                                        />\n                                    </svg>\n                                </div>\n                                <input\n                                    className=\"block w-full bg-gray-50 p-2 ps-10 text-md text-gray-900 placeholder-gray-500 border border-gray-500 rounded-lg ring-1 ring-transparent focus:outline-none focus:border-blue-500 focus:ring-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500\"\n                                    id=\"search\"\n                                    autoComplete=\"off\"\n                                    placeholder=\"Search...\"\n                                    required\n                                    type=\"search\"\n                                    value={search}\n                                    onChange={(e) => setSearch(e.target.value)}\n                                />\n                            </div>\n                        </form>\n                        {isSearching ? (\n                            <div className=\"flex justify-center pt-16\">\n                                <img src=\"/images/blocks-wave.svg\" className=\"h-16 w-16\" alt=\"Loading...\" />\n                            </div>\n                        ) : (\n                            <div className=\"grid space-y-0 md:gap-8 lg:grid-cols-12 lg:gap-16 lg:space-y-0 xl:gap-16\">\n                                <div className=\"lg:col-start-3 lg:col-span-8 xl:col-start-3 xl:col-span-8\">\n                                    <div className=\"text-xs\">\n                                        {afterSearch && (\n                                            <p>About {items.length} results</p>\n                                        )}\n                                    </div>\n                                    <div className=\"grid space-y-10\">\n                                        {items.length ? (\n                                            <ItemsTileGrid searchResults={items}/>\n                                        ) : (\n                                            afterSearch ? (\n                                                <h3 className=\"h3\">No results found, please try another keyword.</h3>\n                                            ):null\n                                        )}\n                                    </div>\n                                </div>\n                            </div>\n                        )}\n                </SectionContainer>\n            </Layout>\n        </>\n    )\n}\n\nexport default Home\n"
  },
  {
    "path": "app/postcss.config.js",
    "content": "module.exports = {\n  plugins: {\n    tailwindcss: {},\n    autoprefixer: {},\n  },\n}\n"
  },
  {
    "path": "app/prettier.config.js",
    "content": "module.exports = {\n  singleQuote: true,\n  semi: false,\n}\n"
  },
  {
    "path": "app/styles/globals.css",
    "content": "@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\nhtml {\n  scroll-behavior: smooth;\n}\n\nbody {\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n}\n\n.section--masked {\n}\n\n::selection {\n  background-color: #93c5fd;\n  color: #333 !important;\n}\n\n.section--bg-masked {\n  position: absolute;\n  width: 100%;\n  height: 100%;\n}\n\n.section-container {\n  position: relative;\n  z-index: 1;\n  display: flex;\n  justify-content: center;\n}\n\n.dark .auth-container {\n  background-color: #181818;\n  background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill-rule='evenodd'%3E%3Cg fill='%23313131' fill-opacity='0.4'%3E%3Cpath opacity='.5' d='M96 95h4v1h-4v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4h-9v4h-1v-4H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15v-9H0v-1h15V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h9V0h1v15h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9h4v1h-4v9zm-1 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm9-10v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-10 0v-9h-9v9h9zm-9-10h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9zm10 0h9v-9h-9v9z'/%3E%3Cpath d='M6 5V0H5v5H0v1h5v94h1V6h94V5H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");\n}\n\n.dark .header--light {\n  display: none;\n}\n\n.header--dark {\n  display: none;\n}\n\n.dark .header--dark {\n  display: block;\n}"
  },
  {
    "path": "app/tailwind.config.js",
    "content": "module.exports = {\n  content: [\n    './components/**/*.tsx',\n    './pages/**/*.tsx',\n  ],\n  darkMode: 'class',\n  theme: {\n    extend: {\n      typography: (theme) => ({\n        DEFAULT: {\n          css: {\n            a: {\n              textDecoration: 'none',\n            },\n          },\n        },\n      }),\n      backdropFilter: {\n        'none': 'none',\n        'blur': 'blur(20px)',\n      },\n      fontFamily: {\n        sans: [\n          'custom-font',\n          'Helvetica Neue',\n          'Helvetica',\n          'Arial',\n          'sans-serif',\n        ],\n        mono: ['Source Code Pro', 'Menlo', 'monospace'],\n      },\n      keyframes: {\n        'flash-code': {\n          '0%': { backgroundColor: 'rgba(63, 207, 142, 0.1)' },\n          '100%': { backgroundColor: 'transparent' },\n        },\n      },\n      animation: {\n        'flash-code': 'flash-code 1s forwards',\n        'flash-code-slow': 'flash-code 2s forwards',\n      },\n    },\n  },\n  plugins: [require('@tailwindcss/typography')],\n}\n"
  },
  {
    "path": "app/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"target\": \"es5\",\n    \"lib\": [\"dom\", \"dom.iterable\", \"esnext\"],\n    \"allowJs\": true,\n    \"skipLibCheck\": true,\n    \"strict\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"noEmit\": true,\n    \"esModuleInterop\": true,\n    \"module\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"resolveJsonModule\": true,\n    \"isolatedModules\": true,\n    \"jsx\": \"preserve\",\n    \"incremental\": true,\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"~/*\": [\"./*\"],\n      \"react\": [ \"./node_modules/@types/react\" ]\n    }\n  },\n  \"include\": [\"next-env.d.ts\", \"**/*.ts\", \"**/*.tsx\"],\n  \"exclude\": [\"node_modules\"]\n}\n"
  },
  {
    "path": "app/types/items.ts",
    "content": "\nexport interface Items {\n    id: number\n    url: string\n    title: string\n    brief?: string\n    tsv?: any\n    doc_embedding?: any\n    logo?: string\n    visitstotalcount?: bigint\n    bouncerate?: number\n    pagespervisit?: number\n    visitsavgdurationformatted?: string\n    similarity?: number\n    rank?: number\n}\n"
  },
  {
    "path": "supabase/migrations/20240506_init.sql",
    "content": "create table\n  items (  -- Replace the \"items\" table with your own table name.\n    id bigint generated by default as identity primary key,\n    url text not null unique,\n    title text not null,\n    brief text,\n    tsv tsvector generated always as (\n       setweight(to_tsvector('english', coalesce(title,'')), 'A') ||\n        setweight(to_tsvector('english', coalesce(brief,'')), 'B')\n     ) stored,\n    doc_embedding vector(512),\n    logo text,\n    visitstotalcount bigint,\n    bouncerate float,\n    pagespervisit float,\n    visitsavgdurationformatted text,\n    created_at timestamp with time zone default timezone ('utc'::text, now()) not null\n  );\n\nalter table\n  items enable row level security;\n\ncreate policy\n  \"Enable public read access\" on items for\nselect\n  using (true);\n\ncreate or replace function match_items(\n    query_embedding vector(512),\n    match_threshold float,\n    match_count int\n)\nreturns table (\n    id bigint,\n    url text,\n    title text,\n    brief text,\n    logo text,\n    visitstotalcount bigint,\n    bouncerate float,\n    pagespervisit float,\n    visitsavgdurationformatted text,\n    similarity float\n)\nlanguage plpgsql\nas $$\nbegin\nreturn query\n  select\n    items.id,\n    items.url,\n    items.title,\n    items.brief,\n    items.logo,\n    items.visitstotalcount,\n    items.bouncerate,\n    items.pagespervisit,\n    items.visitsavgdurationformatted,\n    1 - (items.doc_embedding <=> query_embedding) as similarity\n  from items\n  where\n  1 - (items.doc_embedding <=> query_embedding) > match_threshold\n  order by items.doc_embedding <=> query_embedding\n  limit match_count;\nend;\n$$;\n\ncreate or replace function fts_match_items_ranked(\n    query_string text,\n    match_count int\n)\nreturns table (\n    id bigint,\n    url text,\n    title text,\n    brief text,\n    logo text,\n    visitstotalcount bigint,\n    bouncerate float,\n    pagespervisit float,\n    visitsavgdurationformatted text,\n    rank float\n)\nlanguage plpgsql\nas $$\nbegin\nreturn query\n  select\n    items.id,\n    items.url,\n    items.title,\n    items.brief,\n    items.logo,\n    items.visitstotalcount,\n    items.bouncerate,\n    items.pagespervisit,\n    items.visitsavgdurationformatted,\n    ts_rank_cd(items.tsv, to_tsquery(query_string)) as rank\n  from\n    items\n  where\n    items.tsv @@ to_tsquery(query_string)\n  order by\n    rank DESC\n  limit\n    match_count;\nend;\n$$;"
  }
]