# aryanonit/model-doc-agent architecture

> Architecture diagram of the GitHub repository aryanonit/model-doc-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aryanonit/model-doc-agent
- Repository: https://github.com/aryanonit/model-doc-agent

## Overview

ModelDocAgent is a Google Chat bot that turns a GitHub repository link into architecture documentation and a diagram. A webhook is acknowledged immediately, then background processing fetches repository files, asks Gemini to produce structured content, renders a Mermaid diagram, and delivers results to Chat and Google Docs. The monolithic app.py implements the main runtime stages. The README documents several integrations and workflow links not visible in the sampled code; those documented relationships are cited to readme.md.

Main entry points: [`app.py`](https://github.com/aryanonit/model-doc-agent/blob/main/app.py) (Background worker), [`authorize_google.py`](https://github.com/aryanonit/model-doc-agent/blob/main/authorize_google.py) (OAuth authorization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request handling"]
  node_webhook["Flask webhook<br/>[app.py]"]
  node_worker["Background worker<br/>[app.py]"]
end

subgraph group_analysis["Repository analysis"]
  node_ingestor["Repository ingestor<br/>[app.py]"]
  node_orchestrator["Doc orchestrator<br/>[app.py]"]
end

subgraph group_outputs["Document generation"]
  node_diagram["Diagram renderer<br/>[app.py]"]
  node_docbuilder["Document builder<br/>[app.py]"]
  node_chat_delivery["Chat card delivery<br/>[app.py]"]
end

subgraph group_integrations["External services"]
  node_chat["Google Chat"]
  node_github["GitHub API"]
  node_gemini["Gemini"]
  node_mermaid["mermaid.ink"]
  node_google_docs["Google Docs"]
  node_service_account["Service account"]
  node_oauth["OAuth authorization"]
  node_drive["Google Drive"]
end

node_developer(("Developer"))

node_developer -->|"submits repository link"| node_chat
node_chat -->|"sends webhook"| node_webhook
node_webhook -->|"acknowledges"| node_chat
node_webhook -->|"starts"| node_worker
node_worker -->|"runs analysis"| node_orchestrator
node_orchestrator -->|"fetches repository"| node_ingestor
node_ingestor -->|"reads files"| node_github
node_orchestrator -->|"generates structured content"| node_gemini
node_orchestrator -->|"renders diagram"| node_diagram
node_diagram -->|"requests image"| node_mermaid
node_worker -->|"builds document"| node_docbuilder
node_docbuilder -->|"creates document"| node_google_docs
node_worker -->|"delivers results"| node_chat_delivery
node_chat_delivery -->|"sends card"| node_chat
node_chat_delivery -->|"authenticates with"| node_service_account
node_oauth -->|"authorizes document access"| node_google_docs
node_docbuilder -.->|"uploads optional logo"| node_drive

click node_webhook "https://github.com/aryanonit/model-doc-agent/blob/main/app.py"
click node_worker "https://github.com/aryanonit/model-doc-agent/blob/main/app.py"
click node_ingestor "https://github.com/aryanonit/model-doc-agent/blob/main/app.py"
click node_orchestrator "https://github.com/aryanonit/model-doc-agent/blob/main/app.py"
click node_diagram "https://github.com/aryanonit/model-doc-agent/blob/main/app.py"
click node_docbuilder "https://github.com/aryanonit/model-doc-agent/blob/main/app.py"
click node_chat_delivery "https://github.com/aryanonit/model-doc-agent/blob/main/app.py"
click node_oauth "https://github.com/aryanonit/model-doc-agent/blob/main/authorize_google.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_webhook,node_worker toneBlue
class node_ingestor,node_orchestrator toneAmber
class node_diagram,node_docbuilder,node_chat_delivery toneMint
class node_chat,node_github,node_gemini,node_mermaid,node_google_docs,node_service_account,node_oauth,node_drive toneRose
class node_developer toneIndigo
```

## Components

### Request handling

- [Flask webhook](https://github.com/aryanonit/model-doc-agent/blob/main/app.py): `app.py`
- [Background worker](https://github.com/aryanonit/model-doc-agent/blob/main/app.py): `app.py`

### Repository analysis

- [Repository ingestor](https://github.com/aryanonit/model-doc-agent/blob/main/app.py): `app.py`
- [Doc orchestrator](https://github.com/aryanonit/model-doc-agent/blob/main/app.py): `app.py`

### Document generation

- [Diagram renderer](https://github.com/aryanonit/model-doc-agent/blob/main/app.py): `app.py`
- [Document builder](https://github.com/aryanonit/model-doc-agent/blob/main/app.py): `app.py`
- [Chat card delivery](https://github.com/aryanonit/model-doc-agent/blob/main/app.py): `app.py`

### External services

- **Google Chat**
- **GitHub API**
- **Gemini**
- **mermaid.ink**
- **Google Docs**
- **Service account**
- [OAuth authorization](https://github.com/aryanonit/model-doc-agent/blob/main/authorize_google.py): `authorize_google.py`
- **Google Drive**

### Other components

- **Developer**

## Connections

- Developer → Google Chat: submits repository link (evidence: `readme.md`)
- Google Chat → Flask webhook: sends webhook (evidence: `readme.md`)
- Flask webhook → Google Chat: acknowledges (evidence: `readme.md`)
- Flask webhook → Background worker: starts (evidence: `readme.md`)
- Background worker → Doc orchestrator: runs analysis (evidence: `readme.md`)
- Doc orchestrator → Repository ingestor: fetches repository (evidence: `app.py`)
- Repository ingestor → GitHub API: reads files (evidence: `readme.md`)
- Doc orchestrator → Gemini: generates structured content (evidence: `readme.md`)
- Doc orchestrator → Diagram renderer: renders diagram (evidence: `app.py`)
- Diagram renderer → mermaid.ink: requests image (evidence: `readme.md`)
- Background worker → Document builder: builds document (evidence: `app.py`)
- Document builder → Google Docs: creates document (evidence: `readme.md`)
- Background worker → Chat card delivery: delivers results (evidence: `readme.md`)
- Chat card delivery → Google Chat: sends card (evidence: `readme.md`)
- Chat card delivery → Service account: authenticates with (evidence: `readme.md`)
- OAuth authorization → Google Docs: authorizes document access (evidence: `authorize_google.py`)
- Document builder → Google Drive: uploads optional logo (evidence: `app.py`)
