Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.env

node_modules/

todo.md
10 changes: 6 additions & 4 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ dependencies = [
"langfuse>=3.10.1",
# MCP (Model Context Protocol)
"fastmcp>=2.14.1",
# Security: CVE-2025-66418, CVE-2025-66471 対応
"urllib3>=2.6.0",
# Security Fix
"urllib3>=2.6.3",
# Security: CVE-2025-68480 対応
"marshmallow>=3.26.2",
# Security: GHSA-w853-jp5j-5j7f 対応
"filelock>=3.20.1",
# Security Fix
"filelock>=3.20.3",
# Security Fix
"aiohttp>=3.13.3",
]

[project.optional-dependencies]
Expand Down
160 changes: 81 additions & 79 deletions backend/uv.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/design/0-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
2. [アーキテクチャ](./architecture.md)
3. [データフロー](./dataflow.md)
4. [ディレクトリ構造](./directory-structure.md)
5. [Lambda](./lambda/0-index.md)
5. [モノレポ設計](./monorepo.md)
6. [Lambda](./lambda/0-index.md)
16 changes: 14 additions & 2 deletions docs/design/directory-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@

```sh
ai-chatbot-api/
├── backend/
├── backend/ # Python (FastAPI)
│ ├── app/
│ └── Dockerfile
├── frontend/
├── frontend/ # TypeScript (React + Vite)
│ ├── src/
│ │ ├── App.tsx # メインコンポーネント
│ │ └── main.tsx # エントリーポイント
│ ├── Dockerfile
│ └── package.json
├── flutter/ # Dart (Flutter)
│ ├── lib/
│ │ ├── main.dart # エントリーポイント
│ │ ├── models/ # データモデル
│ │ ├── screens/ # 画面
│ │ ├── services/ # サービス
│ │ └── widgets/ # ウィジェット
│ ├── test/ # テスト
│ └── pubspec.yaml # 依存関係
├── lambda/ # Python (AWS CDK + Lambda)
├── localstack/ # ローカルAWS環境
├── docs/ # ドキュメント
├── compose.yml # Docker Compose設定
└── README.md
```
Expand Down
155 changes: 155 additions & 0 deletions docs/design/monorepo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# モノレポ設計

## 概要

本プロジェクトでは、複数の技術スタック(Python、TypeScript、Dart)を**モノレポ(Monorepo)** 構成で管理しています。

## リポジトリ構成

```text
ai-chatbot-api/
├── backend/ # Python (FastAPI)
├── frontend/ # TypeScript (React + Vite)
├── flutter/ # Dart (Flutter)
├── lambda/ # Python (AWS CDK + Lambda)
├── localstack/ # Shell (ローカルAWS環境)
└── docs/ # ドキュメント
```

## 選定理由

### モノレポを選択した理由

| 観点 | 判断 | 理由 |
| ------------------------ | ------------- | ------------------------------------------ |
| **プロジェクトの関連性** | ✅ 高い | 同一のチャットボットアプリケーションを構成 |
| **開発チーム** | ✅ 同一 | 個人開発(学習目的) |
| **リリースサイクル** | ✅ 統一的 | 同時にデプロイ可能 |
| **セキュリティ要件** | ✅ 同一 | 特別な分離要件なし |
| **リポジトリサイズ** | ✅ 小〜中規模 | 巨大なバイナリなし |
| **目的** | ✅ 学習・実験 | シンプルな構成が望ましい |

### 比較検討した選択肢

#### 1. モノレポ(直接追加)✅ 採用

```text
ai-chatbot-api/
├── backend/
├── frontend/
├── flutter/ # 直接追加
└── ...
```

| メリット | デメリット |
| ---------------------------- | ----------------------------- |
| 単一リポジトリで管理が簡単 | リポジトリサイズが増加 |
| 共通設定・ドキュメントを統一 | 言語ごとのツールが混在 |
| 関連する変更を1コミットで | CI/CDの設定が複雑になる可能性 |
| 学習コストが最小 | - |

#### 2. Git Submodule ❌ 不採用

```text
ai-chatbot-api/
├── flutter/ # ← 別リポジトリへの参照
└── .gitmodules
```

