How hkustdial/deepear works
1. What this repo is
DeepEar is a two-part system: a Python research/workflow engine that turns news into investment logic chains, and a React dashboard that visualizes runs, signals, charts, and comparisons.
2. Primary execution entry points
The main offline/CLI workflow starts in src/main_flow.py. The web-facing runtime starts in dashboard/server.py, which serves the dashboard and exposes backend endpoints. There is also a skill-mode entry via skills/deepear/scripts/server.py.
3. Core workflow shape
The central pipeline is intentionally staged: user intent is interpreted first, then hot topics are discovered, then financial logic is validated, then forecasting is applied, and finally a report is generated. This is the main data flow an architecture diagram should show.
4. Agent layer
src/agents/ contains the specialized reasoning stages: intent_agent.py, trend_agent.py, fin_agent.py, forecast_agent.py, and report_agent.py. These agents are the main semantic boundary in the system; they consume structured inputs from prior stages and emit progressively more structured analysis.
5. Data acquisition and domain tooling
src/tools/ and src/utils/ provide the external-data and helper boundary around the agents. The repository explicitly supports news, stock, sentiment, and search tooling, plus hybrid retrieval (hybrid_search.py) and content extraction. These tools are the main bridge to live market/news sources.
6. Forecasting subsystem
Prediction is separate from pure LLM reasoning. src/utils/predictor/ and src/utils/kronos_predictor.py wrap a custom Kronos-based time-series model, with a prebuilt checkpoint in src/exports/models/. The forecast stage combines news-aware embeddings with time-series modeling rather than relying only on textual analysis.
7. Structured schemas and signal quality
src/schema/ defines the structured contract for analysis output, including ISQ templates and schema models. This matters because later stages depend on stable structured artifacts, not free-form text, to compare runs and render signals consistently.
8. Report generation and output artifacts
The reporting layer turns analysis into final deliverables such as Markdown/HTML reports and chart-rich summaries. Supporting utilities like md_to_html.py, visualizer.py, and scripts/inline_charts.py indicate that report rendering is a first-class output pipeline, not just a final text dump.
9. Dashboard subsystem
dashboard/frontend/ is a separate Vite + React + TypeScript app. It includes run monitoring, comparison views, signal cards, history panels, hot-news panels, chart modals, and an ISQ radar, which suggests the UI is optimized for observing workflow state and comparing multiple runs over time.
10. Dashboard backend and persistence
dashboard/db.py, dashboard/models.py, and dashboard/integration.py form the backend side of the UI. The dashboard likely persists users, runs, and related metadata in a local database, and useWebSocket.ts in the frontend shows that real-time status/log streaming is part of the design.
11. State management and reliability
The workflow engine uses checkpointing and resumability via src/utils/checkpointing.py, with shared logging and JSON helpers in src/utils/logging_setup.py and json_utils.py. This means long research runs are treated as resumable stateful jobs rather than one-shot requests.
12. Configuration boundaries
Runtime behavior is controlled by .env plus profile files in config/ such as default.json, macro.json, risk.json, and short_term.json. That implies the same pipeline can be tuned for different research styles or risk regimes without changing code.
13. Agent-skill packaging
skills/deepear/ wraps the system as a reusable agent skill. In architecture terms, this is an alternate interface layer that exposes the same backend workflow to external agent runtimes through a small skill server.
14. Automation and deployment
.github/workflows/lite-cron.yml and vercel.json show that the project has lightweight scheduled automation and a hosted dashboard deployment path. Those are supporting infrastructure, not core logic, but they matter if you are drawing the full system boundary.
Main entry points: main_flow.py Main flow · toolkits.py Toolkits · server.py Dashboard server · intent_agent.py Intent
Components 21
Core pipeline
Offline workflow engine and agent stages that turn news into structured investment analysis.
- Main flow · CLI/offline entry point that orchestrates the staged research pipeline.
src/main_flow.py - Intent · Interprets user intent and initializes the analysis path.
src/agents/intent_agent.py - Trends · Discovers hot topics and market-relevant trend signals.
src/agents/trend_agent.py - Finance · Validates financial logic and grounds the analysis in market context.
src/agents/fin_agent.py - Forecast · Combines structured signals with time-series prediction.
src/agents/forecast_agent.py - Report · Turns analysis into final narrative and structured deliverables.
src/agents/report_agent.py
Data and utilities
External-data access, extraction, checkpointing, schema, and forecasting support.
- Toolkits · Central registry or assembly point for agent-facing tools.
src/tools/toolkits.py - Market tools · News, stock, sentiment, and search interfaces that connect the pipeline to live sources.
src/utils/news_tools.py - Hybrid search · Blends retrieval across sources for relevant evidence gathering.
src/utils/hybrid_search.py - Extractor · Normalizes and extracts usable content from external sources.
src/utils/content_extractor.py - Schemas · Defines ISQ templates and model contracts for stable analysis artifacts.
src/schema/models.py - Checkpointing · Supports resumable long-running runs and persisted workflow state.
src/utils/checkpointing.py - Kronos · Wraps the custom time-series predictor used in the forecast stage.
src/utils/kronos_predictor.py - Model checkpoint · Prebuilt Kronos model weights used by the predictor stack.
src/exports/models/kronos_news_v1_20260101_0015.pt
Dashboard system
Web UI, backend, and persistence for run monitoring and comparison.
- Dashboard server · Serves the dashboard and exposes backend endpoints.
dashboard/server.py - Dashboard DB · Local database layer for users, runs, and related metadata.
dashboard/db.py - React UI · Vite + React + TypeScript frontend for monitoring, comparison, and reports.
dashboard/frontend/src/App.tsx - Live updates · WebSocket-driven run status and log streaming in the frontend.
dashboard/frontend/src/useWebSocket.ts
Packaging and ops
Skill wrapper, scheduled automation, and deployment glue.
- Skill server · Alternate entry point that exposes the workflow as a reusable agent skill.
skills/deepear/scripts/server.py - Lite cron · Scheduled workflow automation for lightweight recurring runs.
.github/workflows/lite-cron.yml - Deploy config · Hosted deployment configuration for the dashboard runtime.
vercel.json
Connections 22
- Main flow → Intent: starts with · Main workflow begins by interpreting intent.
- Intent → Trends: feeds · Intent output seeds topic discovery.
- Trends → Finance: feeds · Trend evidence is validated financially.
- Finance → Forecast: feeds · Structured financial signals inform forecasting.
- Forecast → Report: feeds · Prediction outputs are turned into the report.
- Main flow → Toolkits: uses · Workflow stages are assembled around shared tools.
- Toolkits → Market tools: includes · Tool assembly exposes market and news access.
- Toolkits → Hybrid search: includes · Retrieval support is part of the shared tool boundary.
- Toolkits → Extractor: includes · External content is extracted and normalized through tooling.
- Intent → Schemas: writes · Stages emit structured contracts rather than free text alone.
- Trends → Schemas: writes · Trend analysis is serialized into stable artifacts.
- Finance → Schemas: writes · Financial validation produces structured output.
- Forecast → Kronos: uses · Forecast stage invokes the time-series predictor.
- Kronos → Model checkpoint: loads · Predictor depends on the packaged model weights.
- Main flow → Checkpointing: persists · Long runs can be resumed from checkpoints.
- Report → Dashboard server: publishes · Final analysis is exposed to the web dashboard.
- Dashboard server → Dashboard DB: stores · Backend persists run and user metadata.
- Dashboard server → React UI: serves · Backend pairs with the interactive UI.
- React UI → Live updates: subscribes · UI receives live run progress and logs.
- Skill server → Main flow: wraps · Skill mode reuses the core workflow.
- Lite cron → Main flow: triggers · Scheduled automation invokes the workflow.
- Deploy config → Dashboard server: deploys · Deployment configuration targets the dashboard runtime.