# beak00hyunmin7/team_yucheital_ai_model architecture

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

- Interactive diagram: https://gitdiagram.com/beak00hyunmin7/team_yucheital_ai_model
- Repository: https://github.com/beak00hyunmin7/team_yucheital_ai_model

## Overview

유체이탈은 등고선 지형과 강우·시간 조건으로 침수 수심을 예측하는 AI 모델 및 웹앱이며, 별도 도구로 OpenFOAM 정답 시뮬레이션을 구축합니다. 주요 경로는 지역 등고선에서 고도 격자를 추출하고, OpenFOAM으로 침수 시계열을 만든 뒤 학습 이미지 쌍을 준비해 U-Net을 학습·추론하고 결과를 웹앱에서 제공하는 것입니다. README에 있는 검증, 애니메이션, scalar 추론, 간이 유출 시뮬레이션도 포함했습니다. 화살표는 발췌 소스의 호출 또는 README의 명시적 설명으로 확인 가능한 관계만 표시하며, 생략된 구현은 경로 수준으로 나타냅니다.

Main entry points: [`terrainFlowSim/webapp/backend/app.py`](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/webapp/backend/app.py) (FastAPI routes), [`busanOpenFOAMDataset/run_batch.py`](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/busanOpenFOAMDataset/run_batch.py) (OpenFOAM batches), [`terrainFlowSim/ai_model/src/models/unet_generator.py`](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/models/unet_generator.py) (FiLM U-Net), [`busanOpenFOAMDataset/run_rain_variants.py`](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/busanOpenFOAMDataset/run_rain_variants.py) (Rain variants)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_terrain["Terrain inputs"]
  node_contours["Contour sources"]
  node_regional_dem["Regional DEM extraction<br/>[extract_patch.py]"]
  node_seoul_dem["Seoul terrain tools"]
  node_staging["Simulation staging<br/>[prepare_samples.py]"]
end

subgraph group_simulation["Flow simulation"]
  node_foam_batch["OpenFOAM batches<br/>[run_batch.py]"]
  node_rain_variants["Rain variants"]
  node_foam_results[("Simulation results")]
  node_simple_flow["Overland flow model"]
end

subgraph group_ai["AI model"]
  node_data_prep["Training-pair preparation"]
  node_render["Field rendering<br/>[render_fields.py]"]
  node_contour_dataset["Contour dataset"]
  node_scalar_dataset["Scalar dataset"]
  node_flow_accum["Flow accumulation<br/>[flow_accum.py]"]
  node_trainer["Model training<br/>[train.py]"]
  node_scalar_trainer["Scalar training<br/>[train_scalar.py]"]
  node_translation["Translation model"]
  node_unet["FiLM U-Net<br/>[unet_generator.py]"]
  node_inference["Depth inference<br/>[inference_api.py]"]
  node_scalar_inference["Scalar inference"]
end

