Repository: DiscovAI/DiscovAI-search Branch: main Commit: 0499fae24f94 Files: 79 Total size: 144.1 KB Directory structure: gitextract_sui8u3lf/ ├── .eslintrc.json ├── .gitignore ├── LICENSE ├── README.md ├── components.json ├── next.config.mjs ├── package.json ├── postcss.config.mjs ├── src/ │ ├── app/ │ │ ├── api/ │ │ │ ├── chat/ │ │ │ │ └── route.ts │ │ │ └── join-wait/ │ │ │ └── route.ts │ │ ├── blocked/ │ │ │ └── page.tsx │ │ ├── globals.css │ │ ├── layout.tsx │ │ ├── page.tsx │ │ ├── robots.txt │ │ └── waitlist/ │ │ └── page.tsx │ ├── components/ │ │ ├── ask-input.tsx │ │ ├── assistant-message.tsx │ │ ├── chat-panel.tsx │ │ ├── image-section.tsx │ │ ├── landing/ │ │ │ ├── hero.tsx │ │ │ ├── preview-landing.tsx │ │ │ ├── typing-title.tsx │ │ │ └── wailtlist.tsx │ │ ├── magicui/ │ │ │ └── typing-animation.tsx │ │ ├── markdown.tsx │ │ ├── message.tsx │ │ ├── messages-list.tsx │ │ ├── mode-toggle.tsx │ │ ├── more-results.tsx │ │ ├── nav.tsx │ │ ├── related-questions.tsx │ │ ├── search-results.tsx │ │ ├── section.tsx │ │ ├── shared/ │ │ │ ├── icons.tsx │ │ │ └── max-width-wrapper.tsx │ │ ├── starter-questions.tsx │ │ ├── theme-provider.tsx │ │ ├── ui/ │ │ │ ├── accordion.tsx │ │ │ ├── alert.tsx │ │ │ ├── avatar.tsx │ │ │ ├── badge.tsx │ │ │ ├── button.tsx │ │ │ ├── card.tsx │ │ │ ├── dropdown-menu.tsx │ │ │ ├── hover-card.tsx │ │ │ ├── input.tsx │ │ │ ├── label.tsx │ │ │ ├── select.tsx │ │ │ ├── separator.tsx │ │ │ ├── skeleton.tsx │ │ │ ├── switch.tsx │ │ │ ├── tabs.tsx │ │ │ ├── textarea.tsx │ │ │ ├── timeline.tsx │ │ │ ├── toast.tsx │ │ │ ├── toaster.tsx │ │ │ ├── toggle.tsx │ │ │ ├── tooltip.tsx │ │ │ ├── typewriter-effect.tsx │ │ │ └── use-toast.ts │ │ └── user-message.tsx │ ├── config/ │ │ └── sites.ts │ ├── db/ │ │ ├── init.sql │ │ ├── redis.ts │ │ └── supabase.ts │ ├── env.mjs │ ├── hooks/ │ │ └── chat.ts │ ├── lib/ │ │ ├── chat/ │ │ │ ├── embedding.ts │ │ │ ├── llm.ts │ │ │ └── prompts.ts │ │ └── utils.ts │ ├── middleware.ts │ ├── providers.tsx │ ├── schema/ │ │ └── chat.ts │ └── stores/ │ ├── index.ts │ └── slices/ │ └── messageSlice.ts ├── tailwind.config.ts └── tsconfig.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintrc.json ================================================ { "extends": "next/core-web-vitals" } ================================================ FILE: .gitignore ================================================ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies /node_modules /.pnp .pnp.js .yarn/install-state.gz # testing /coverage # next.js /.next/ /out/ # production /build # misc .DS_Store *.pem # debug npm-debug.log* yarn-debug.log* yarn-error.log* # local env files .env*.local .env # vercel .vercel # typescript *.tsbuildinfo next-env.d.ts copy_github_release.sh supabase/ ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2024 Yoshiki Miura Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ # DiscovAI An AI-powered search engine for AI tools, or your own data. https://github.com/user-attachments/assets/2cdc92d0-d0c9-4098-8166-260e973783f0 Please feel free to contact me on [Twitter](https://x.com/ruiyanghim) or [create an issue](https://github.com/DiscovAI/DiscovAI-search/issues/new) if you have any questions. ## 💻 Live Demo [DiscovAI.io](https://discovai.io/) (use it for free without signin or credit card) ## 🗂️ Overview - 🛠 [Features](#-features) - 🧱 [Tech-Stack](#-stack) - 🚀 [Quickstart](#-quickstart) - 🌐 [Deploy](#-deploy) ## 🛠 Features - **Vector-based Search**: Converts user queries into vectors for precise similarity matching in our AI product database. - **Redis-powered Caching**: Utilizes Redis to cache search results and outputs, significantly improving response times for repeated queries. - **Comprehensive AI Database**: Maintains an up-to-date collection of AI products across various categories and industries. - **LLM-powered Responses**: Leverages large language models to provide detailed, context-aware answers based on search results. - **User-friendly Interface**: Offers an intuitive design for effortless navigation and efficient AI product discovery. ## 🧱 Stack - App framework: [Next.js](https://nextjs.org/) - Text streaming: [Vercel AI SDK](https://sdk.vercel.ai/docs) - LLM Model: [gpt-4o-mini](https://openai.com/) - Database: [Supabase](https://supabase.com/) - Vector: [Pgvector](https://github.com/pgvector/pgvector) - Embedding Model: [Jina AI](https://jina.ai/embeddings) - Redis Cache: [Upstash](https://upstash.com/) - Component library: [shadcn/ui](https://ui.shadcn.com/) - Headless component primitives: [Radix UI](https://www.radix-ui.com/) - Styling: [Tailwind CSS](https://tailwindcss.com/) ## 🚀 Quickstart ### 1. Clone repo run the following command to clone the repo: ``` git clone https://github.com/DiscovAI/DiscovAI-search ``` ### 2. Install dependencies ``` cd discovai-search pnpm i ``` ### 3. Setting up Supabase create a supabase [project](https://supabase.com/dashboard/projects), then run the src/db/init.sql in [SQL Editor](https://supabase.com/docs/guides/database/overview) to setup database ### 4. Setting up Upstash Follow the guide below to set up Upstash Redis. Create a database and obtain `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`. Refer to the [Upstash guide](https://upstash.com/blog/rag-chatbot-upstash#setting-up-upstash-redis) for instructions on how to proceed. ### 4. Fill out secrets ``` cp .env.local.example .env.local ``` Your .env.local file should look like this: ``` # Required # for match documents NEXT_PUBLIC_SUPABASE_URL= NEXT_PUBLIC_SUPABASE_ANON_KEY= # for embedding query, retrieved here: https://jina.ai/embeddings/ JINA_API_KEY= # for llm output, retrieved here: https://platform.openai.com/api-keys OPENAI_API_KEY= OPENAI_API_URL= # for llm cache and serach cache UPSTASH_REDIS_REST_URL= UPSTASH_REDIS_REST_TOKEN= ``` ### 5. Run app locally ``` pnpm dev ``` You can now visit http://localhost:3000. ## 🌐 Deploy You can deploy on any saas platform like vercel, zeabur, cloudflare pages. ## 🌟 History Star History Chart ================================================ FILE: components.json ================================================ { "$schema": "https://ui.shadcn.com/schema.json", "style": "new-york", "rsc": true, "tsx": true, "tailwind": { "config": "tailwind.config.ts", "css": "src/app/globals.css", "baseColor": "zinc", "cssVariables": true, "prefix": "" }, "aliases": { "components": "@/components", "utils": "@/lib/utils", "ui": "@/components/ui", "magicui": "@/components/magicui" } } ================================================ FILE: next.config.mjs ================================================ /** @type {import('next').NextConfig} */ const nextConfig = { images: { remotePatterns: [ { protocol: "https", hostname: "**", }, { protocol: "http", hostname: "**", }, ], }, compiler: { removeConsole: !!process.env.CI, }, }; export default nextConfig; ================================================ FILE: package.json ================================================ { "name": "discovai-search", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" }, "dependencies": { "@ai-sdk/openai": "^0.0.40", "@langchain/community": "^0.2.21", "@microsoft/fetch-event-source": "^2.0.1", "@next/env": "^14.2.3", "@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-avatar": "^1.1.0", "@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-hover-card": "^1.0.7", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-label": "^2.0.2", "@radix-ui/react-select": "^2.0.0", "@radix-ui/react-separator": "^1.0.3", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-switch": "^1.0.3", "@radix-ui/react-tabs": "^1.1.0", "@radix-ui/react-toast": "^1.1.5", "@radix-ui/react-toggle": "^1.0.3", "@radix-ui/react-tooltip": "^1.0.7", "@supabase/supabase-js": "^2.44.4", "@t3-oss/env-nextjs": "^0.10.1", "@tanstack/react-query": "^5.32.0", "@upstash/ratelimit": "^2.0.1", "@upstash/redis": "^1.33.0", "ai": "^3.2.38", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", "framer-motion": "^11.1.7", "geist": "^1.3.0", "ioredis": "^5.4.1", "lodash": "^4.17.21", "lucide-react": "^0.376.0", "next": "14.2.3", "next-themes": "^0.3.0", "react": "^18", "react-dom": "^18", "react-hot-toast": "^2.4.1", "react-markdown": "^9.0.1", "react-textarea-autosize": "^8.5.3", "rehype-raw": "^7.0.0", "tailwind-merge": "^2.3.0", "tailwindcss-animate": "^1.0.7", "zod": "^3.23.8", "zustand": "^4.5.2" }, "devDependencies": { "@tailwindcss/typography": "^0.5.13", "@types/lodash": "^4.17.0", "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", "eslint": "^8", "eslint-config-next": "14.2.3", "postcss": "^8", "prettier": "^3.2.5", "tailwindcss": "^3.4.1", "typescript": "^5" } } ================================================ FILE: postcss.config.mjs ================================================ /** @type {import('postcss-load-config').Config} */ const config = { plugins: { tailwindcss: {}, }, }; export default config; ================================================ FILE: src/app/api/chat/route.ts ================================================ // app/api/stream/route.ts import { embeddingVectorCacheKey, llmResultCacheKey, redis } from "@/db/redis"; import { supabase } from "@/db/supabase"; import { generateQueyEmbedding } from "@/lib/chat/embedding"; import { genLLMTextChunk, translate } from "@/lib/chat/llm"; import { addRefToUrl, genStream, sleep } from "@/lib/utils"; import { StreamEvent } from "@/schema/chat"; import { PostgrestError } from "@supabase/supabase-js"; import { NextRequest } from "next/server"; export async function POST(req: NextRequest) { const body = await req.json(); const { query } = body; const customReadable = new ReadableStream({ async start(controller) { try { const beginData = { event: StreamEvent.BEGIN_STREAM, data: { event_type: StreamEvent.BEGIN_STREAM, query: query }, }; controller.enqueue(genStream(beginData)); const cacheResult: null | any = await redis.get( embeddingVectorCacheKey(query) ); let documents: any[], queryEmbeddingError: PostgrestError; if (cacheResult) { documents = cacheResult; console.log("search result", "cached"); } else { // match documents const embedding = await generateQueyEmbedding( await translate({ query }) ); let result = await supabase.rpc("match_embeddings", { query_embedding: embedding, // Pass the embedding you want to compare match_threshold: 0.78, // Choose an appropriate threshold for your data match_count: 15, // Choose the number of matches }); documents = result.data; queryEmbeddingError = result.error; } if (queryEmbeddingError) { console.error(queryEmbeddingError); controller.enqueue( genStream({ event: StreamEvent.ERROR, data: { event_type: StreamEvent.ERROR, detail: "error on query embeddings", }, }) ); controller.close(); } redis.setex( embeddingVectorCacheKey(query), 60 * 60 * 24, // 1 day JSON.stringify(documents) ); // filter for unique docs const uniqueDocuments = [ ...new Set(documents.map((tool) => tool.metadata.url)), ].map((url) => documents.find((tool) => tool.metadata.url === url)); for (let doc of uniqueDocuments) { doc.metadata.url = addRefToUrl(doc.metadata.url); } documents = uniqueDocuments.slice(0, 5); const searchResult = documents.map((d) => { const safeContent = d.chunk_text.includes("DESCRIPTION") ? d.chunk_text?.split("---")?.[0]?.split("DESCRIPTION:")?.[1] : d.chunk_text; return { title: d.metadata.title, url: d.metadata.url, content: safeContent, description: safeContent, screenshot_url: d.screenshot_url, }; }); controller.enqueue( genStream({ event: StreamEvent.SEARCH_RESULTS, data: { event_type: StreamEvent.SEARCH_RESULTS, results: searchResult, images: uniqueDocuments.map((r) => r.screenshot_url), }, }) ); // stream llm text chunk const llmKey = llmResultCacheKey(query); const llmCache: string | null = await redis.get(llmKey); let gathered = ""; if (llmCache) { console.log("llm result cache", "cached"); gathered = llmCache; // simulate stream let cacheArray = llmCache.split(" "); for await (const c of cacheArray) { await sleep(10); controller.enqueue( genStream({ event: StreamEvent.TEXT_CHUNK, data: { event_type: StreamEvent.TEXT_CHUNK, text: c + " ", }, }) ); } } else { const stream = await genLLMTextChunk({ query, contexts: documents, }); for await (const chunk of stream.textStream) { controller.enqueue( genStream({ event: StreamEvent.TEXT_CHUNK, data: { event_type: StreamEvent.TEXT_CHUNK, text: chunk, }, }) ); gathered += chunk; } } redis.setex(llmKey, 60 * 60 * 12, gathered); // more results or related query const moreTools = uniqueDocuments.slice(5); controller.enqueue( genStream({ event: StreamEvent.MORE_RESULTS, data: { event_type: StreamEvent.MORE_RESULTS, more_results: moreTools.map((d) => ({ title: d.metadata.title, url: d.metadata.url, screenshot_url: d.screenshot_url, })), }, }) ); controller.enqueue( genStream({ event: StreamEvent.FINAL_RESPONSE, data: { event_type: StreamEvent.FINAL_RESPONSE, message: gathered, }, }) ); controller.enqueue( genStream({ event: StreamEvent.STREAM_END, data: { event_type: StreamEvent.STREAM_END, thread_id: null }, }) ); controller.close(); } catch (error) { console.error(error); controller.enqueue( genStream({ event: StreamEvent.ERROR, data: { event_type: StreamEvent.ERROR, detail: "Oops~", }, }) ); controller.close(); } }, }); return new Response(customReadable, { headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", Connection: "keep-alive", }, }); } ================================================ FILE: src/app/api/join-wait/route.ts ================================================ import { NextRequest } from "next/server"; import { supabase } from "@/db/supabase"; async function postHandler(req: NextRequest) { try { const body = await req.json(); const { email } = body; const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/; if (!emailRegex.test(email)) { return new Response(JSON.stringify("Invalid email format"), { status: 400, }); } const { error, data } = await supabase .from("searchzero-waitlist") .insert({ email_address: email, }) .select(); if (error) { if (error.code === "23505") { return new Response( JSON.stringify({ isSuc: true, code: 0, msg: "Already subscribed", }) ); } throw error; } if (data && data.length) { return new Response( JSON.stringify({ isSuc: true, code: 0, msg: "Subscription successful", }) ); } } catch (error) { console.error(error); return new Response("Failed to subscribe, pleas Try again", { status: 501, }); } } export const POST = postHandler; export const runtime = "edge"; ================================================ FILE: src/app/blocked/page.tsx ================================================ export default function Blocked() { return (

