How jina-ai/node-deepresearch works
Main Components
• Core Processing Engine – Represent the iterative “deep research” loop that processes a user query through a chain: it gathers the question, generates a prompt, sends that to an LLM, then examines the type of action (answer, reflect, search, visit) and loops until a final answer is produced. This is best represented as a loop or flow that captures: Get Question → Generate Prompt → Model Generation → Action Check → (Answer/Reflect/Search/Visit) → Loop back OR termination.
• LLM Integration Module – Show the interface for external LLM providers (Gemini, OpenAI, or Local LLM services). Indicate that these modules are invoked to generate responses.
• External Search and Reading – Highlight that integration with the Jina Reader (or Jina API) supports the search and read steps for obtaining web content.
• From the Client Interfaces to the Core Processing Engine (requests coming from CLI or API calls).
• Interactions from various utility components (logging, error handling, configuration) being used by the core modules.
Architectural Patterns & Design Principles
• Iterative Workflow Pattern – Emphasize the cyclic process that continues until the token budget is exceeded or a “definitive” answer is reached.
• Separation of Concerns – The structure already divides responsibilities: the “src” directory deals with general application logic, and “jina-ai” encapsulates specialized functionalities (possibly microservice-like behavior for Jina-specific operations).
• Extensibility – Tools in the “src/tools” and “src/lib” directories indicate modular design. Note how new LLM integrations or search strategies could be added thanks to a well-defined interface.
Technologies, Frameworks, and Libraries
• Node.js runtime and Express (inferred from server.ts files) for the API server.
• Docker and Docker Compose for containerization and deployment.
• Testing frameworks such as Jest (noted by jest.config.js and __tests__ directories) for quality assurance.
• Integration with external APIs (OpenAI, Gemini, Jina Reader).
• Use of TypeScript (indicated by tsconfig.json files) which suggests a typed code base.
1. Entry points (CLI and API).
2. The iterative reasoning loop (with details for each step if space allows).
3. Connections to external LLM and search services.
4. Deployment context (noting Docker and configuration).
• Remember to incorporate any architectural elements that might be unique to deep research (for instance, the special handling of tokens like <think>...</think> in the response flow).