# devgomesai/superior-agent architecture

> Architecture diagram of the GitHub repository devgomesai/superior-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devgomesai/superior-agent
- Repository: https://github.com/devgomesai/superior-agent

## Overview

##### Project type and purpose
- This is a full-stack, AI-powered stock analysis system built around a multi-agent orchestration pattern.
- Purpose: Accept a stock query (via CLI, HTTP API, or web form), dispatch it through a supervisor and three specialized agents, gather financial data and news, and finally generate a Markdown report (and optional HTML view).

##### File structure
- Top-level
- agent_flow.json – defines the orchestrator workflow
- pyproject.toml / requirements.txt – dependency and build metadata
- output/ – generated Markdown reports
- src/agent/
- api/api.py – FastAPI HTTP endpoints, request schema, routing
- agent.py – supervisor setup, multi-agent orchestration logic via LangGraph
- src/prompts/agent_prompts.py – system prompts for each agent
- src/templates/index.html – Jinja2 template for the web interface
- src/tools/stock_analysis_tools.py – helper functions for yfinance, Perplexity API, file I/O
- src/tests/ – interactive CLI runner (main.py) and unit tests (test.py)

##### README for additional insights
- Four logical components: Supervisor, Web Search Expert, Finance Analyst, Report Generator
- External dependencies: Perplexity API, yfinance, LLM providers via LangChain, FastAPI, Uvicorn
- Workflow visualization (graph.png) already generated via LangGraph

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Configuration"
        Metadata["Dependency & Build Metadata"]:::config
        Config["agent_flow.json"]:::config
    end

    subgraph "Client Layer"
        CLI["CLI Client"]:::client
        Browser["Browser UI (Web Form)"]:::client
        HTTPClient["HTTP Client (curl, etc.)"]:::client
    end

    subgraph "API / Web Server Layer"
        API["FastAPI + Uvicorn"]:::api
        Router["API Router & Pydantic Models"]:::api
    end

    subgraph "Orchestrator Layer"
        Supervisor["Supervisor Orchestrator"]:::orchestrator
    end

    subgraph "Agent Layer"
        Prompts["Agent Prompts"]:::prompts
        WebExpert["Web Search Expert Agent"]:::agent
        FinanceAgent["Finance Analyst Agent"]:::agent
        ReportGen["Report Generator Agent"]:::agent
    end

    subgraph "External Services"
        Perplexity["Perplexity API"]:::external
        YFinance["Yahoo Finance API"]:::external
        LLM["LLM Providers"]:::external
    end

    subgraph "Persistence Layer"
        Output["Markdown Reports (output/*.md)"]:::storage
    end

    %% Connections
    CLI -->|"HTTP POST /analyze"| API
    Browser -->|"HTTP POST /analyze"| API
    HTTPClient -->|"HTTP POST /analyze"| API

    API -->|"invoke orchestrator"| Supervisor
    API --> Router
    Router --> Supervisor

    Supervisor -->|"dispatch query"| WebExpert
    Supervisor -->|"dispatch query"| FinanceAgent

    WebExpert -->|"news & trends"| Supervisor
    FinanceAgent -->|"market data"| Supervisor

    Supervisor -->|"combined context"| ReportGen

    WebExpert --> Perplexity
    FinanceAgent --> YFinance
    WebExpert --> LLM
    FinanceAgent --> LLM
    ReportGen --> LLM

    ReportGen -->|"writes .md"| Output
    Output -->|"serve/download"| API

    Prompts --> WebExpert
    Prompts --> FinanceAgent
    Prompts --> ReportGen

    %% Click Events
    click Metadata "https://github.com/devgomesai/superior-agent/blob/main/pyproject.toml"
    click Config "https://github.com/devgomesai/superior-agent/blob/main/agent_flow.json"
    click API "https://github.com/devgomesai/superior-agent/blob/main/src/agent/api/api.py"
    click Supervisor "https://github.com/devgomesai/superior-agent/blob/main/src/agent/agent.py"
    click WebExpert "https://github.com/devgomesai/superior-agent/blob/main/src/prompts/agent_prompts.py"
    click FinanceAgent "https://github.com/devgomesai/superior-agent/blob/main/src/prompts/agent_prompts.py"
    click ReportGen "https://github.com/devgomesai/superior-agent/blob/main/src/tools/stock_analysis_tools.py"
    click CLI "https://github.com/devgomesai/superior-agent/blob/main/src/tests/main.py"
    click Browser "https://github.com/devgomesai/superior-agent/blob/main/src/templates/index.html"
    click Output "https://github.com/devgomesai/superior-agent/tree/main/output"

    %% Styles
    classDef client fill:#e0ffe0,stroke:#333,stroke-width:1px
    classDef api fill:#fff2cc,stroke:#333,stroke-width:1px
    classDef orchestrator fill:#d9ead3,stroke:#333,stroke-width:1px
    classDef agent fill:#cfe2f3,stroke:#333,stroke-width:1px
    classDef external fill:#d0e0e3,stroke:#333,stroke-width:1px
    classDef storage fill:#cccccc,stroke:#333,stroke-width:1px
    classDef config fill:#f4cccc,stroke:#333,stroke-width:1px
    classDef prompts fill:#f9cb9c,stroke:#333,stroke-width:1px
```
