A production-ready, full-stack research assistant built with Next.js 14, TypeScript, and Tailwind CSS. This application leverages OpenAI's GPT models and Firecrawl's deep research capabilities to perform comprehensive web research on any topic.
- Deep Web Research: Automatically searches the web, extracts content, and synthesizes findings using Firecrawl
- AI-Powered Enhancement: Uses OpenAI GPT-4 to elaborate on research findings with additional context and insights
- Modern UI: Beautiful, responsive interface built with Tailwind CSS and React
- Type-Safe: Full TypeScript support for better developer experience
- Production Ready: Optimized for performance with Next.js App Router and Server Components
- Downloadable Reports: Export research findings as markdown files
- Secure API Key Management: Client-side API key storage with localStorage
- Dark Mode Support: Automatic dark mode based on system preferences
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- AI: OpenAI GPT-4 Turbo
- Web Scraping: Firecrawl Deep Research API
- Deployment Ready: Vercel, Netlify, or any Node.js hosting
- Node.js 18+ and npm/yarn/pnpm
- OpenAI API key (Get one here)
- Firecrawl API key (Get one here)
-
Clone the repository:
git clone <your-repo-url> cd ai-research-agent
-
Install dependencies:
npm install # or yarn install # or pnpm install
-
Set up environment variables (optional): Create a
.env.localfile in the root directory:OPENAI_API_KEY=your_openai_api_key_here FIRECRAWL_API_KEY=your_firecrawl_api_key_here
Note: API keys can also be configured directly in the UI. They are stored securely in your browser's localStorage.
-
Run the development server:
npm run dev # or yarn dev # or pnpm dev
-
Open your browser: Navigate to http://localhost:3000
-
Configure API Keys:
- Click on "API Configuration" in the sidebar
- Enter your OpenAI API key
- Enter your Firecrawl API key
- Keys are automatically saved to your browser's localStorage
-
Enter Research Topic:
- Type your research question or topic in the input field
- Examples:
- "Latest developments in quantum computing"
- "Impact of climate change on marine ecosystems"
- "Advancements in renewable energy storage"
-
Start Research:
- Click the "Start Research" button
- The application will:
- Use Firecrawl to perform deep web research
- Generate an initial research report
- Enhance the report with GPT-4 for additional insights
- Display the enhanced report
-
Download Report:
- Click "Download Report" to save the research as a markdown file
ai-research-agent/
βββ app/
β βββ api/
β β βββ research/
β β βββ route.ts # API endpoint for research
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ page.tsx # Main page component
βββ components/
β βββ ApiKeyConfig.tsx # API key configuration component
β βββ ResearchForm.tsx # Research input form
β βββ ResearchResults.tsx # Results display component
βββ public/ # Static assets
βββ .gitignore # Git ignore rules
βββ next.config.js # Next.js configuration
βββ package.json # Dependencies
βββ postcss.config.js # PostCSS configuration
βββ tailwind.config.ts # Tailwind CSS configuration
βββ tsconfig.json # TypeScript configuration
βββ README.md # This file
You can optionally set environment variables in .env.local:
OPENAI_API_KEY: Your OpenAI API keyFIRECRAWL_API_KEY: Your Firecrawl API keyNEXT_PUBLIC_APP_URL: Your application URL (for production)
The research parameters are configured in app/api/research/route.ts:
maxDepth: Maximum depth for web crawling (default: 3)timeLimit: Maximum time for research in seconds (default: 180)maxUrls: Maximum number of URLs to crawl (default: 10)
You can modify these values in the deepResearch function call.
- Push your code to GitHub
- Import your repository in Vercel
- Add environment variables in Vercel dashboard
- Deploy!
The application can be deployed to any platform that supports Next.js:
- Netlify: Use the Next.js build preset
- Railway: Connect your GitHub repo
- AWS Amplify: Configure for Next.js
- Docker: Use the included Dockerfile (if added)
Build command: npm run build
Start command: npm start
- API keys are stored in the browser's localStorage (client-side only)
- API keys are never exposed in the client-side code
- All API calls are made server-side through Next.js API routes
- Consider implementing user authentication for production use
- Use environment variables for server-side API keys in production
npm run type-checknpm run lintnpm run buildnpm startPerforms deep research on a given topic.
Request Body:
{
"topic": "Your research topic",
"openaiApiKey": "sk-...",
"firecrawlApiKey": "fc-..."
}Response:
{
"report": "Enhanced research report in markdown format"
}Error Response:
{
"error": "Error message"
}- Verify your API keys are correct
- Check your API key quotas and limits
- Ensure you have sufficient credits in your OpenAI and Firecrawl accounts
- Ensure Node.js version is 18 or higher
- Delete
node_modulesand.nextfolders, then reinstall dependencies - Check TypeScript errors with
npm run type-check
- Ensure you're using Next.js 14+ with App Router
- Check that the file structure matches the expected layout
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
- OpenAI for the GPT models
- Firecrawl for web scraping capabilities
- Next.js for the amazing framework
- Tailwind CSS for the styling framework
Built with β€οΈ using Next.js, TypeScript, and modern web technologies.