# donggwony/publicdata_ai_agent architecture

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

- Interactive diagram: https://gitdiagram.com/donggwony/publicdata_ai_agent
- Repository: https://github.com/donggwony/publicdata_ai_agent

## Overview

This repository is a Daegu commercial-district lifecycle analysis service, exposed through a Streamlit app and an AI agent. The main workflow is a visitor’s question entering the app, passing through the agent’s tool loop, and reaching analysis tools; a separate batch workflow prepares processed data for those tools. The graph also preserves documented analysis capabilities and the MCP entry point. Source excerpts are incomplete, so links to unsampled subsystems are included only where the README or SOURCE INDEX supports them.

Main entry points: [`service/core/tools.py`](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py) (Analysis Tools), [`service/pipeline/build.py`](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/pipeline/build.py) (Batch Builder), [`service/app.py`](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/app.py) (Streamlit App), [`service/agent.py`](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/agent.py) (Agent Loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_streamlit["Streamlit App<br/>[app.py]"]
  node_agent["Agent Loop<br/>[agent.py]"]
  node_gemini["Gemini Agent<br/>[agent_gemini.py]"]
  node_mcp["MCP Server<br/>[mcp_server.py]"]
  node_tool_specs["Tool Schemas<br/>[tool_specs.py]"]
  node_visuals["UI Visuals<br/>[ui_visuals.py]"]
end

subgraph group_analysis["Lifecycle Analysis"]
  node_tools["Analysis Tools<br/>[tools.py]"]
  node_address["Address Matching<br/>[address.py]"]
  node_cycle["Market Cycle<br/>[cycle.py]"]
  node_survival["Survival Analysis<br/>[survival.py]"]
  node_history["Store History<br/>[tools.py]"]
  node_vacancy["Vacancy Search<br/>[tools.py]"]
  node_area_compare["Area Comparison<br/>[tools.py]"]
  node_transitions["Industry Transitions<br/>[tools.py]"]
  node_risk["Risk Spots<br/>[tools.py]"]
end

subgraph group_data["Data Preparation"]
  node_build["Batch Builder<br/>[build.py]"]
  node_external_data["External Data Prep<br/>[external.py]"]
  node_config["Analysis Config<br/>[config.py]"]
  node_processed_data[("Processed Data")]
end

node_visitor(("Visitor"))
node_public_data(("Public Data Sources"))

node_visitor -->|"asks"| node_streamlit
node_streamlit -->|"creates agent"| node_agent
node_streamlit -->|"calls tools"| node_tools
node_streamlit -->|"renders with"| node_visuals
node_agent -->|"sends schemas"| node_tool_specs
node_agent -->|"dispatches tools"| node_tools
node_agent -->|"selects provider"| node_gemini
node_mcp -->|"exposes tools"| node_tools
node_mcp -->|"builds schemas"| node_tool_specs
node_tools -->|"normalizes addresses"| node_address
node_tools -->|"classifies cycle"| node_cycle
node_tools -->|"summarizes survival"| node_survival
node_tools -->|"provides history"| node_history
node_tools -->|"finds vacancies"| node_vacancy
node_tools -->|"compares areas"| node_area_compare
node_tools -->|"analyzes transitions"| node_transitions
node_tools -->|"finds risk spots"| node_risk
node_public_data -->|"provides CSVs"| node_build
node_build -->|"builds address keys"| node_address
node_build -->|"computes cycle"| node_cycle
node_build -->|"computes survival"| node_survival
node_build -->|"reads settings"| node_config
node_build -->|"writes tables"| node_processed_data
node_external_data -->|"reads settings"| node_config
node_public_data -.->|"supplies inputs"| node_external_data
node_tools -->|"reads tables"| node_processed_data

click node_streamlit "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/app.py"
click node_agent "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/agent.py"
click node_gemini "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/agent_gemini.py"
click node_mcp "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/mcp_server.py"
click node_tool_specs "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tool_specs.py"
click node_visuals "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/ui_visuals.py"
click node_tools "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py"
click node_address "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/address.py"
click node_cycle "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/cycle.py"
click node_survival "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/survival.py"
click node_history "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py"
click node_vacancy "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py"
click node_area_compare "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py"
click node_transitions "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py"
click node_risk "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py"
click node_build "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/pipeline/build.py"
click node_external_data "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/pipeline/external.py"
click node_config "https://github.com/donggwony/publicdata_ai_agent/blob/main/service/config.py"
click node_processed_data "https://github.com/donggwony/publicdata_ai_agent/tree/main/service/data/processed"

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_streamlit,node_agent,node_gemini,node_mcp,node_tool_specs,node_visuals toneBlue
class node_tools,node_address,node_cycle,node_survival,node_history,node_vacancy,node_area_compare,node_transitions,node_risk toneAmber
class node_build,node_external_data,node_config,node_processed_data toneMint
class node_visitor,node_public_data toneIndigo
```

## Components

### User Experience

- [Streamlit App](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/app.py): `service/app.py`
- [Agent Loop](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/agent.py): `service/agent.py`
- [Gemini Agent](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/agent_gemini.py): `service/agent_gemini.py`
- [MCP Server](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/mcp_server.py): `service/mcp_server.py`
- [Tool Schemas](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tool_specs.py): `service/core/tool_specs.py`
- [UI Visuals](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/ui_visuals.py): `service/ui_visuals.py`

### Lifecycle Analysis

- [Analysis Tools](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py): `service/core/tools.py`
- [Address Matching](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/address.py): `service/core/address.py`
- [Market Cycle](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/cycle.py): `service/core/cycle.py`
- [Survival Analysis](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/survival.py): `service/core/survival.py`
- [Store History](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py): `service/core/tools.py`
- [Vacancy Search](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py): `service/core/tools.py`
- [Area Comparison](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py): `service/core/tools.py`
- [Industry Transitions](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py): `service/core/tools.py`
- [Risk Spots](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/core/tools.py): `service/core/tools.py`

### Data Preparation

- [Batch Builder](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/pipeline/build.py): `service/pipeline/build.py`
- [External Data Prep](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/pipeline/external.py): `service/pipeline/external.py`
- [Analysis Config](https://github.com/donggwony/publicdata_ai_agent/blob/main/service/config.py): `service/config.py`
- [Processed Data](https://github.com/donggwony/publicdata_ai_agent/tree/main/service/data/processed): `service/data/processed`

### Other components

- **Visitor**
- **Public Data Sources**

## Connections

- Visitor → Streamlit App: asks (evidence: `README.md`)
- Streamlit App → Agent Loop: creates agent (evidence: `service/app.py`)
- Streamlit App → Analysis Tools: calls tools (evidence: `service/core/tools.py`)
- Streamlit App → UI Visuals: renders with (evidence: `service/app.py`)
- Agent Loop → Tool Schemas: sends schemas (evidence: `service/agent.py`)
- Agent Loop → Analysis Tools: dispatches tools (evidence: `service/agent.py`)
- Agent Loop → Gemini Agent: selects provider (evidence: `service/agent.py`)
- MCP Server → Analysis Tools: exposes tools (evidence: `service/mcp_server.py`)
- MCP Server → Tool Schemas: builds schemas (evidence: `service/mcp_server.py`)
- Analysis Tools → Address Matching: normalizes addresses (evidence: `service/core/tools.py`)
- Analysis Tools → Market Cycle: classifies cycle (evidence: `service/core/tools.py`)
- Analysis Tools → Survival Analysis: summarizes survival (evidence: `service/core/tools.py`)
- Analysis Tools → Store History: provides history (evidence: `service/core/tools.py`)
- Analysis Tools → Vacancy Search: finds vacancies (evidence: `service/core/tools.py`)
- Analysis Tools → Area Comparison: compares areas (evidence: `service/core/tools.py`)
- Analysis Tools → Industry Transitions: analyzes transitions (evidence: `service/core/tools.py`)
- Analysis Tools → Risk Spots: finds risk spots (evidence: `service/core/tools.py`)
- Public Data Sources → Batch Builder: provides CSVs (evidence: `service/pipeline/build.py`)
- Batch Builder → Address Matching: builds address keys (evidence: `service/pipeline/build.py`)
- Batch Builder → Market Cycle: computes cycle (evidence: `service/pipeline/build.py`)
- Batch Builder → Survival Analysis: computes survival (evidence: `service/pipeline/build.py`)
- Batch Builder → Analysis Config: reads settings (evidence: `service/pipeline/build.py`)
- Batch Builder → Processed Data: writes tables (evidence: `README.md`)
- External Data Prep → Analysis Config: reads settings (evidence: `service/pipeline/external.py`)
- Public Data Sources → External Data Prep: supplies inputs
- Analysis Tools → Processed Data: reads tables (evidence: `service/core/tools.py`)
