# atineiatte/deep-research-at-home architecture

> Architecture diagram of the GitHub repository atineiatte/deep-research-at-home, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atineiatte/deep-research-at-home
- Repository: https://github.com/atineiatte/deep-research-at-home

## Overview

##### Project type and purpose
- Type: A command-line AI research pipeline.
- Purpose:
– Accept a user query, generate starter searches.
– Build and iteratively refine a research outline based on user feedback.
– Perform iterative search cycles, synthesize results with an LLM (Gemma3-12b).
– Compose a multi-section research report with citations.
– Save final output to a text file.

##### File structure
Top-level entries:
– LICENSE
– README.md (project description, usage, architecture notes)
– gemma3-12b-prompt (prompt templates for LLM synthesis)
– granite30m mit 10k.gz (local model checkpoint or embeddings)
– pipe (core controller script)
– why (helper or config script)
Patterns & architectural hints:
– “pipe” and “why” suggest a modular pipeline.
– A standalone CLI tool with no explicit frontend/backend split.
– External dependencies implied: Python, LLM weights, search engine credentials.

##### Extract architecture insights from the README
– Iterative controller that tracks cycles, topic completion, repetition management.
– Modules for: starter-search generation, outline drafting & revision, synthesis, compression, per-section editing, final assembly.
– Integrations: SearXNG search API, archive.org fallback, Gemma3-12b for synthesis.
– Output: Text file in user’s home.

1. CLI Interface
– Reads user query & feedback.
2. Prompt Manager
– Loads templates (gemma3-12b-prompt).
3. Search Adapter
– Issues HTTP requests to SearXNG or archive.org.
– Applies delays, headers, retries.
4. Manager
– Drafts initial outline, applies user revisions.
5. Iterative Research Controller
– Tracks MAX_CYCLES, result windows, relevance penalties.
– Orchestrates search → synthesis loops.
6. Model Inference Engine
– Invokes Gemma3-12b (via local weights granite30m mit 10k.gz).
– Performs semantic compression & section synthesis.
7. Citation & Results Manager
– Collects, verifies, deduplicates sources.
8. Report Composer
– Assembles per-section outputs into final report (abstract, sections, conclusion).
9. Storage Module
– Writes final text file (`~/research_export_…txt`).

##### Relationships & data flow
- User Query → CLI → Prompt Manager
- Prompt → Search Adapter → Search Results
- Results → Outline Manager → User Feedback loop
- Revised Outline + Results → Iterative Controller → Model Engine
- Model Outputs → Citation Manager → Report Composer
- Final Report → Storage → User

##### Architectural patterns & design principles
– Pipeline Architecture: distinct stages connected in sequence.
– Modular Separation of Concerns: each component (search, outline, synthesis) is self-contained.
– Feedback Loop: user feedback integrated into outline manager, driving iteration.
– Data Flow Emphasis: clear flow from input through transformation to output.
– Configurable Parameters: MAX_CYCLES, token limits, compression settings.

##### Technologies & dependencies
– Language: Python (implied by .py or scripts).
– LLM: Gemma3-12b model weights (local).
– Search API: SearXNG, archive.org fallback.
– Prompt templates: plain-text files.
– Storage: local file system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User-facing Layer
    subgraph "User-facing" 
        direction TB
        CLI["CLI Interface"]:::user
    end

    %% Core Pipeline Layer
    subgraph "Core Pipeline" 
        direction TB
        PM["Prompt Manager"]:::core
        SA["Search Adapter"]:::core
        OM["Outline Manager"]:::core
        IC["Iterative Research Controller"]:::core
        ME["Model Inference Engine"]:::core
        CM["Citation & Results Manager"]:::core
        RC["Report Composer"]:::core
    end

    %% LLM Inference Group
    subgraph "LLM Inference" 
        direction TB
        PM
        ME
    end

    %% External Services Layer
    subgraph "External Services"
        direction TB
        SR["SearXNG Search API"]:::external
        AO["Archive.org (Fallback)"]:::external
    end

    %% Storage Layer
    subgraph "Storage / Files"
        direction TB
        ST["Storage Module\n(final report writer)"]:::storage
    end

    %% Data Flow
    CLI -->|"user query"| PM
    PM -->|"search prompt"| SA
    SA -->|"search results"| OM
    SA -.->|"fallback search"| AO
    OM -->|"initial outline"| CLI
    CLI -->|"outline revision"| OM
    OM -->|"revised outline + results"| IC
    IC -->|"invoke inference"| ME
    ME -->|"model output"| CM
    CM -->|"citations + sections"| RC
    RC -->|"assemble report"| ST
    IC -->|loop back| OM

    %% Click Events
    click CLI "https://github.com/atineiatte/deep-research-at-home/tree/main/pipe"
    click IC "https://github.com/atineiatte/deep-research-at-home/tree/main/pipe"
    click PM "https://github.com/atineiatte/deep-research-at-home/tree/main/gemma3-12b-prompt/"
    click ME "https://github.com/atineiatte/deep-research-at-home/blob/main/granite30m mit 10k.gz"
    click SA "https://github.com/atineiatte/deep-research-at-home/tree/main/why"
    click ST "https://github.com/atineiatte/deep-research-at-home/tree/main/pipe"

    %% Styles
    classDef user fill:#adebad,stroke:#333,stroke-width:1px
    classDef core fill:#9ec5fe,stroke:#333,stroke-width:1px
    classDef external fill:#feb2a8,stroke:#333,stroke-width:1px
    classDef storage fill:#d3d3d3,stroke:#333,stroke-width:1px
```