Access blocked.

); } ================================================ FILE: src/app/globals.css ================================================ @tailwind base; @tailwind components; @tailwind utilities; @layer base { :root { --background: 60 30% 98%; --foreground: 0 0% 3.9%; --card: 0 0% 96.1%; --card-foreground: 0 0% 45.1%; --popover: 0 0% 100%; --popover-foreground: 0 0% 3.9%; --primary: 0 0% 9%; --primary-foreground: 0 0% 98%; --secondary: 0 0% 96.1%; --secondary-foreground: 0 0% 9%; --muted: 0 0% 96.1%; --muted-foreground: 0 0% 45.1%; --accent: 240 4.8% 95.9%; --accent-foreground: 240 5.9% 10%; --tint: 27 100% 49.8%; --tint-foreground: 25 76% 31%; --destructive: 0 84.2% 60.2%; --destructive-foreground: 0 0% 98%; --border: 0 0% 89.8%; --input: 0 0% 89.8%; --ring: 0 0% 89.8%; --radius: 0.5rem; } .dark { --background: 180 2% 10%; --foreground: 0 0% 98%; --card: 180 3% 13%; --card-foreground: 0 0% 63.9%; --popover: 180 2% 10%; --popover-foreground: 0 0% 98%; --primary: 0 0% 98%; --primary-foreground: 0 0% 9%; --secondary: 0 0% 14.9%; --secondary-foreground: 0 0% 98%; --muted: 0 0% 14.9%; --muted-foreground: 0 0% 63.9%; --accent: 240 3.7% 15.9%; --accent-foreground: 0 0% 98%; --tint: 22.4 100% 53%; --tint-foreground: 0 0% 98%; --destructive: 0 62.8% 30.6%; --destructive-foreground: 0 0% 98%; --border: 0 0% 14.9%; --input: 0 0% 14.9%; --ring: 0 0% 14.9%; } } @layer base { * { @apply border-border; } body { @apply bg-background text-foreground; } } .cl-internal-11ttlho { display: none; opacity: 0; } .cl-internal-180wb59 { display: none; opacity: 0; } ================================================ FILE: src/app/layout.tsx ================================================ import { Navbar } from "@/components/nav"; import { ThemeProvider } from "@/components/theme-provider"; import { LinkConfig, SiteConfig } from "@/config/sites"; import { cn } from "@/lib/utils"; import Providers from "@/providers"; import { GeistSans } from "geist/font/sans"; import type { Metadata } from "next"; import Script from "next/script"; import { Toaster } from "react-hot-toast"; import "./globals.css"; const title = SiteConfig.metaTitle; const description = SiteConfig.desc; export const metadata: Metadata = { metadataBase: new URL(LinkConfig.site), title, description, keywords: [ "searchgpt", "topaitools", "ai", "chatgpt", "discov-ai", "discover ai", "search engine", "top ai traffic", "ai search engine", ], openGraph: { title, description, images: "/og.png", url: new URL(LinkConfig.site), type: "website", siteName: SiteConfig.name, }, twitter: { title, description, card: "summary_large_image", creator: "@ruiyanghim", images: "/og.png", site: LinkConfig.site, }, icons: ["/favicon.svg"], alternates: { canonical: "./", }, }; export default function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { return ( <> {children} ); } ================================================ FILE: src/app/page.tsx ================================================ import { ChatPanel } from "@/components/chat-panel"; import { Suspense } from "react"; export default function Home() { return ( <>
); } ================================================ FILE: src/app/robots.txt ================================================ User-Agent: * Allow: / Disallow: /auth ================================================ FILE: src/app/waitlist/page.tsx ================================================ import HeroLanding from "@/components/landing/hero"; import PreviewLanding from "@/components/landing/preview-landing"; export default function Page() { return ( <> ); } ================================================ FILE: src/components/ask-input.tsx ================================================ import TextareaAutosize from "react-textarea-autosize"; import { useState } from "react"; import { Button } from "./ui/button"; import { ArrowRight, ArrowUp } from "lucide-react"; const InputBar = ({ input, setInput, }: { input: string; setInput: (input: string) => void; }) => { return (
setInput(e.target.value)} value={input} />
); }; const FollowingUpInput = ({ input, setInput, }: { input: string; setInput: (input: string) => void; }) => { return (
setInput(e.target.value)} value={input} />
{/* */}
); }; export const AskInput = ({ sendMessage, isFollowingUp = false, }: { sendMessage: (message: string) => void; isFollowingUp?: boolean; }) => { const [input, setInput] = useState(""); return ( <>
{ if (input.trim().length < 5) return; e.preventDefault(); sendMessage(input); setInput(""); }} onKeyDown={(e) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); if (input.trim().length < 5) return; sendMessage(input); setInput(""); } }} > {isFollowingUp ? ( // <> ) : ( )} ); }; ================================================ FILE: src/components/assistant-message.tsx ================================================ import { MessageComponent, MessageComponentSkeleton } from "./message"; import { SearchResultsSkeleton, SearchResults } from "./search-results"; import { Section } from "./section"; import { AlertCircle } from "lucide-react"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { ImagePreload } from "./image-section"; import { ChatMessage } from "@/schema/chat"; import MoreResults from "./more-results"; export function ErrorMessage({ content }: { content: string }) { return ( Error {content} ); } export const AssistantMessageContent = ({ message, isStreaming = false, onRelatedQuestionSelect, }: { message: ChatMessage; isStreaming?: boolean; onRelatedQuestionSelect: (question: string) => void; }) => { const { sources, content, related_queries, images, is_error_message = false, more_results, } = message; if (is_error_message) { return ; } return (
{!sources || sources.length === 0 ? ( ) : ( <> )}
{content ? ( ) : ( )}
{more_results && more_results.length > 0 && (
)}
); }; ================================================ FILE: src/components/chat-panel.tsx ================================================ "use client"; import { useChat } from "@/hooks/chat"; import { useChatStore } from "@/stores"; import { useSearchParams } from "next/navigation"; import { useEffect, useRef, useState } from "react"; import { AskInput } from "./ask-input"; import { SiteConfig } from "@/config/sites"; import { LoaderIcon, TrendingUpIcon } from "lucide-react"; import { MessageRole } from "@/schema/chat"; import MessagesList from "./messages-list"; import { StarterQuestionsList } from "./starter-questions"; const useAutoScroll = (ref: React.RefObject) => { const { messages } = useChatStore(); useEffect(() => { if (messages.at(-1)?.role === MessageRole.USER) { ref.current?.scrollIntoView({ behavior: "smooth", block: "end", }); } }, [messages, ref]); }; const useAutoResizeInput = ( ref: React.RefObject, setWidth: (width: number) => void ) => { const { messages } = useChatStore(); useEffect(() => { const updatePosition = () => { if (ref.current) { setWidth(ref.current.scrollWidth); } }; updatePosition(); window.addEventListener("resize", updatePosition); return () => { window.removeEventListener("resize", updatePosition); }; }, [messages, ref, setWidth]); }; const useAutoFocus = (ref: React.RefObject) => { useEffect(() => { ref.current?.focus(); }, [ref]); }; export const ChatPanel = ({ threadId }: { threadId?: number }) => { const searchParams = useSearchParams(); const queryMessage = searchParams.get("q"); const hasRun = useRef(false); const { handleSend, streamingMessage, isStreamingMessage } = useChat(); const { messages, setMessages, setThreadId } = useChatStore(); const [width, setWidth] = useState(0); const messagesRef = useRef(null); const messageBottomRef = useRef(null); const inputRef = useRef(null); useAutoScroll(messageBottomRef); useAutoResizeInput(messagesRef, setWidth); useAutoFocus(inputRef); useEffect(() => { if (queryMessage && !hasRun.current) { setThreadId(null); hasRun.current = true; handleSend(queryMessage); } }, [queryMessage]); useEffect(() => { if (messages.length == 0) { setThreadId(null); } }, [messages, setThreadId]); return ( <> {messages.length > 0 ? (
) : (
{SiteConfig.subPanel}
People are searching
)} ); }; ================================================ FILE: src/components/image-section.tsx ================================================ /* eslint-disable @next/next/no-img-element */ "use client"; import { Skeleton } from "./ui/skeleton"; export const ImageSectionSkeleton = () => { return ( <>
{[...Array(4)].map((_, index) => (
))}
); }; export function ImagePreload({ images }: { images: string[] }) { if (images && images.length > 0) { return (
{images.map((image) => ( ))}
); } return null; } ================================================ FILE: src/components/landing/hero.tsx ================================================ import { Icons } from "@/components/shared/icons"; import { buttonVariants } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import Link from "next/link"; import { TypingTitle } from "./typing-title"; import { SubscribeForm } from "./wailtlist"; export default async function HeroLanding() { return (
🎉 Introducing  DiscovAI on{" "}

Stay ahead in AI with DiscovAI, Your Go-To Source for the Latest {" "} AI Products | News | Companies | Models

); } ================================================ FILE: src/components/landing/preview-landing.tsx ================================================ import Image from "next/image"; import MaxWidthWrapper from "@/components/shared/max-width-wrapper"; export default function PreviewLanding() { return (
preview landing
); } ================================================ FILE: src/components/landing/typing-title.tsx ================================================ "use client"; import { useEffect, useState } from "react"; import { TypewriterEffect, TypewriterEffectSmooth, } from "../ui/typewriter-effect"; const typingTextList = [ { text: "Your", }, { text: "Serach ", }, { text: "Engine", }, { text: "for ", }, { text: "Anything", }, { text: "About AI", className: "text-tint dark:text-tint", }, ]; export function TypingTitle() { const [textList, setTextList] = useState(typingTextList); // useEffect(() => { // let effect; // setTimeout(() => { // effect = setInterval(() => { // console.log("setting"); // const newTextList = [...textList]; // newTextList[newTextList.length - 1].text = "Models"; // setTextList(newTextList); // }, 1000); // }, 2000); // }, []); return ( <>

Your Serach Engine for Anything About AI

); } ================================================ FILE: src/components/landing/wailtlist.tsx ================================================ "use client"; import { Input } from "@/components/ui/input"; import { cn, nFormatter } from "@/lib/utils"; import { Button } from "../ui/button"; import { Icons } from "../shared/icons"; import { useState, FC } from "react"; import toast from "react-hot-toast"; import { Loader2, ChevronRight } from "lucide-react"; export function WailtList() { return (
); } export const SubscribeForm: FC = () => { const [email, setEmail] = useState(""); const [message, setMessage] = useState(""); const [loading, setLoading] = useState(false); const handleSubscribe = async (e: React.FormEvent) => { e.preventDefault(); // Validate email format const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/; if (!emailRegex.test(email)) { toast("Please enter a valid email address", { id: "subscripe-toast", }); return; } try { setLoading(true); toast.loading("🙏 Thank you...", { id: "subscripe-toast" }); const response = await fetch("/api/join-waitlist", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ email }), }); if (!response.ok) { throw new Error("Failed to subscribe"); } toast.success("👍 You have joined the wailt list of DiscovAI !", { id: "subscripe-toast", }); setMessage("Subscription successful!"); setEmail(""); } catch (error: any) { toast.error("Something wrong happens, please try again!", { id: "subscripe-toast", }); setMessage(error.message); } finally { setLoading(false); } }; return (
setEmail(e.target.value)} />
); }; ================================================ FILE: src/components/magicui/typing-animation.tsx ================================================ "use client"; import { useEffect, useState } from "react"; import { cn } from "@/lib/utils"; interface TypingAnimationProps { duration?: number; className?: string; textList: string[]; } export default function TypingAnimation({ duration = 200, className, textList, }: TypingAnimationProps) { const [displayedText, setDisplayedText] = useState(""); const [i, setI] = useState(0); const [wordI, setWordI] = useState(0); useEffect(() => { const typingEffect = setInterval(() => { if (i < textList[wordI].length) { setDisplayedText(textList[wordI].substring(0, i + 1)); setI(i + 1); } else { setTimeout(() => { setWordI((wordI + 1) % textList.length); setI(0); }, 1000); // clearInterval(typingEffect); } }, duration); return () => { clearInterval(typingEffect); }; }, [duration, i, wordI]); return (

{displayedText ? displayedText : textList[wordI]}

); } ================================================ FILE: src/components/markdown.tsx ================================================ import { FC, memo } from "react"; import ReactMarkdown, { Options } from "react-markdown"; export const MemoizedReactMarkdown: FC = memo( ReactMarkdown, (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className, ); ================================================ FILE: src/components/message.tsx ================================================ import React, { FC, memo, useEffect, useMemo, useState } from "react"; import { MemoizedReactMarkdown } from "./markdown"; import rehypeRaw from "rehype-raw"; import _ from "lodash"; import { cn } from "@/lib/utils"; import { Skeleton } from "./ui/skeleton"; import { ChatMessage } from "@/schema/chat"; function chunkString(str: string): string[] { const words = str.split(" "); const chunks = _.chunk(words, 2).map((chunk) => chunk.join(" ") + " "); return chunks; } export interface MessageProps { message: ChatMessage; isStreaming?: boolean; } const CitationText = ({ number, href }: { number: number; href: string }) => { return ` `; }; const Text = ({ children, isStreaming, containerElement = "p", }: { children: React.ReactNode; isStreaming: boolean; containerElement: React.ElementType; }) => { const renderText = (node: React.ReactNode): React.ReactNode => { if (typeof node === "string") { const chunks = isStreaming ? chunkString(node) : [node]; return chunks.flatMap((chunk, index) => { return ( {chunk} ); }); } else if (React.isValidElement(node)) { return React.cloneElement( node, node.props, renderText(node.props.children) ); } else if (Array.isArray(node)) { return node.map((child, index) => ( {renderText(child)} )); } return null; }; const text = renderText(children); return React.createElement(containerElement, {}, text); }; const StreamingParagraph = memo( ({ children }: React.HTMLProps) => { return ( {children} ); } ); const Paragraph = memo( ({ children }: React.HTMLProps) => { return ( {children} ); } ); const ListItem = memo(({ children }: React.HTMLProps) => { return ( {children} ); }); const StreamingListItem = memo( ({ children }: React.HTMLProps) => { return ( {children} ); } ); StreamingParagraph.displayName = "StreamingParagraph"; Paragraph.displayName = "Paragraph"; ListItem.displayName = "ListItem"; StreamingListItem.displayName = "StreamingListItem"; export const MessageComponent: FC = ({ message, isStreaming = false, }) => { const { content, sources } = message; const [parsedMessage, setParsedMessage] = useState(content); useEffect(() => { const citationRegex = /(\[\d+\])/g; const newMessage = content.replace(citationRegex, (match) => { const number = match.slice(1, -1); const source = sources?.find( (source, idx) => idx + 1 === parseInt(number) ); return CitationText({ number: parseInt(number), href: source?.url ?? "", }); }); setParsedMessage(newMessage); }, [content, sources]); return ( {parsedMessage} ); }; export const MessageComponentSkeleton = () => { return ( <>
); }; ================================================ FILE: src/components/messages-list.tsx ================================================ import { AssistantMessageContent } from "./assistant-message"; import { Separator } from "./ui/separator"; import { UserMessageContent } from "./user-message"; import { memo } from "react"; import { ChatMessage, MessageRole } from "@/schema/chat"; const MessagesList = ({ messages, streamingMessage, isStreamingMessage, onRelatedQuestionSelect, }: { messages: ChatMessage[]; streamingMessage: ChatMessage | null; isStreamingMessage: boolean; onRelatedQuestionSelect: (question: string) => void; }) => { return (
{messages.map((message, index) => message.role === MessageRole.USER ? ( ) : (
{index !== messages.length - 1 && }
) )} {streamingMessage && isStreamingMessage && ( )}
); }; export default memo(MessagesList); ================================================ FILE: src/components/mode-toggle.tsx ================================================ "use client"; import * as React from "react"; import { ComputerIcon, Moon, Sun } from "lucide-react"; import { useTheme } from "next-themes"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; export function ModeToggle() { const { setTheme } = useTheme(); return ( {["light", "dark", "system"].map((theme) => ( setTheme(theme)} > {theme === "light" && } {theme === "dark" && } {theme === "system" && } {theme.charAt(0).toUpperCase() + theme.slice(1)} ))} ); } ================================================ FILE: src/components/more-results.tsx ================================================ import { PlusIcon } from "lucide-react"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import Image from "next/image"; export default function MoreResults({ results, }: { results: { url: string; title: string; screenshot_url: string }[]; }) { return (
{results.map((res, i) => (
{res.title}
{res.title}
))}
); } ================================================ FILE: src/components/nav.tsx ================================================ "use client"; import Link from "next/link"; import { ModeToggle } from "./mode-toggle"; import { useTheme } from "next-themes"; import { Button, buttonVariants } from "./ui/button"; import { PlusIcon } from "lucide-react"; import { useChatStore } from "@/stores"; import { useRouter } from "next/navigation"; import { SiteConfig, LinkConfig } from "@/config/sites"; import { GitHubLogoIcon } from "@radix-ui/react-icons"; import { Icons } from "./shared/icons"; import { cn } from "@/lib/utils"; const NewChatButton = () => { return ( ); }; const TextLogo = () => { // return <>; return (
{SiteConfig.name}
); }; export function Navbar() { const router = useRouter(); const { theme } = useTheme(); const { messages } = useChatStore(); const onHomePage = messages.length === 0; return (
(location.href = "/")}> Logo {onHomePage ? : }
); } ================================================ FILE: src/components/related-questions.tsx ================================================ import { PlusIcon } from "lucide-react"; export default function RelatedQuestions({ questions, onSelect, }: { questions: string[]; onSelect: (question: string) => void; }) { return (
{questions.map((question, index) => (
onSelect(question)} > {question.toLowerCase()}
))}
); } ================================================ FILE: src/components/search-results.tsx ================================================ /* eslint-disable @next/next/no-img-element */ "use client"; import { useState } from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Skeleton } from "./ui/skeleton"; import { HoverCard, HoverCardContent, HoverCardTrigger, } from "@/components/ui/hover-card"; import { SearchResult } from "@/schema/chat"; export const SearchResultsSkeleton = () => { return ( <>
{[...Array(4)].map((_, index) => (
))}
); }; export const Logo = ({ url }: { url: string }) => { return (
favicon
); }; export function SearchResults({ results }: { results: SearchResult[] }) { const [showAll, setShowAll] = useState(false); const displayedResults = showAll ? results : results.slice(0, 3); const additionalCount = results.length > 3 ? results.length - 3 : 0; const additionalResults = results.slice(3, 3 + additionalCount); return (
{displayedResults.map(({ title, url, content, description }, index) => { const formattedUrl = new URL(url).hostname.split(".").slice(-2, -1)[0]; return (
{formattedUrl}

{title}

{content}
); })} {!showAll && additionalCount > 0 && (
setShowAll(true)} >
{additionalResults.map(({ url }, index) => { return ; })}
View {additionalCount} more
)}
); } ================================================ FILE: src/components/section.tsx ================================================ import { cn } from "@/lib/utils"; import { BookOpen, BookOpenIcon, CameraIcon, ListOrderedIcon, ListPlusIcon, SparkleIcon, SparklesIcon, StarIcon, TextSearchIcon, } from "lucide-react"; import { motion } from "framer-motion"; export const Section = ({ title, children, animate = true, streaming = false, }: { title: "Sources" | "Answer" | "Related" | "Images" | "More Results"; children: React.ReactNode; animate?: boolean; streaming?: boolean; }) => { const iconMap = { Sources: BookOpenIcon, Answer: SparkleIcon, Related: ListPlusIcon, Images: CameraIcon, "More Results": ListOrderedIcon, }; const IconComponent = iconMap[title] || StarIcon; return (
{title === "Answer" && streaming ? ( ) : ( )}
{title}
{children}
); }; ================================================ FILE: src/components/shared/icons.tsx ================================================ import { AlertTriangle, ArrowRight, ArrowUpRight, Check, ChevronLeft, ChevronRight, Copy, CreditCard, File, FileText, HelpCircle, Image, Laptop, Loader2, LucideIcon, LucideProps, Moon, MoreVertical, Plus, Puzzle, Search, Settings, SunMedium, Trash, User, X, } from "lucide-react"; export type Icon = LucideIcon; export const Icons = { add: Plus, arrowRight: ArrowRight, arrowUpRight: ArrowUpRight, billing: CreditCard, chevronLeft: ChevronLeft, chevronRight: ChevronRight, check: Check, close: X, copy: Copy, ellipsis: MoreVertical, gitHub: ({ ...props }: LucideProps) => ( ), google: ({ ...props }: LucideProps) => ( ), nextjs: ({ ...props }: LucideProps) => ( ), help: HelpCircle, laptop: Laptop, logo: Puzzle, media: Image, moon: Moon, page: File, post: FileText, search: Search, settings: Settings, spinner: Loader2, sun: SunMedium, trash: Trash, twitter: ({ ...props }: LucideProps) => ( ), user: User, warning: AlertTriangle, }; ================================================ FILE: src/components/shared/max-width-wrapper.tsx ================================================ import { ReactNode } from "react"; import { cn } from "@/lib/utils"; export default function MaxWidthWrapper({ className, children, large = false, }: { className?: string; large?: boolean; children: ReactNode; }) { return (
{children}
); } ================================================ FILE: src/components/starter-questions.tsx ================================================ import { ArrowRight, ArrowUpRight } from "lucide-react"; const starterQuestions = [ "I want to make old photos high definition", "Tools that can help me market better on Twitter", "Auto-generated seo friendly blogs from my website", "I need an AI girlfriend with multiple roles to choose from", ]; export const StarterQuestionsList = ({ handleSend, }: { handleSend: (question: string) => void; }) => { return (
    {starterQuestions.map((question) => (
  • ))}
); }; ================================================ FILE: src/components/theme-provider.tsx ================================================ "use client"; import * as React from "react"; import { ThemeProvider as NextThemesProvider } from "next-themes"; import { type ThemeProviderProps } from "next-themes/dist/types"; export function ThemeProvider({ children, ...props }: ThemeProviderProps) { return {children}; } ================================================ FILE: src/components/ui/accordion.tsx ================================================ "use client"; import * as React from "react"; import * as AccordionPrimitive from "@radix-ui/react-accordion"; import { ChevronDownIcon } from "@radix-ui/react-icons"; import { cn } from "@/lib/utils"; const Accordion = AccordionPrimitive.Root; const AccordionItem = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); AccordionItem.displayName = "AccordionItem"; const AccordionTrigger = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, children, ...props }, ref) => ( svg]:rotate-180", className, )} {...props} > {children} )); AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName; const AccordionContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, children, ...props }, ref) => (
{children}
)); AccordionContent.displayName = AccordionPrimitive.Content.displayName; export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }; ================================================ FILE: src/components/ui/alert.tsx ================================================ import * as React from "react"; import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "@/lib/utils"; const alertVariants = cva( "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7", { variants: { variant: { default: "bg-background text-foreground", destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive", }, }, defaultVariants: { variant: "default", }, }, ); const Alert = React.forwardRef< HTMLDivElement, React.HTMLAttributes & VariantProps >(({ className, variant, ...props }, ref) => (
)); Alert.displayName = "Alert"; const AlertTitle = React.forwardRef< HTMLParagraphElement, React.HTMLAttributes >(({ className, ...props }, ref) => (
)); AlertTitle.displayName = "AlertTitle"; const AlertDescription = React.forwardRef< HTMLParagraphElement, React.HTMLAttributes >(({ className, ...props }, ref) => (
)); AlertDescription.displayName = "AlertDescription"; export { Alert, AlertTitle, AlertDescription }; ================================================ FILE: src/components/ui/avatar.tsx ================================================ "use client" import * as React from "react" import * as AvatarPrimitive from "@radix-ui/react-avatar" import { cn } from "@/lib/utils" const Avatar = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )) Avatar.displayName = AvatarPrimitive.Root.displayName const AvatarImage = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )) AvatarImage.displayName = AvatarPrimitive.Image.displayName const AvatarFallback = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )) AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName export { Avatar, AvatarImage, AvatarFallback } ================================================ FILE: src/components/ui/badge.tsx ================================================ import * as React from "react"; import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "@/lib/utils"; const badgeVariants = cva( "inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", { variants: { variant: { default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80", secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", destructive: "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80", outline: "text-foreground", }, }, defaultVariants: { variant: "default", }, }, ); export interface BadgeProps extends React.HTMLAttributes, VariantProps {} function Badge({ className, variant, ...props }: BadgeProps) { return (
); } export { Badge, badgeVariants }; ================================================ FILE: src/components/ui/button.tsx ================================================ import * as React from "react"; import { Slot } from "@radix-ui/react-slot"; import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "@/lib/utils"; const buttonVariants = cva( "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50", { variants: { variant: { default: "bg-primary text-primary-foreground shadow hover:bg-primary/90", destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90", outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground", secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", ghost: "hover:bg-accent hover:text-accent-foreground", link: "text-primary underline-offset-4 hover:underline", }, size: { default: "h-9 px-4 py-2", sm: "h-8 rounded-md px-3 text-xs", lg: "h-10 rounded-md px-8", icon: "h-9 w-9", }, rounded: { default: "rounded-md", sm: "rounded-sm", lg: "rounded-lg", xl: "rounded-xl", "2xl": "rounded-2xl", full: "rounded-full", }, }, defaultVariants: { variant: "default", size: "default", }, } ); export interface ButtonProps extends React.ButtonHTMLAttributes, VariantProps { asChild?: boolean; } const Button = React.forwardRef( ({ className, variant, size, asChild = false, ...props }, ref) => { const Comp = asChild ? Slot : "button"; return ( ); } ); Button.displayName = "Button"; export { Button, buttonVariants }; ================================================ FILE: src/components/ui/card.tsx ================================================ import * as React from "react"; import { cn } from "@/lib/utils"; const Card = React.forwardRef< HTMLDivElement, React.HTMLAttributes >(({ className, ...props }, ref) => (
)); Card.displayName = "Card"; const CardHeader = React.forwardRef< HTMLDivElement, React.HTMLAttributes >(({ className, ...props }, ref) => (
)); CardHeader.displayName = "CardHeader"; const CardTitle = React.forwardRef< HTMLParagraphElement, React.HTMLAttributes >(({ className, ...props }, ref) => (

)); CardTitle.displayName = "CardTitle"; const CardDescription = React.forwardRef< HTMLParagraphElement, React.HTMLAttributes >(({ className, ...props }, ref) => (

)); CardDescription.displayName = "CardDescription"; const CardContent = React.forwardRef< HTMLDivElement, React.HTMLAttributes >(({ className, ...props }, ref) => (

)); CardContent.displayName = "CardContent"; const CardFooter = React.forwardRef< HTMLDivElement, React.HTMLAttributes >(({ className, ...props }, ref) => (
)); CardFooter.displayName = "CardFooter"; export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent, }; ================================================ FILE: src/components/ui/dropdown-menu.tsx ================================================ "use client"; import * as React from "react"; import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; import { CheckIcon, ChevronRightIcon, DotFilledIcon, } from "@radix-ui/react-icons"; import { cn } from "@/lib/utils"; const DropdownMenu = DropdownMenuPrimitive.Root; const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger; const DropdownMenuGroup = DropdownMenuPrimitive.Group; const DropdownMenuPortal = DropdownMenuPrimitive.Portal; const DropdownMenuSub = DropdownMenuPrimitive.Sub; const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup; const DropdownMenuSubTrigger = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { inset?: boolean; } >(({ className, inset, children, ...props }, ref) => ( {children} )); DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName; const DropdownMenuSubContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName; const DropdownMenuContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, sideOffset = 4, ...props }, ref) => ( )); DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName; const DropdownMenuItem = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { inset?: boolean; } >(({ className, inset, ...props }, ref) => ( )); DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName; const DropdownMenuCheckboxItem = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, children, checked, ...props }, ref) => ( {children} )); DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName; const DropdownMenuRadioItem = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, children, ...props }, ref) => ( {children} )); DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName; const DropdownMenuLabel = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { inset?: boolean; } >(({ className, inset, ...props }, ref) => ( )); DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName; const DropdownMenuSeparator = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName; const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes) => { return ( ); }; DropdownMenuShortcut.displayName = "DropdownMenuShortcut"; export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuGroup, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuRadioGroup, }; ================================================ FILE: src/components/ui/hover-card.tsx ================================================ "use client"; import * as React from "react"; import * as HoverCardPrimitive from "@radix-ui/react-hover-card"; import { cn } from "@/lib/utils"; const HoverCard = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ ...props }, ref) => ( )); HoverCard.displayName = HoverCardPrimitive.Root.displayName; const HoverCardTrigger = HoverCardPrimitive.Trigger; const HoverCardContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, align = "center", sideOffset = 4, ...props }, ref) => ( )); HoverCardContent.displayName = HoverCardPrimitive.Content.displayName; export { HoverCard, HoverCardTrigger, HoverCardContent }; ================================================ FILE: src/components/ui/input.tsx ================================================ import * as React from "react"; import { cn } from "@/lib/utils"; export interface InputProps extends React.InputHTMLAttributes {} const Input = React.forwardRef( ({ className, type, ...props }, ref) => { return ( ); }, ); Input.displayName = "Input"; export { Input }; ================================================ FILE: src/components/ui/label.tsx ================================================ "use client"; import * as React from "react"; import * as LabelPrimitive from "@radix-ui/react-label"; import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "@/lib/utils"; const labelVariants = cva( "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", ); const Label = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & VariantProps >(({ className, ...props }, ref) => ( )); Label.displayName = LabelPrimitive.Root.displayName; export { Label }; ================================================ FILE: src/components/ui/select.tsx ================================================ "use client"; import * as React from "react"; import { CaretSortIcon, CheckIcon, ChevronDownIcon, ChevronUpIcon, } from "@radix-ui/react-icons"; import * as SelectPrimitive from "@radix-ui/react-select"; import { cn } from "@/lib/utils"; const Select = SelectPrimitive.Root; const SelectGroup = SelectPrimitive.Group; const SelectValue = SelectPrimitive.Value; const SelectTrigger = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, children, ...props }, ref) => ( span]:line-clamp-1", className, )} {...props} > {children} )); SelectTrigger.displayName = SelectPrimitive.Trigger.displayName; const SelectScrollUpButton = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName; const SelectScrollDownButton = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName; const SelectContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, children, position = "popper", ...props }, ref) => ( {children} )); SelectContent.displayName = SelectPrimitive.Content.displayName; const SelectLabel = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); SelectLabel.displayName = SelectPrimitive.Label.displayName; const SelectItem = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, children, ...props }, ref) => ( {children} )); SelectItem.displayName = SelectPrimitive.Item.displayName; const SelectSeparator = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); SelectSeparator.displayName = SelectPrimitive.Separator.displayName; export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, }; ================================================ FILE: src/components/ui/separator.tsx ================================================ "use client"; import * as React from "react"; import * as SeparatorPrimitive from "@radix-ui/react-separator"; import { cn } from "@/lib/utils"; const Separator = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >( ( { className, orientation = "horizontal", decorative = true, ...props }, ref, ) => ( ), ); Separator.displayName = SeparatorPrimitive.Root.displayName; export { Separator }; ================================================ FILE: src/components/ui/skeleton.tsx ================================================ import { cn } from "@/lib/utils"; function Skeleton({ className, ...props }: React.HTMLAttributes) { return (
); } export { Skeleton }; ================================================ FILE: src/components/ui/switch.tsx ================================================ "use client"; import * as React from "react"; import * as SwitchPrimitives from "@radix-ui/react-switch"; import { cn } from "@/lib/utils"; const Switch = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); Switch.displayName = SwitchPrimitives.Root.displayName; export { Switch }; ================================================ FILE: src/components/ui/tabs.tsx ================================================ "use client"; import * as React from "react"; import * as TabsPrimitive from "@radix-ui/react-tabs"; import { cn } from "@/lib/utils"; const Tabs = TabsPrimitive.Root; const TabsList = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); TabsList.displayName = TabsPrimitive.List.displayName; const TabsTrigger = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); TabsTrigger.displayName = TabsPrimitive.Trigger.displayName; const TabsContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( )); TabsContent.displayName = TabsPrimitive.Content.displayName; export { Tabs, TabsList, TabsTrigger, TabsContent }; ================================================ FILE: src/components/ui/textarea.tsx ================================================ import * as React from "react"; import { cn } from "@/lib/utils"; export interface TextareaProps extends React.TextareaHTMLAttributes {} const Textarea = React.forwardRef( ({ className, ...props }, ref) => { return (