This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
bun dev- Start development server with Next.js Turbo mode (http://localhost:3000)bun run build- Create production buildbun start- Start production serverbun lint- Run ESLint for code quality checks and import sortingbun typecheck- Run TypeScript type checkingbun format- Format code with Prettierbun format:check- Check code formatting without modifying files
docker compose up -d- Run the application with Dockerdocker pull ghcr.io/miurla/morphic:latest- Pull prebuilt Docker image
- Next.js 15.2.3 with App Router and React Server Components
- React 19.0.0 with TypeScript for type safety
- Vercel AI SDK 4.3.6 for AI streaming and GenerativeUI
- Supabase for authentication and backend services
- Redis (Upstash or local) for chat history storage
- Tailwind CSS with shadcn/ui components
-
App Router Structure (
/app)/api/- Backend API routes for chat, search, and auth endpoints/auth/- Authentication pages (login, signup, password reset)/search/- Search functionality and results display/share/- Sharing functionality for search results
-
AI Integration (
/lib)/lib/agents/- AI agents for research and question generation/lib/config/- Model configuration management/lib/streaming/- Stream handling for AI responses/lib/tools/- Search and retrieval tool implementations- Models configured in
public/config/models.json
-
Search System
- Multiple providers: Tavily (default), SearXNG (self-hosted), Exa (neural)
- Video search support via Serper API
- URL-specific search capabilities
- Configurable search depth and result limits
-
Component Organization (
/components)/artifact/- Search result and AI response display components/sidebar/- Chat history and navigation/ui/- Reusable UI components from shadcn/ui- Feature-specific components (auth forms, chat interfaces)
-
State Management
- Server-side state via React Server Components
- Client-side hooks in
/hooks/ - Redis for persistent chat history
- Supabase for user data
OPENAI_API_KEY= # Default AI provider
TAVILY_API_KEY= # Default search provider- Chat history: Set
NEXT_PUBLIC_ENABLE_SAVE_CHAT_HISTORY=trueand configure Redis - Alternative AI providers: Add corresponding API keys (ANTHROPIC_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY, etc.)
- Alternative search: Configure SEARCH_API and provider-specific settings
- Sharing: Set
NEXT_PUBLIC_ENABLE_SHARE=true
- AI Streaming: Uses Vercel AI SDK's streaming capabilities for real-time responses
- GenerativeUI: Dynamic UI components generated based on AI responses
- Type Safety: Strict TypeScript configuration with comprehensive type definitions in
/lib/types/ - Schema Validation: Zod schemas in
/lib/schema/for data validation - Error Handling: Comprehensive error boundaries and fallback UI components
Currently no dedicated test framework. Verify changes by:
- Running
bun lintto check code quality - Building with
bun run buildto catch TypeScript errors - Manual testing in development mode
Before creating a pull request, you MUST ensure all of the following checks pass:
- Linting: Run
bun lintand fix all ESLint errors and warnings (includes import sorting) - Type checking: Run
bun typecheckto ensure no TypeScript errors - Formatting: Run
bun format:checkto verify code formatting (orbun formatto auto-fix) - Build: Run
bun run buildto ensure the application builds successfully
These checks are enforced in CI/CD and PRs will fail if any of these steps don't pass.
Note: Import sorting is handled by ESLint using eslint-plugin-simple-import-sort. Run bun lint --fix to automatically sort imports according to the configured order.
Models are defined in public/config/models.json with:
id: Model identifierprovider: Display nameproviderId: Provider key for API routingenabled: Toggle availabilitytoolCallType: "native" or "manual" for function callingtoolCallModel: Optional override for tool calls
When working with Supabase, follow the cursor rules in .cursor/rules/ for:
- Creating migrations
- Setting up RLS policies
- Writing edge functions
- SQL style guide