subgraph group_web["Web application"]
  node_api["FastAPI routes<br/>[app.py]"]
  node_terrain_io["Terrain input handling<br/>[terrain_io.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_figures["Analysis figures<br/>[analysis_figure.py]"]
  node_mysql[("MySQL users")]
end

subgraph group_validation["Evaluation"]
  node_ground_truth["Ground-truth access<br/>[ground_truth.py]"]
  node_evaluation["Evaluation tools<br/>[evaluate.py]"]
end

node_user(("User"))
node_browser(("Browser"))
node_openfoam["OpenFOAM"]

node_contours -->|"extracts DEM"| node_regional_dem
node_contours -->|"builds terrain"| node_seoul_dem
node_regional_dem -.->|"stages terrain"| node_staging
node_seoul_dem -->|"runs simulation"| node_simple_flow
node_staging -->|"runs cases"| node_foam_batch
node_foam_batch -->|"executes solver"| node_openfoam
node_rain_variants -->|"reuses helpers"| node_foam_batch
node_rain_variants -->|"executes solver"| node_openfoam
node_foam_batch -->|"writes results"| node_foam_results
node_foam_results -->|"prepares pairs"| node_data_prep
node_data_prep -->|"renders fields"| node_render
node_contour_dataset -.->|"uses renderers"| node_render
node_scalar_dataset -->|"computes accumulation"| node_flow_accum
node_trainer -.->|"loads dataset"| node_contour_dataset
node_trainer -.->|"trains model"| node_translation
node_translation -->|"uses generator"| node_unet
node_scalar_trainer -.->|"loads dataset"| node_scalar_dataset
node_scalar_inference -->|"runs generator"| node_unet
node_scalar_inference -->|"computes accumulation"| node_flow_accum
node_inference -->|"runs generator"| node_unet
node_browser -.->|"requests prediction"| node_api
node_api -->|"checks access"| node_auth
node_auth -->|"stores accounts"| node_mysql
node_api -->|"parses terrain"| node_terrain_io
node_api -->|"predicts depth"| node_inference
node_api -->|"loads reference"| node_ground_truth
node_api -->|"builds comparison"| node_figures
node_api -.->|"returns maps"| node_browser
node_evaluation -.->|"compares predictions"| node_foam_results
node_user -.->|"uses app"| node_browser

click node_regional_dem "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/busanTerrain/extract_patch.py"
click node_seoul_dem "https://github.com/beak00hyunmin7/team_yucheital_ai_model/tree/main/seoulTerrain"
click node_staging "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/busanOpenFOAMDataset/prepare_samples.py"
click node_foam_batch "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/busanOpenFOAMDataset/run_batch.py"
click node_rain_variants "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/busanOpenFOAMDataset/run_rain_variants.py"
click node_simple_flow "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/overland_flow_sim.py"
click node_data_prep "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/scripts/prepare_openfoam_dataset.py"
click node_render "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/utils/render_fields.py"
click node_contour_dataset "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/datasets/contour_flow_dataset.py"
click node_scalar_dataset "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/datasets/scalar_flow_dataset.py"
click node_flow_accum "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/utils/flow_accum.py"
click node_trainer "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/train.py"
click node_scalar_trainer "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/train_scalar.py"
click node_translation "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/models/translation_model.py"
click node_unet "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/models/unet_generator.py"
click node_inference "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/inference_api.py"
click node_scalar_inference "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/inference_scalar.py"
click node_ground_truth "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/ground_truth.py"
click node_api "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/webapp/backend/app.py"
click node_terrain_io "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/webapp/backend/terrain_io.py"
click node_auth "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/webapp/backend/auth.py"
click node_figures "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/webapp/backend/analysis_figure.py"
click node_evaluation "https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/scripts/evaluate.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_contours,node_regional_dem,node_seoul_dem,node_staging,node_user,node_browser toneBlue
class node_foam_batch,node_rain_variants,node_foam_results,node_simple_flow toneAmber
class node_data_prep,node_render,node_contour_dataset,node_scalar_dataset,node_flow_accum,node_trainer,node_scalar_trainer,node_translation,node_unet,node_inference,node_scalar_inference toneMint
class node_api,node_terrain_io,node_auth,node_figures,node_mysql toneRose
class node_ground_truth,node_evaluation,node_openfoam toneIndigo
```

## Components

### Terrain inputs

- **Contour sources**
- [Regional DEM extraction](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/busanTerrain/extract_patch.py): `busanTerrain/extract_patch.py`
- [Seoul terrain tools](https://github.com/beak00hyunmin7/team_yucheital_ai_model/tree/main/seoulTerrain): `seoulTerrain`
- [Simulation staging](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/busanOpenFOAMDataset/prepare_samples.py): `busanOpenFOAMDataset/prepare_samples.py`

### Flow simulation

- [OpenFOAM batches](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/busanOpenFOAMDataset/run_batch.py): `busanOpenFOAMDataset/run_batch.py`
- [Rain variants](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/busanOpenFOAMDataset/run_rain_variants.py): `busanOpenFOAMDataset/run_rain_variants.py`
- **Simulation results**
- [Overland flow model](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/overland_flow_sim.py): `terrainFlowSim/overland_flow_sim.py`

### AI model

- [Training-pair preparation](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/scripts/prepare_openfoam_dataset.py): `terrainFlowSim/ai_model/scripts/prepare_openfoam_dataset.py`
- [Field rendering](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/utils/render_fields.py): `terrainFlowSim/ai_model/src/utils/render_fields.py`
- [Contour dataset](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/datasets/contour_flow_dataset.py): `terrainFlowSim/ai_model/src/datasets/contour_flow_dataset.py`
- [Scalar dataset](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/datasets/scalar_flow_dataset.py): `terrainFlowSim/ai_model/src/datasets/scalar_flow_dataset.py`
- [Flow accumulation](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/utils/flow_accum.py): `terrainFlowSim/ai_model/src/utils/flow_accum.py`
- [Model training](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/train.py): `terrainFlowSim/ai_model/src/train.py`
- [Scalar training](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/train_scalar.py): `terrainFlowSim/ai_model/src/train_scalar.py`
- [Translation model](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/models/translation_model.py): `terrainFlowSim/ai_model/src/models/translation_model.py`
- [FiLM U-Net](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/models/unet_generator.py): `terrainFlowSim/ai_model/src/models/unet_generator.py`
- [Depth inference](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/inference_api.py): `terrainFlowSim/ai_model/src/inference_api.py`
- [Scalar inference](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/inference_scalar.py): `terrainFlowSim/ai_model/src/inference_scalar.py`

### Web application

- [FastAPI routes](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/webapp/backend/app.py): `terrainFlowSim/webapp/backend/app.py`
- [Terrain input handling](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/webapp/backend/terrain_io.py): `terrainFlowSim/webapp/backend/terrain_io.py`
- [Authentication](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/webapp/backend/auth.py): `terrainFlowSim/webapp/backend/auth.py`
- [Analysis figures](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/webapp/backend/analysis_figure.py): `terrainFlowSim/webapp/backend/analysis_figure.py`
- **MySQL users**

### Evaluation

- [Ground-truth access](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/src/ground_truth.py): `terrainFlowSim/ai_model/src/ground_truth.py`
- [Evaluation tools](https://github.com/beak00hyunmin7/team_yucheital_ai_model/blob/main/terrainFlowSim/ai_model/scripts/evaluate.py): `terrainFlowSim/ai_model/scripts/evaluate.py`

### Other components

- **User**
- **Browser**
- **OpenFOAM**

## Connections

- Contour sources → Regional DEM extraction: extracts DEM (evidence: `busanTerrain/extract_patch.py`)
- Contour sources → Seoul terrain tools: builds terrain (evidence: `seoulTerrain/generate_seoul_dataset.py`)
- Regional DEM extraction → Simulation staging: stages terrain
- Seoul terrain tools → Overland flow model: runs simulation (evidence: `seoulTerrain/generate_seoul_dataset.py`)
- Simulation staging → OpenFOAM batches: runs cases (evidence: `busanOpenFOAMDataset/run_batch.py`)
- OpenFOAM batches → OpenFOAM: executes solver (evidence: `busanOpenFOAMDataset/run_batch.py`)
- Rain variants → OpenFOAM batches: reuses helpers (evidence: `busanOpenFOAMDataset/run_rain_variants.py`)
- Rain variants → OpenFOAM: executes solver (evidence: `busanOpenFOAMDataset/run_rain_variants.py`)
- OpenFOAM batches → Simulation results: writes results (evidence: `busanOpenFOAMDataset/run_batch.py`)
- Simulation results → Training-pair preparation: prepares pairs (evidence: `terrainFlowSim/ai_model/scripts/prepare_openfoam_dataset.py`)
- Training-pair preparation → Field rendering: renders fields (evidence: `terrainFlowSim/ai_model/scripts/prepare_openfoam_dataset.py`)
- Contour dataset → Field rendering: uses renderers
- Scalar dataset → Flow accumulation: computes accumulation (evidence: `terrainFlowSim/ai_model/src/datasets/scalar_flow_dataset.py`)
- Model training → Contour dataset: loads dataset
- Model training → Translation model: trains model
- Translation model → FiLM U-Net: uses generator (evidence: `terrainFlowSim/ai_model/src/models/translation_model.py`)
- Scalar training → Scalar dataset: loads dataset
- Scalar inference → FiLM U-Net: runs generator (evidence: `terrainFlowSim/ai_model/src/inference_scalar.py`)
- Scalar inference → Flow accumulation: computes accumulation (evidence: `terrainFlowSim/ai_model/src/inference_scalar.py`)
- Depth inference → FiLM U-Net: runs generator (evidence: `terrainFlowSim/ai_model/src/inference_api.py`)
- Browser → FastAPI routes: requests prediction
- FastAPI routes → Authentication: checks access (evidence: `terrainFlowSim/webapp/backend/app.py`)
- Authentication → MySQL users: stores accounts (evidence: `terrainFlowSim/webapp/backend/auth.py`)
- FastAPI routes → Terrain input handling: parses terrain (evidence: `terrainFlowSim/webapp/backend/app.py`)
- FastAPI routes → Depth inference: predicts depth (evidence: `terrainFlowSim/webapp/backend/app.py`)
- FastAPI routes → Ground-truth access: loads reference (evidence: `terrainFlowSim/webapp/backend/app.py`)
- FastAPI routes → Analysis figures: builds comparison (evidence: `terrainFlowSim/webapp/backend/app.py`)
- FastAPI routes → Browser: returns maps
- Evaluation tools → Simulation results: compares predictions
- User → Browser: uses app
