# Repository Briefing: 666ghj/BettaFish
> Source: https://repoforai.com/repo/666ghj/BettaFish (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/666ghj/BettaFish
- **Official Docs / Website**: https://deepwiki.com/666ghj/BettaFish
- **Category**: Agents & Frameworks (智能体与框架)
- **Primary Language**: Python
- **License**: GPL-2.0
- **Engineering Health**: B+ (73/100 · Maintenance 26/35 · Adoption 25/25 · Releases 11/20 · License 11/20)
- **Latest Release**: v3.0.0 (2025-12-23) — https://github.com/666ghj/BettaFish/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: Docker, Self-Hosted, API
- **Momentum**: 42,839 ★ total (+3 24h / +59 7d) · 7,642 forks
- **Topics**: `agent-framework`, `data-analysis`, `deep-research`, `deep-search`, `llms`, `multi-agent-system`, `nlp`, `public-opinion-analysis`, `python3`, `sentiment-analysis`
- **When to Use**: Best for: Research and teaching teams that want to combine authorized social or internal datasets with web and media evidence and generate reusable reports from natural-language questions. Skip if: You need turnkey continuous monitoring, guaranteed platform coverage, an entirely offline workflow without replacing external dependencies, or clear commercial-use terms without legal review.

## Overview
```text
### Architecture & Core Mechanics
BettaFish is a modular Python application for public-opinion research, not a general-purpose agent SDK. The Flask entrypoint in app.py starts QueryEngine, MediaEngine, and InsightEngine in parallel for web search, multimodal research, and analysis of database-backed opinion data. After an initial sweep, each agent plans follow-up research. ForumEngine uses an LLM moderator to synthesize agent discussion and steer later rounds; ReportEngine consumes both the findings and the discussion to assemble a structured document intermediate representation (IR).

The runtime includes Flask 2.3.3 and Flask-SocketIO 5.3.6, with Streamlit 1.28.1 for standalone engine interfaces. Engine directories separate orchestration, nodes, tools, state, and prompts. Models are invoked through OpenAI-compatible clients, while provider and domain customization happens through per-engine settings, Python tools, and prompts. InsightEngine's async SQLAlchemy read-only wrappers provide a concrete starting point for database integrations; a new business schema still needs its own queries and access policy.

### Key Capabilities & Differentiators
QueryEngine handles broad web and news research; MediaEngine handles images, short videos, and structured search cards; InsightEngine retrieves topics and comments and can apply sentiment analysis. Available sentiment implementations include multilingual, small fine-tuned Qwen3, Chinese BERT LoRA, GPT-2 LoRA, and traditional options such as SVM. The sample settings show where to bound work: Query allows two reflection rounds and 15 search results, while Insight caps the number of search results passed to the LLM at 50. These are configuration examples, not throughput or quality guarantees.

ReportEngine can select a built-in template or use a custom Markdown or text template, check output in sections, and render interactive HTML from Document IR. Markdown and optional PDF are also supported. The report_engine_only.py command can regenerate a synthesis from existing engine reports without rerunning research; separate re-render scripts rebuild HTML or Markdown from saved chapter JSON and export PDF from a saved IR. When selecting the latest files per engine for a report-only run, verify that they belong to the same topic and time window.

### Trade-offs & Limitations
Compared with a web-only deep-research agent, BettaFish offers a path from database and media evidence to reusable report artifacts without building the entire pipeline yourself. The additional research rounds, moderator calls, and synthesis stages can increase elapsed time and API spend, and multiple agents do not make shared sources independent or summaries automatically reliable. Compared with a managed social-listening service, you gain control over models, queries, and templates but take on source maintenance, credentials, provider limits, and validation of actual coverage. The Flask workflow does not start MindSpider for you.

A practical pilot should test source freshness, trace material conclusions back to evidence, and measure cost per completed report using representative queries. Self-hosted storage can coexist with externally processed prompts, so map data flows before using private records. The repository identifies GPL-2.0, while its disclaimer separately prohibits commercial or for-profit use. Those terms are in tension and warrant legal review before commercial rollout; crawler use also requires a separate check of site terms, robots.txt, and data rights.

### Hardware & Deployment Guide
For self-hosting, copy .env.example to .env, configure the required model and search credentials, set DB_HOST=db and DB_PORT=5432 for the Compose database, and run docker compose up -d. The stack uses ghcr.io/666ghj/bettafish:latest and PostgreSQL 15. Flask listens on port 5000, and Compose also publishes Streamlit ports 8501–8503; restrict exposure to the interfaces users actually need. Bind mounts retain logs, final reports, and per-engine reports. For repeatable deployments, pin the tested image by digest rather than relying on the floating latest tag.

Source installs support Python 3.9+, with Python 3.11 shown in the environment setup. Install requirements.txt and start python app.py; add Playwright Chromium for crawling and WeasyPrint system dependencies if PDF output is needed. PostgreSQL is recommended and MySQL is configurable. Start with the 2 GB-plus memory recommendation, then size for concurrent runs, browser processes, and any local models. Self-hosting does not imply offline operation: check where model requests go and which search paths require network access. Release v2.0.0 rebuilt reporting, v2.1.0 added KMeans-based representative sampling in Insight, and v3.0.0 points to MiroFish as a separate downstream forecasting project.
```

## Key Capabilities
```text
- Research lanes: Query, Media, and Insight run in parallel; ForumEngine feeds moderator guidance back into subsequent research rounds.
- Model configuration: Each engine can use a separately configured OpenAI-compatible endpoint through its API key, base URL, and model name.
- Database retrieval: InsightEngine uses async SQLAlchemy read-only wrappers, with example caps of 500 comments per fetch and 50 search results passed to the LLM.
- Report generation: A shared Document IR drives interactive HTML, Markdown, and optional PDF output, with scripts to re-render saved artifacts.
- Collection boundary: MindSpider runs separately from the Flask analysis app; browser-based source installs use Playwright Chromium.
- Operational entrypoints: Docker Compose pairs the application with PostgreSQL 15; three individual engines also have Streamlit entrypoints.
```

## Quick Start / Clone
```bash
docker compose up -d
```
