# aianytime/multi-agents-system-from-scratch architecture

> Architecture diagram of the GitHub repository aianytime/multi-agents-system-from-scratch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aianytime/multi-agents-system-from-scratch
- Repository: https://github.com/aianytime/multi-agents-system-from-scratch

## Overview

This is a Streamlit multi-agent application for medical-text summarization, research-article drafting and refinement, and PHI sanitization, with task-specific quality validators. The user selects a task in the app; the app obtains agents from AgentManager, runs the task stages, and displays their outputs and validation. Agent implementations share an OpenAI-calling base class, and the app configures and uses logging. Workflow calls are visible in app.py; the manager’s registrations are documented in agents/__init__.py. Unsampled runtime behavior is not inferred.

Main entry points: [`app.py`](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/app.py) (Streamlit App), [`agents/__init__.py`](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/__init__.py) (Agent Manager), [`agents/agent_base.py`](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/agent_base.py) (Agent Base), [`agents/summarize_tool.py`](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/summarize_tool.py) (Summarizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_app["Streamlit App<br/>[app.py]"]
end

subgraph group_coordination["Agent Coordination"]
  node_manager["Agent Manager<br/>[__init__.py]"]
end

subgraph group_workflows["Task Agents"]
  node_summarize["Summarizer<br/>[summarize_tool.py]"]
  node_summarize_validator["Summary Validator"]
  node_writer["Article Writer"]
  node_refiner["Article Refiner<br/>[refiner_agent.py]"]
  node_article_validator["Article Validator<br/>[validator_agent.py]"]
  node_sanitize["PHI Sanitizer"]
  node_sanitize_validator["Sanitization Validator"]
end

subgraph group_foundation["Shared Services"]
  node_agent_base["Agent Base<br/>[agent_base.py]"]
  node_openai{{"OpenAI API"}}
  node_logger["Logger Configuration<br/>[logger.py]"]
end

node_user(("User"))

node_user -->|"selects task"| node_app
node_app -->|"creates and queries"| node_manager
node_manager -->|"registers"| node_summarize
node_manager -->|"registers"| node_summarize_validator
node_manager -->|"registers"| node_writer
node_manager -->|"registers"| node_refiner
node_manager -->|"registers"| node_article_validator
node_manager -->|"registers"| node_sanitize
node_manager -->|"registers"| node_sanitize_validator
node_app -->|"executes"| node_summarize
node_app -->|"validates summary"| node_summarize_validator
node_app -->|"executes"| node_writer
node_app -->|"refines draft"| node_refiner
node_app -->|"validates article"| node_article_validator
node_app -->|"executes"| node_sanitize
node_app -->|"validates data"| node_sanitize_validator
node_summarize -->|"calls inherited method"| node_agent_base
node_summarize_validator -->|"calls inherited method"| node_agent_base
node_writer -->|"calls inherited method"| node_agent_base
node_refiner -->|"calls inherited method"| node_agent_base
node_article_validator -->|"calls inherited method"| node_agent_base
node_sanitize -->|"calls inherited method"| node_agent_base
node_sanitize_validator -->|"calls inherited method"| node_agent_base
node_agent_base -->|"sends chat request"| node_openai
node_app -->|"configures and logs errors"| node_logger

click node_app "https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/app.py"
click node_manager "https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/__init__.py"
click node_summarize "https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/summarize_tool.py"
click node_summarize_validator "https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/summarize_validator_agent.py"
click node_writer "https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/write_article_tool.py"
click node_refiner "https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/refiner_agent.py"
click node_article_validator "https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/validator_agent.py"
click node_sanitize "https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/sanitize_data_tool.py"
click node_sanitize_validator "https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/sanitize_data_validator_agent.py"
click node_agent_base "https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/agent_base.py"
click node_logger "https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/utils/logger.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_app,node_user toneBlue
class node_manager toneAmber
class node_summarize,node_summarize_validator,node_writer,node_refiner,node_article_validator,node_sanitize,node_sanitize_validator toneMint
class node_agent_base,node_openai,node_logger toneRose
```

## Components

### User Interface

- [Streamlit App](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/app.py): `app.py`

### Agent Coordination

- [Agent Manager](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/__init__.py): `agents/__init__.py`

### Task Agents

- [Summarizer](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/summarize_tool.py): `agents/summarize_tool.py`
- [Summary Validator](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/summarize_validator_agent.py): `agents/summarize_validator_agent.py`
- [Article Writer](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/write_article_tool.py): `agents/write_article_tool.py`
- [Article Refiner](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/refiner_agent.py): `agents/refiner_agent.py`
- [Article Validator](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/validator_agent.py): `agents/validator_agent.py`
- [PHI Sanitizer](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/sanitize_data_tool.py): `agents/sanitize_data_tool.py`
- [Sanitization Validator](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/sanitize_data_validator_agent.py): `agents/sanitize_data_validator_agent.py`

### Shared Services

- [Agent Base](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/agents/agent_base.py): `agents/agent_base.py`
- **OpenAI API**
- [Logger Configuration](https://github.com/aianytime/multi-agents-system-from-scratch/blob/main/utils/logger.py): `utils/logger.py`

### Other components

- **User**

## Connections

- User → Streamlit App: selects task (evidence: `README.md`)
- Streamlit App → Agent Manager: creates and queries (evidence: `app.py`)
- Agent Manager → Summarizer: registers (evidence: `agents/__init__.py`)
- Agent Manager → Summary Validator: registers (evidence: `agents/__init__.py`)
- Agent Manager → Article Writer: registers (evidence: `agents/__init__.py`)
- Agent Manager → Article Refiner: registers (evidence: `agents/__init__.py`)
- Agent Manager → Article Validator: registers (evidence: `agents/__init__.py`)
- Agent Manager → PHI Sanitizer: registers (evidence: `agents/__init__.py`)
- Agent Manager → Sanitization Validator: registers (evidence: `agents/__init__.py`)
- Streamlit App → Summarizer: executes (evidence: `app.py`)
- Streamlit App → Summary Validator: validates summary (evidence: `app.py`)
- Streamlit App → Article Writer: executes (evidence: `app.py`)
- Streamlit App → Article Refiner: refines draft (evidence: `app.py`)
- Streamlit App → Article Validator: validates article (evidence: `app.py`)
- Streamlit App → PHI Sanitizer: executes (evidence: `app.py`)
- Streamlit App → Sanitization Validator: validates data (evidence: `app.py`)
- Summarizer → Agent Base: calls inherited method (evidence: `agents/summarize_tool.py`)
- Summary Validator → Agent Base: calls inherited method (evidence: `agents/summarize_validator_agent.py`)
- Article Writer → Agent Base: calls inherited method (evidence: `agents/write_article_tool.py`)
- Article Refiner → Agent Base: calls inherited method (evidence: `agents/refiner_agent.py`)
- Article Validator → Agent Base: calls inherited method (evidence: `agents/validator_agent.py`)
- PHI Sanitizer → Agent Base: calls inherited method (evidence: `agents/sanitize_data_tool.py`)
- Sanitization Validator → Agent Base: calls inherited method (evidence: `agents/sanitize_data_validator_agent.py`)
- Agent Base → OpenAI API: sends chat request (evidence: `agents/agent_base.py`)
- Streamlit App → Logger Configuration: configures and logs errors (evidence: `app.py`)