| メリット | デメリット |
| ------------------------ | ------------------------------------ |
| リポジトリの独立性が高い | 操作が複雑(学習コスト高) |
| 特定バージョンを固定可能 | `--recursive`を忘れると不完全なclone |
| 権限を分けられる | detached HEAD問題が発生しやすい |

**不採用理由**: 個人開発では複雑さに見合うメリットがない

#### 3. Git Subtree ❌ 不採用

```text
ai-chatbot-api/
├── flutter/ # ← コードがコピーされている
└── (履歴が統合)
```

| メリット | デメリット |
| ------------------------ | -------------------- |
| 通常のcloneでOK | 双方向同期が面倒 |
| サブモジュールより直感的 | 履歴が混在する可能性 |

**不採用理由**: 別リポジトリを維持する必要がなく、オーバーヘッド

#### 4. 完全に独立したリポジトリ ❌ 不採用

```text
github.com/user/ai-chatbot-api
github.com/user/ai-chatbot-flutter
```

| メリット | デメリット |
| -------------- | ------------------ |
| 最もシンプル | 関連する変更が分散 |
| 自由に実験可能 | 共通設定の重複 |

**不採用理由**: 同一アプリケーションのため統一管理が望ましい

## モノレポの運用方針

### ディレクトリごとの独立性

各ディレクトリは独立した依存関係管理を持ちます:

| ディレクトリ | 言語 | 依存管理 |
| ------------ | ---------- | --------------------- |
| `backend/` | Python | `pyproject.toml` (uv) |
| `frontend/` | TypeScript | `package.json` (pnpm) |
| `flutter/` | Dart | `pubspec.yaml` (pub) |
| `lambda/` | Python | `pyproject.toml` (uv) |

### CI/CD の分離

GitHub Actions でパスフィルターを使用し、変更があった部分のみビルド:

```yaml
# .github/workflows/backend.yml
on:
push:
paths:
- 'backend/**'

# .github/workflows/flutter.yml
on:
push:
paths:
- 'flutter/**'
```

### 開発環境

開発者は必要なプロジェクトのみセットアップ可能:

```bash
# バックエンドのみ開発
cd backend && uv sync

# Flutterのみ開発
cd flutter && flutter pub get

# 全体を起動(Docker Compose)
make up
```

## モノレポが適さなくなるケース

以下の状況が発生した場合、リポジトリ分割を検討:

1. **チームの分離**: 異なるチームが独立してリリースする必要がある
2. **セキュリティ要件**: 機密コードの分離が必要
3. **リポジトリサイズ**: cloneに数分以上かかるようになった
4. **ライセンス**: 異なるライセンスのコードが混在

## 参考資料

- [Monorepo vs Polyrepo](https://monorepo.tools/)
- [Git Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
- [Git Subtree](https://www.atlassian.com/git/tutorials/git-subtree)
30 changes: 30 additions & 0 deletions docs/design/tech-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,36 @@
- ディスク効率が良い(node_modulesの重複削減)
- 厳密なパッケージ依存関係管理

## モバイル(Flutter)

### Flutter

- [公式サイト](https://flutter.dev/)
- 選定理由
- 1つのコードベースでiOS、Android、Webアプリを構築可能
- 宣言的UIでReactに近い開発体験
- ホットリロードによる高速な開発サイクル
- Material Design 3対応で美しいUI
- Dart言語の学習

### Dart

- [公式サイト](https://dart.dev/)
- 選定理由
- Flutter公式言語
- 型安全でモダンな構文
- async/awaitによる非同期処理
- null safety対応

### Riverpod

- [公式サイト](https://riverpod.dev/)
- 選定理由
- Flutterの状態管理ライブラリ
- コンパイル時の安全性
- テスタビリティの向上
- Providerの進化版として設計

## MCP (Model Context Protocol)

### FastMCP
Expand Down
58 changes: 58 additions & 0 deletions flutter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.packages
.package-config.json
.flutter-plugins
.flutter-plugins-dependencies
.flutter_build/
flutter_export_environment.sh
*.dill
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/.gradle/
/android/app/build/
/android/app/debug
/android/app/profile
/android/app/release

# iOS/macOS
**/GeneratedPluginRegistrant.*
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Pods/
**/ios/.symlinks/
**/macos/Pods/
**/macos/.symlinks/

# Environment variables
.env

Loading
Loading