How btahir/open-deep-research works
Main Components
• Frontend Interface:
• Next.js pages located in the “app” directory, including the main entry (app/page.tsx), layout (app/layout.tsx), and dedicated feature pages (such as app/flow/page.tsx and app/report/[id]/page.tsx).
• UI components stored in “components” (including components/ui, flows, analytics, etc.) which build the interactive elements and visualization (such as the visual research flow, report generation, and knowledge base).
• Backend/API Endpoints:
• API routes found in “app/api” (for actions like analyze-results, consolidate-report, download, fetch-content, generate-question, optimize-research, parse-document, report, search).
• These endpoints are responsible for handling requests from the UI, processing data, and interacting with external services.
• Business Logic & Utilities:
• Libraries in the “lib” folder (such as config, documents, file-upload, gemini, knowledge-base, redis, and utils) that abstract out the functionalities such as rate limiting, search provider configuration, file handling, and integration with external AI platforms.
• External/Third-Party Services:
• Search APIs (Google Custom Search & Bing Search) for fetching search results.
• AI platforms (Google Gemini, OpenAI, Anthropic, DeepSeek, OpenRouter, Ollama for local models) which are configured under “lib/config.ts”.
• Content extraction service (JinaAI) which processes retrieved webpages.
• Upstash Redis used for rate limiting.
• Local File and Knowledge Base Support:
• The system supports file uploads (TXT, PDF, DOCX) integrated via file-upload utilities and custom UI actions.
• Knowledge Base functionality to save and retrieve previously generated reports (with data stored in browser localStorage via “lib/localStorage-utils.ts” and related hooks).
Relationships and Interactions
• The Frontend interacts with the API endpoints via HTTP requests.
• The API layer encapsulates business logic and uses “lib” utilities to connect with external search and AI services.
• The results from searches, content extraction, and AI report generation are relayed back to the UI which dynamically renders research flows and report content.
• Additionally, the configuration file “lib/config.ts” ties together platform-specific settings (rate limits, API keys, and model configurations) that influence how the backend functions call external APIs.
Architectural Patterns & Design Principles
• Modular separation of concerns: The project cleanly divides UI components, API endpoints, and library/helpers.
• API-centric design: Modern REST-like endpoints using Next.js API routes to separate business logic from presentation.
• Integration-centric architecture: Multiple external services (search providers, AI platforms, rate limiting via Redis) are abstracted via configuration and thin API wrappers.
• Dynamic, recursive “flow” design to support deep research, where UI components like “question-node”, “report-node”, and “search-node” visually map out research progress.
Final Recommendations for the Principal Software Engineer
• Revisit key areas like the “Flow” component to ensure its recursive and dynamic nature is visually expressed.