Getting started
Perplexica is a modern AI chat application with advanced search capabilities. Before contributing, familiarize yourself with:- Architecture: Component-level overview
- How it works: High-level flow
- The codebase structure (explained below)
Project structure
Perplexica’s codebase is organized into clear, logical sections:Frontend (UI)
Components and pages
Components and pages
- Components (
src/components): Reusable UI components - Pages and routes (
src/app): Next.js app directory structure- Home (
/) - Chat (
/c) - Discover (
/discover) - Library (
/library)
- Home (
- API routes (
src/app/api): Server endpoints using Next.js route handlers
Backend (Core logic)
Backend functionality
Backend functionality
Located in
src/lib/, this contains all backend functionality:- Search system (
src/lib/agents/search): Core chat and search pipeline - Database (
src/lib/db): Database functionality and schema - Models (
src/lib/models):- Providers in
src/lib/models/providers - Registry in
src/lib/models/registry.ts
- Providers in
- Prompts (
src/lib/prompts): Prompt templates - SearXNG (
src/lib/searxng.ts): Search backend integration - Uploads (
src/lib/uploads): File upload and semantic search
Search pipeline
The search system is split into four key phases:Classification
src/lib/agents/search/classifier.ts - Decides whether research is needed and what should runWhere to make changes
Use this section as a map for common contribution types:Search behavior and reasoning
Core search pipeline
Location:
src/lib/agents/search- Classifier (
classifier.ts): Modify how questions are analyzed - Researcher (
researcher/): Change how information is gathered - Main flow (
index.ts): Adjust overall orchestration
Add or change search capabilities
Research tools
Location:
src/lib/agents/search/researcher/actionsAvailable tools:webSearch.ts- General web resultsacademicSearch.ts- Scholarly paperssocialSearch.ts- Discussion forumsuploadsSearch.ts- User file searchscrapeURL.ts- Direct URL scraping
- Create a new file in
actions/(e.g.,newsSearch.ts) - Implement the tool interface
- Register it in
actions/index.ts
Add or change widgets
Widget system
Location:
src/lib/agents/search/widgetsExisting widgets:weatherWidget.ts- Weather forecastsstockWidget.ts- Stock pricescalculationWidget.ts- Math expressions
- Create a file (e.g.,
newsWidget.ts) - Implement the widget interface
- Add classification logic in
classifier.ts - Register in
widgets/index.ts
Model integrations
AI providers
Location:
src/lib/models/providersAdd new AI providers:- Create a provider file (e.g.,
groq.ts) - Implement the provider interface
- Wire into
src/lib/models/registry.ts - Provider will appear in the setup UI
UI components
Interface changes
Location:
src/componentsModify or add UI components:- Chat interface
- Widget displays
- Settings panels
- Citation rendering
API endpoints
API routes
Location:
src/app/apiKey endpoints:chat/route.ts- Main chat APIsearch/route.ts- Programmatic searchimages/route.ts- Image searchvideos/route.ts- Video searchproviders/route.ts- Provider management
Setting up your environment
Before diving into coding, set up your local development environment:Start development server
Complete setup
Open http://localhost:3000 and complete the setup in the UI:
- Add API keys for your chosen providers
- Select models
- Configure search backend URL (SearXNG)
- Enable desired sources
For Docker-based development, see the installation guide in the repository README. Docker is recommended for production, while
npm run dev is used for development.Coding practices
Follow these guidelines to maintain code quality and consistency:Before committing
Test your changes
Ensure your code functions correctly through thorough testing:
- Test in the UI
- Test API endpoints
- Verify database changes
Format your code
Always run the formatter before committing:This maintains consistency and code quality across the project.
Code style
- TypeScript: Use strict typing, avoid
any - Naming: Use descriptive variable and function names
- Comments: Explain the “why”, not the “what”
- Error handling: Always handle errors gracefully
- Async/await: Prefer over
.then()chains
Testing
While Perplexica doesn’t currently have automated tests:- Manually test your changes thoroughly
- Test different AI providers
- Test with and without search enabled
- Check edge cases (empty queries, long responses, etc.)
Contribution workflow
Create a branch
Create a feature branch for your changes:Use descriptive branch names like:
feature/add-news-searchfix/citation-renderingdocs/update-api-guide
API documentation
If you’re modifying APIs, update the API documentation:- Search API: See
docs/API/SEARCH.mdin the source repository - Document new endpoints or parameters
- Include request/response examples
Architecture documentation
If you’re making significant architectural changes:- Update
docs/architecture/README.mdfor component changes - Update
docs/architecture/WORKING.mdfor workflow changes - Keep documentation in sync with code
Community guidelines
While Perplexica doesn’t yet have a formal code of conduct:- Be respectful and professional
- Provide constructive feedback
- Help other contributors
- Report bugs clearly with reproduction steps
- Discuss significant changes before implementing
Getting help
Discord Community
Join the Discord server for real-time help and discussions
GitHub Issues
Report bugs or request features on GitHub
Recognition
Contributors are recognized in:- GitHub contributors page
- Project README
- Release notes for significant contributions
Next steps
Architecture
Understand the component-level architecture
How it works
Learn the high-level flow of answering questions