How filiksyos/ai-reddit-search works
Project Type and Purpose
• This is a full-stack, AI-powered search application built on Next.js 14 (App Router) with TypeScript and Tailwind CSS.
• It provides a user interface for entering natural language queries, enhances them via Google’s Gemini 2.0 Flash through OpenRouter, and then performs optimized Reddit searches, displaying the results in real time.
File Structure
• Top-level config and metadata:
• .env.local.example, next.config.js, package.json, pnpm-workspace.yaml, tsconfig.json
• src/app (Next.js App Router)
• /api/enhance-query/route.ts – serverless API route for AI query enhancement
• layout.tsx, page.tsx – root layout and home page component
• globals.css – global Tailwind styles
• src/components
• providers/theme-provider.tsx – UI context provider
• ui/{search-bar.tsx, filter-bar.tsx, post-card.tsx} – core presentational components
• src/hooks
• useRedditSearch.ts – custom hook using SWR for calling the Reddit API
• src/lib
• client-openrouter.ts – client-side wrapper for AI calls
• openrouter-api.ts – server-side AI service implementation
• reddit-api.ts – wrapper around Reddit’s OAuth-authenticated search
• types.ts and utils.ts – shared TypeScript types and helpers
Extract Key Architectural Insights from the README
• Emphasis on server-side AI calls (keeps API key hidden), client-side query throttling (debouncing), and SWR caching for performance.
Detail Without Over-Complication
• Every major component and interaction: UI, data fetching hooks, API routes, AI service, external API.