Synthia: A blend of "synthesis" and "AI," Synthia is an AI-powered browser application designed to provide intelligent, user-friendly search and research capabilities. It synthesizes information from web searches, delivers AI-generated summaries, and organizes results into an intuitive interface. Synthia combines modern web technologies with a robust backend to offer a seamless experience for users seeking information on diverse topics.
- Project Overview
- Features
- Tech Stack
- Installation
- Usage
- Project Structure
- Environment Variables
- Contributing
- License
- Acknowledgments
- Contact
Synthia is a full-stack web application that leverages AI to enhance the search experience. It allows users to perform searches via text or audio input, offering two modes: Standard Search for quick results and Deep Research for in-depth analysis. Results include AI-generated summaries, images, and source links, all stored for future reference in a user’s library. The app features a discovery section for trending news, a credit system for usage limits, and secure authentication via Clerk.
Key objectives:
- Provide a seamless, AI-driven search experience.
- Support both guest and authenticated users.
- Organize search history and trending topics.
- Ensure a responsive, modern UI with dark/light mode support.
Synthia integrates Google Custom Search for web results, Gemini AI for summarization, Supabase for data storage, and Inngest for asynchronous processing, making it a robust tool for information retrieval and synthesis.
- Provider: Clerk for secure sign-in and sign-up.
- Routes:
/sign-in: Login page with Clerk’sSignIncomponent./sign-up: Registration page with Clerk’sSignUpcomponent.
- Guest Access: Non-authenticated users can perform one search; further actions require login.
- User Data: Upon sign-up/login, user details (name, email) are stored in Supabase’s
Userstable. - Middleware: Clerk’s middleware protects routes, allowing public access to
/,/sign-in,/sign-up, and API endpoints.
- Route:
/(root). - Input Options:
- Text Input: Users enter queries via a text field.
- Audio-to-Text: Converts voice input to text (implementation details in
ChatInputBox.jsx).
- Search Modes:
- Standard Search: Quick results using Google Custom Search API.
- Deep Research: Enhanced analysis with potentially broader result fetching or deeper AI processing.
- Credit Cost: Each search deducts 1 credit from the user’s balance.
- Output: Redirects to
/search/[libid]with a unique library ID (libid) for the search session.
- Route:
/search/[libid]. - Components:
- Header (
Header.jsx):- Displays search query, timestamp (via Moment.js), user avatar (Clerk’s
UserButton), and credit balance. - Includes a “Copy Link” button to share the results page URL.
- Displays search query, timestamp (via Moment.js), user avatar (Clerk’s
- Tabs (
DisplayResult.jsx):- Answer Tab: AI-generated summary (via Gemini AI) with markdown formatting (bold, headings, lists).
- Images Tab: Masonry grid of images from search results (
ImageTabList.jsx). - Sources Tab: List of source cards with titles, descriptions, URLs, favicons, and thumbnails (
SourceCard.jsx).
- Data Flow:
- Search results are fetched via
/api/search-apiand stored in Supabase’sChatstable. - AI summaries are generated asynchronously via
/api/llm-modeland Inngest, updated in real-time.
- Search results are fetched via
- UX: Loading skeletons (
skeleton.jsx) and error handling for smooth interaction.
- Header (
- Route:
/library. - Functionality:
- Displays a list of past searches/chats for the authenticated user.
- Each entry shows:
- Search query (
searchinput). - Type (
searchorresearch). - Creation date (formatted via Moment.js).
- Search query (
- Users can:
- Click to view details (redirects to
/search/[libid]). - Delete entries, removing associated data from
LibreryandChatstables.
- Click to view details (redirects to
- Data Source: Supabase (
Librerytable, joined withChats). - UI: Responsive list with hover effects and delete buttons (
Trash2icon from Lucide).
- Route:
/discover. - Functionality:
- Curated categories: Top, Technology, Finance, Art & Culture.
- Clicking a category triggers a search for “{category} Latest News & Updates” via Google Custom Search.
- Displays news cards with:
- Title, snippet, and source link.
- Optional thumbnail image.
- UI: Responsive grid layout, loading spinner (
Loader2from Lucide). - Navigation: Button to return to home for new searches.
- Implementation:
- Stored in Supabase’s
Userstable (creditscolumn). - Each search deducts 1 credit.
- Displayed in the header (
Header.jsx) with aCreditCardicon.
- Stored in Supabase’s
- Purchase Credits:
- Implemented via
CreditPopup.jsx(likely a modal or external payment gateway integration). - Users are prompted to buy credits if balance is low.
- Implemented via
- Validation: Checks credit balance before allowing searches.
- Component:
AppSidebar.jsx. - Features:
- Links to Home, Library, and Discover.
- Collapsible on mobile (via
use-mobile.jshook). - Includes Clerk’s
UserButtonfor profile management.
- Styling: Uses custom colors (
#e9fff6for sidebar,#2b5195for primary).
/api/search-api: Executes Google Custom Search queries, returns formatted results./api/llm-model: Sends search results and user input to Gemini AI for summarization, triggers Inngest job./api/inngest: Handles Inngest serverless functions for background tasks./api/get-inngest-status: Polls status of Inngest jobs to update AI responses.- Protection: Public routes defined in
middleware.js.
- Provider: Supabase (PostgreSQL).
- Tables:
- Users:
- Columns:
id,name,email,credits. - Stores user details and credit balance.
- Columns:
- Librery:
- Columns:
libid(UUID),searchinput,type(search/research),userEmail,created_at. - Tracks search sessions.
- Columns:
- Chats:
- Columns:
id,libid,searchResult(JSON),userSearchInput,aiResp(markdown). - Stores individual search results and AI responses.
- Columns:
- Users:
- Context:
UserDetailContext.jsxprovides real-time user data access.
- Breakpoints: Uses Tailwind CSS for mobile-first design.
- Mobile Detection:
use-mobile.jshook checks for screen width < 768px. - Features:
- Sidebar collapses on mobile.
- Masonry grid for images adjusts columns (2 on mobile, 4 on desktop).
- Responsive typography and padding.
- Frontend:
- Next.js: React framework for server-side rendering and API routes.
- Tailwind CSS: Utility-first CSS with custom colors (
#e9fff6,#f9faf5,#2b5195). - Shadcn UI: Accessible components (button, sidebar, tabs, etc.).
- Lucide React: Icons (e.g.,
Star,LibraryBig,CreditCard). - Radix UI: Headless UI primitives for accessibility.
- Backend:
- Next.js API Routes: Handle search and AI processing.
- Supabase: PostgreSQL database for user and search data.
- Inngest: Serverless functions for asynchronous AI tasks.
- Authentication: Clerk for user management.
- APIs:
- Google Custom Search: Web search results.
- Gemini AI: AI summarization (via
/api/llm-model).
- Other Libraries:
- Axios: HTTP requests.
- Moment.js: Date formatting.
- UUID: Generate unique IDs.
- clsx & tailwind-merge: Class name utilities.
- Fonts: Geist Sans and Geist Mono (via Next.js font optimization).
- Deployment: Vercel or similar (Next.js compatible).
- Node.js: v18 or higher.
- Accounts/Services:
- Clerk (authentication).
- Supabase (database).
- Google Custom Search (API key and CX ID).
- Gemini AI (API key).
- Inngest (signing key and server host).
-
Clone the Repository:
git clone https://github.com/sakshamagarwalm2/synthia.git cd synthia -
Install Dependencies:
npm install
-
Configure Environment Variables:
- Copy
.env.exampleto.env.local:cp .env.example .env.local
- Add the following keys in
.env.local:NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key CLERK_SECRET_KEY=your_clerk_secret_key NEXT_PUBLIC_SUPABASE_URL=your_supabase_url NEXT_PUBLIC_SUPABASE_KEY=your_supabase_key GOOGLE_SEARCH_API_KEY=your_google_api_key CX=your_google_cx_id GEMINI_API_KEY=your_gemini_api_key NEXT_PUBLIC_GEMINI_API_KEY=your_gemini_public_key INNGEST_SIGNING_KEY=your_inngest_signing_key INNGEST_SERVER_HOST=your_inngest_server_host
- Copy
-
Run the Development Server:
npm run dev
- Access at
http://localhost:3000.
- Access at
-
Build for Production:
npm run build npm run start
- Visit
http://localhost:3000(or deployed URL). - For first-time use, perform a guest search or sign up at
/sign-up. - Log in at
/sign-infor full access.
- On the home page (
/), enter a query via:- Text input in
ChatInputBox. - Audio-to-text (click the mic icon, if implemented).
- Text input in
- Select Search or Deep Research.
- View results at
/search/[libid]with tabs for Answer, Images, and Sources. - Share results using the “Copy Link” button.
- Navigate to
/library. - Browse past searches, click to view details, or delete unwanted entries.
- Each entry links to its results page (
/search/[libid]).
- Go to
/discover. - Select a category (Top, Technology, Finance, Art & Culture).
- Browse news cards; click to open sources in a new tab.
- Check credit balance in the header.
- If low, use the credit purchase feature (via
CreditPopup.jsx). - Each search deducts 1 credit.
sakshamagarwalm2-synthia/
├── README.md # Project documentation
├── components.json # Shadcn UI configuration
├── jsconfig.json # Path aliases (@/*)
├── middleware.js # Clerk authentication middleware
├── next-env.d.ts # TypeScript environment types
├── next.config.mjs # Next.js configuration
├── package.json # Dependencies and scripts
├── postcss.config.mjs # Tailwind/PostCSS configuration
├── tsconfig.json # TypeScript configuration
├── .env.example # Environment variable template
├── app/ # Next.js app router
│ ├── globals.css # Global Tailwind styles
│ ├── layout.js # Root layout with sidebar
│ ├── page.js # Home page with search input
│ ├── provider.jsx # User context provider
│ ├── (auth)/ # Authentication routes
│ │ ├── sign-in/[[...sign-in]]/page.jsx
│ │ └── sign-up/[[...sign-up]]/page.jsx
│ ├── (routes)/ # Protected routes
│ │ ├── discover/page.jsx # Trending news page
│ │ ├── library/page.jsx # Search history page
│ │ └── search/[libid]/ # Search results page
│ │ ├── page.jsx
│ │ └── _components/ # Results-specific components
│ │ ├── AnswerDisplay.jsx
│ │ ├── DisplayResult.jsx
│ │ ├── Header.jsx
│ │ ├── ImageTabList.jsx
│ │ ├── SourceCard.jsx
│ │ └── SourceList.jsx
│ ├── _components/ # Shared app components
│ │ ├── AppSidebar.jsx
│ │ └── ChatInputBox.jsx
│ └── api/ # API routes
│ ├── get-inngest-status/route.jsx
│ ├── inngest/route.js
│ ├── llm-model/route.js
│ └── search-api/route.jsx
├── components/ # Reusable UI components
│ └── ui/
│ ├── button.jsx
│ ├── CreditPopup.jsx
│ ├── dropdown-menu.jsx
│ ├── input.jsx
│ ├── separator.jsx
│ ├── sheet.jsx
│ ├── sidebar.jsx
│ ├── skeleton.jsx
│ ├── tabs.jsx
│ └── tooltip.jsx
├── context/ # React contexts
│ └── UserDetailContext.jsx
├── hooks/ # Custom React hooks
│ └── use-mobile.js
├── inngest/ # Inngest serverless functions
│ ├── client.js
│ └── functions.js
├── lib/ # Utility functions
│ └── utils.js
└── Services/ # External service integrations
├── Shared.jsx # Sample search result structure
└── supabase.jsx # Supabase client
Required variables (see .env.example):
- Clerk:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYCLERK_SECRET_KEYNEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-upNEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-inNEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL=/NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL=/
- Supabase:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_KEY
- Google Custom Search:
GOOGLE_SEARCH_API_KEYCX
- Gemini AI:
GEMINI_API_KEYNEXT_PUBLIC_GEMINI_API_KEY
- Inngest:
INNGEST_SIGNING_KEYINNGEST_SERVER_HOST
Store sensitive keys securely in production (e.g., Vercel environment variables).
- Fork the repository.
- Create a feature branch:
git checkout -b feature/your-feature
- Commit changes:
git commit -m "Add your feature" - Push to your fork:
git push origin feature/your-feature
- Open a Pull Request with a detailed description.
This project is licensed under the MIT License. See LICENSE for details.
- Inspiration: Tools like Perplexity AI and Google Search.
- Libraries: Next.js, Tailwind CSS, Clerk, Supabase, Inngest, Gemini AI.
- Community: Open-source contributors to Shadcn UI, Radix UI, and Lucide React.
For questions or feedback, contact [sakshamagarwalm2@gmail.com] or open an issue on GitHub.
