# theblewish/automated-ai-web-researcher-ollama architecture

> Architecture diagram of the GitHub repository theblewish/automated-ai-web-researcher-ollama, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/theblewish/automated-ai-web-researcher-ollama
- Repository: https://github.com/theblewish/automated-ai-web-researcher-ollama

## Overview

##### Project type and purpose
- This is a Python-based, command-line automated research assistant.
- It orchestrates structured web searches and scraping, drives a locally-hosted LLM (via Ollama), compiles findings into a text file, then produces a summary and Q&A session.

##### File structure
- Entry point:
– Web-LLM.py (main driver for research sessions)
– Self_Improving_Search.py (implements the iterative “self-improving” cycle)
- Orchestration & focus planning:
– research_manager.py (coordinates research loop, user commands)
– strategic_analysis_parser.py (breaks queries into prioritized focus areas)
- LLM integration:
– llm_wrapper.py (abstracts calls to Ollama’s HTTP API)
– llm_response_parser.py (parses the LLM’s JSON/text responses)
– llm_config.py (configures model name, server URL, temperature, context length)
- Data collection:
– web_scraper.py (performs DuckDuckGo searches, fetches and extracts HTML/text)
- Persistence & output:
– The code writes session logs and research content into timestamped text files in the working directory.
- Configuration & dependencies:
– requirements.txt; .gitignore, LICENSE, README.md

##### README for additional insights
- Workflow:
1. User issues “@” query in CLI.
2. LLM proposes N focus areas (via strategic_analysis_parser).
3. Loop over focus areas:
a. Formulate search queries
b. Call web_scraper to fetch content and URLs
c. Append results to research file
d. Generate new sub-focus areas (Self_Improving_Search)
4. On quit: aggregate all findings, call LLM for final summary, enter interactive Q&A.
- External dependencies: Ollama (local LLM), DuckDuckGo search API.
- Architecture pattern: modular, layered services—CLI → Orchestrator → Planner / Scraper / LLM → Data store.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers and Components
    subgraph "User Interface"
        User((User)):::external
        CLI["CLI Interface\n(Web-LLM.py)\ns, f, p, q"]:::core
    end

    subgraph "Core Modules"
        ORG["Orchestrator\nSession Manager\n(research_manager.py)"]:::core
        FP["Focus Planner\n(strategic_analysis_parser.py)"]:::core
        SE["Self-Improving Cycle Engine\n(Self_Improving_Search.py)"]:::core
        SCR["Web Scraper\n(web_scraper.py)"]:::core
    end

    subgraph "LLM Integration"
        LA["LLM Service Adapter\n(llm_wrapper.py)"]:::core
        LC["LLM Configuration\n(llm_config.py)"]:::core
        LP["LLM Response Parser\n(llm_response_parser.py)"]:::core
    end

    subgraph "External Services"
        OLM["Ollama API"]:::external
        DDG["DuckDuckGo Search API"]:::external
    end

    DS["Data Store\n(Text File Repository)"]:::datastore

    %% Data Flows
    User -->|issues “@” query| CLI
    CLI -->|start session| ORG
    ORG -->|plan focus| FP
    FP -->|prioritized areas| ORG
    ORG -->|start cycle| SE
    SE -->|new sub-focus| FP

    ORG -->|perform search| SCR
    SCR -->|HTTP request| DDG
    DDG -->|search results| SCR
    SCR -->|return content| ORG

    ORG -->|request completion| LA
    LA -->|HTTP request| OLM
    OLM -->|completion| LA
    LA -->|raw response| LP
    LP -->|parsed data| ORG

    ORG -->|append findings| DS

    %% Final summary & Q&A
    ORG -->|final summary request| LA
    LA -->|HTTP request| OLM
    OLM -->|summary| LA
    LA -->|parsed summary| LP
    LP -->|display| CLI

    %% Click Events
    click CLI "https://github.com/theblewish/automated-ai-web-researcher-ollama/blob/main/Web-LLM.py"
    click ORG "https://github.com/theblewish/automated-ai-web-researcher-ollama/blob/main/research_manager.py"
    click FP "https://github.com/theblewish/automated-ai-web-researcher-ollama/blob/main/strategic_analysis_parser.py"
    click SE "https://github.com/theblewish/automated-ai-web-researcher-ollama/blob/main/Self_Improving_Search.py"
    click SCR "https://github.com/theblewish/automated-ai-web-researcher-ollama/blob/main/web_scraper.py"
    click LA "https://github.com/theblewish/automated-ai-web-researcher-ollama/blob/main/llm_wrapper.py"
    click LC "https://github.com/theblewish/automated-ai-web-researcher-ollama/blob/main/llm_config.py"
    click LP "https://github.com/theblewish/automated-ai-web-researcher-ollama/blob/main/llm_response_parser.py"
    click DS "https://github.com/theblewish/automated-ai-web-researcher-ollama/blob/main/requirements.txt"
    click DS "https://github.com/theblewish/automated-ai-web-researcher-ollama/blob/main/README.md"
    click DS "https://github.com/theblewish/automated-ai-web-researcher-ollama/tree/main/LICENSE"
    click DS "https://github.com/theblewish/automated-ai-web-researcher-ollama/blob/main/.gitignore"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef external fill:#90EE90,stroke:#333,stroke-width:1px
    classDef datastore fill:#FFA500,stroke:#333,stroke-width:1px
```
