# Walkthrough - 愛犬給餌量計算Webアプリ `Lab_gr`

愛犬「ろみ」（ラブラドール・レトリバー）のための給餌量計算Webアプリ `Lab_gr` の実装および全ファイルの一括生成、動作検証を完了しました。

## 🛠️ 作成・更新したファイル一覧

| ファイル | 概要 |
| :--- | :--- |
| [Lab_gr.py](file:///Users/mmorita/Desktop/MyVS/Gemini/lab_gr/Lab_gr.py) | Streamlitメインアプリケーション（サイドバー入力、BIG KPI、Plotlyゲージ、ブレンド機能、データマスター閲覧） |
| [modules/calc.py](file:///Users/mmorita/Desktop/MyVS/Gemini/lab_gr/modules/calc.py) | RER ($70 \times \text{kg}^{0.75}$)、DER ($\text{RER} \times \text{係数}$)、給餌量(g)、および2種フードブレンド計算ロジック |
| [modules/google_sheets.py](file:///Users/mmorita/Desktop/MyVS/Gemini/lab_gr/modules/google_sheets.py) | `gspread` / `google-auth` によるスプレッドシート連携（`secrets.toml` 未設定時のフォールバック機能付き） |
| [modules/ui_helpers.py](file:///Users/mmorita/Desktop/MyVS/Gemini/lab_gr/modules/ui_helpers.py) | 医療免責事項、Plotlyゲージチャート、BIG KPIメトリクスカード描画ヘルパー |
| [.antigravity/rules.md](file:///Users/mmorita/Desktop/MyVS/Gemini/lab_gr/.antigravity/rules.md) | エージェントのディレクトリ・Git操作およびセキュリティに関する行動規範 |
| [requirements.txt](file:///Users/mmorita/Desktop/MyVS/Gemini/lab_gr/requirements.txt) | 依存ライブラリ（`streamlit`, `pandas`, `gspread`, `google-auth`, `plotly`） |
| [.streamlit/config.toml](file:///Users/mmorita/Desktop/MyVS/Gemini/lab_gr/.streamlit/config.toml) | UIテーマカラー設定（ラブラドール風トーン） |
| [.streamlit/secrets.toml.example](file:///Users/mmorita/Desktop/MyVS/Gemini/lab_gr/.streamlit/secrets.toml.example) | GCPサービスアカウントとSpreadsheet IDの設定サンプルテンプレート |
| [README.md](file:///Users/mmorita/Desktop/MyVS/Gemini/lab_gr/README.md) | アプリ概要、機能説明、ローカル起動方法、Google Sheets設定手順ドキュメント |
| [.gitignore](file:///Users/mmorita/Desktop/MyVS/Gemini/lab_gr/.gitignore) | `.streamlit/secrets.toml` 等の機密ファイル除外設定 |

---

## 🧪 動作確認と検証結果

1. **計算ロジック検証 (`modules/calc.py`)**:
   - 体重 `30.0 kg`、ライフステージ係数 `1.0`（肥満傾向・減量中）における RER `897.3 kcal` / DER `897.3 kcal` の正常算出を確認
   - カロリー密度 `362 kcal/100g` と `310 kcal/100g` のフードを 7:3 でブレンドした際の各給餌量 (メイン: 181.3g, サブ: 77.7g, 計 259.0g) の正確な計算を確認。

2. **フォールバックデータ検証 (`modules/google_sheets.py`)**:
   - `secrets.toml` 未設定時においても例外でクラッシュすることなく、自動的にローカルの標準ドッグフード＆ライフステージデータが読み込まれることを確認。

3. **Streamlit アプリ起動検証 (`Lab_gr.py`)**:
   - ヘッドレス起動にて Streamlit サーバが正常起動し、エラーなしにページレンダリングが行われることを実証。

---

## 🚀 ローカルでの実行方法

プロジェクトルート (`/Users/＊＊＊＊/lab_gr`) で以下のコマンドを実行してください。

```bash
streamlit run Lab_gr.py
```
