# lordpba/ai_magi architecture

> Architecture diagram of the GitHub repository lordpba/ai_magi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lordpba/ai_magi
- Repository: https://github.com/lordpba/ai_magi

## Overview

MAGI is a Gradio-based multi-agent question-analysis application. A user submits a question and provider settings through the web interface; the interface streams logs and status while the core configures a model, creates three perspective agents and their tasks, runs a CrewAI crew, and returns its result. The README also documents a CLI entry point and optional local Ollama and search support. The graph focuses on the current `src` implementation; some interface-to-core details fall in omitted excerpts, so that link is documented by the source index and README workflow.

Main entry points: [`src/Main_core_002.py`](https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py) (Analysis Orchestrator), [`src/magi_web_interface.py`](https://github.com/lordpba/ai_magi/blob/main/src/magi_web_interface.py) (Query Streaming)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_web["Gradio Interface"]
  node_stream["Query Streaming"]
  node_result["Analysis Result<br/>[Main_core_002.py]"]
end

subgraph group_analysis["Analysis Core"]
  node_core["Analysis Orchestrator<br/>[Main_core_002.py]"]
  node_model_config["Model Setup<br/>[Main_core_002.py]"]
  node_agents["Perspective Agents<br/>[Main_core_002.py]"]
  node_tasks["Analysis Tasks<br/>[Main_core_002.py]"]
  node_crew["Crew Executor<br/>[Main_core_002.py]"]
end

subgraph group_integrations["External Services"]
  node_groq{{"Groq LLM"}}
  node_openai{{"OpenAI LLM"}}
  node_ollama{{"Ollama LLM"}}
  node_serper{{"Serper Search"}}
end

node_user(("Questioner"))

node_user -->|"submits question"| node_web
node_web -->|"routes analysis"| node_stream
node_stream -->|"runs analysis"| node_core
node_core -->|"configures model"| node_model_config
node_model_config -.->|"selects provider"| node_groq
node_model_config -.->|"selects provider"| node_openai
node_model_config -->|"configures model"| node_ollama
node_core -->|"creates agents"| node_agents
node_agents -.->|"uses search"| node_serper
node_core -->|"creates tasks"| node_tasks
node_core -->|"executes crew"| node_crew
node_crew -->|"returns analysis"| node_result
node_result -->|"formats output"| node_stream

click node_web "https://github.com/lordpba/ai_magi/blob/main/src/magi_web_interface.py"
click node_stream "https://github.com/lordpba/ai_magi/blob/main/src/magi_web_interface.py"
click node_core "https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py"
click node_model_config "https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py"
click node_agents "https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py"
click node_tasks "https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py"
click node_crew "https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py"
click node_result "https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_stream,node_result toneBlue
class node_core,node_model_config,node_agents,node_tasks,node_crew toneAmber
class node_groq,node_openai,node_ollama,node_serper toneMint
class node_user toneIndigo
```

## Components

### User Interface

- [Gradio Interface](https://github.com/lordpba/ai_magi/blob/main/src/magi_web_interface.py): `src/magi_web_interface.py`
- [Query Streaming](https://github.com/lordpba/ai_magi/blob/main/src/magi_web_interface.py): `src/magi_web_interface.py`
- [Analysis Result](https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py): `src/Main_core_002.py`

### Analysis Core

- [Analysis Orchestrator](https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py): `src/Main_core_002.py`
- [Model Setup](https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py): `src/Main_core_002.py`
- [Perspective Agents](https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py): `src/Main_core_002.py`
- [Analysis Tasks](https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py): `src/Main_core_002.py`
- [Crew Executor](https://github.com/lordpba/ai_magi/blob/main/src/Main_core_002.py): `src/Main_core_002.py`

### External Services

- **Groq LLM**
- **OpenAI LLM**
- **Ollama LLM**
- **Serper Search**

### Other components

- **Questioner**

## Connections

- Questioner → Gradio Interface: submits question (evidence: `README.md`)
- Gradio Interface → Query Streaming: routes analysis (evidence: `src/magi_web_interface.py`)
- Query Streaming → Analysis Orchestrator: runs analysis (evidence: `src/magi_web_interface.py`)
- Analysis Orchestrator → Model Setup: configures model (evidence: `src/Main_core_002.py`)
- Model Setup → Groq LLM: selects provider (evidence: `src/Main_core_002.py`)
- Model Setup → OpenAI LLM: selects provider (evidence: `src/Main_core_002.py`)
- Model Setup → Ollama LLM: configures model (evidence: `src/Main_core_002.py`)
- Analysis Orchestrator → Perspective Agents: creates agents (evidence: `src/Main_core_002.py`)
- Perspective Agents → Serper Search: uses search (evidence: `src/Main_core_002.py`)
- Analysis Orchestrator → Analysis Tasks: creates tasks (evidence: `src/Main_core_002.py`)
- Analysis Orchestrator → Crew Executor: executes crew (evidence: `src/Main_core_002.py`)
- Crew Executor → Analysis Result: returns analysis (evidence: `src/Main_core_002.py`)
- Analysis Result → Query Streaming: formats output (evidence: `src/magi_web_interface.py`)
