app-bff-api と admin-bff-api を統合 - #46
Open
kantacky wants to merge 5 commits into
Open
Conversation
app / admin の BFF は academic・announcement・funch・user の各 Cloud Run Service を ID トークン付き HTTP で呼び出す。統合元の 2 リポジトリはこの 初期化処理をほぼ同一の内容で個別に持っていたため、internal/shared/apiclient として 1 つに集約する。 生成済みクライアントは gen/<service> に既に存在するため新規生成は行わず、 そこから import する。google.golang.org/api を直接依存へ昇格した。 このコミットでは基盤の追加のみで、利用側の配線は行わない。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
fun-dotto/app-bff-api のアプリケーションコードを internal/modules/app 配下へ、エントリポイントを cmd/app-api へ移設する。 統合元の generated/external/*_api は再生成せず廃止した。統合元が持っていた 外部 spec は本リポジトリの api/openapi/<service>/openapi.yaml と一致しており、 gen/<service> が既に client 付きで生成済みのため、import エイリアスのみで 解決できる。外部クライアントの初期化は internal/shared/apiclient を使う。 サーバ起動は他モジュールと揃えて internal/shared/server.Run に統一した。 リクエストバリデータは統合元でも使っていないため導入していない。 api/openapi/app と gen/app は既存のものをそのまま利用する。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
fun-dotto/admin-bff-api のアプリケーションコードを internal/modules/admin 配下へ、エントリポイントを cmd/admin-api へ移設する。 app モジュールと同様に generated/external/*_api は廃止し、gen/<service> の 生成済みクライアントと internal/shared/apiclient を使う形へ配線し直した。 統合元は OpenAPI 仕様を実行時に openapi/openapi.yaml から読んでいたが、 distroless イメージには仕様ファイルが同梱されないため、他モジュールと同じく openapispec パッケージで go:embed する方式へ変更した。 サーバ起動も internal/shared/server.Run に統一している。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Dockerfile のビルド対象、CD の DEPLOY_TARGETS、mise の build / 起動タスクへ app-api と admin-api を追加する。両者は末尾が -api のため Cloud Run Service として分類される。 あわせて mise の build タスクから漏れていた announcement-api と user-api も 追加した。Dockerfile 側には元からあり、CI の mise run build がこの 2 つを 検証できていなかったため。 generate:openapi には、openapispec/ へ go:embed する仕様の複製を毎回 コピーし直すステップを追加し、元仕様との乖離を防ぐ。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
OpenAPI 仕様の原本は api/openapi/admin/openapi.yaml に既に存在するため、 go:embed 用に internal/modules/admin/openapispec/ へ複製する必要はない。 複製と、それを同期するための generate:openapi のコピー手順を削除した。 仕様は統合元と同じく実行時に相対パスで読む。runtime image への同梱は cmd/migrate が migrations/ を読むのと同じ方式で Dockerfile に追加している。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Deploying fun-dotto-server-docs with
|
| Latest commit: |
a62e7d6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8fbdfd39.fun-dotto-server-docs.pages.dev |
| Branch Preview URL: | https://feat-integrate-bff-apis.fun-dotto-server-docs.pages.dev |
kantacky
marked this pull request as ready for review
August 1, 2026 09:48
kantacky
requested review from
a team,
Hosoda-abo,
hikaru-0602 and
masaya-osuga
August 1, 2026 09:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
変更点
fun-dotto/app-bff-apiとfun-dotto/admin-bff-apiの 2 リポジトリを、本リポジトリのモジュラーモノリス規約に沿って統合しました。配置
app-bff-api/internal/*internal/modules/app/{domain,external,handler,middleware,repository,service}admin-bff-api/internal/*internal/modules/admin/{handler,middleware}internal/infrastructure/clients.gointernal/shared/apiclient/clients.gocmd/server/main.gocmd/app-api/main.go/cmd/admin-api/main.goOpenAPI 仕様
api/openapi/{app,admin}/openapi.yamlに既に存在するものをそのまま利用し、複製は作っていません。cmd/admin-apiは統合元と同じく実行時に相対パスで仕様を読み、リクエストバリデータと Firebase 認証を構築します。runtime image への同梱は、cmd/migrateがmigrations/を読むのと同じ方式でDockerfileに追加しました。cmd/app-apiは統合元でもリクエストバリデータを使っていないため、導入していません(挙動維持)。生成コードの扱い
統合元が持っていた
generated/external/*_apiは再生成せず廃止しました。両 BFF の外部 spec は本リポジトリのapi/openapi/{academic,announcement,funch,user}/openapi.yamlと一致(funch のみ引用符スタイル差のみ)で、既存のgen/*が 4 サービスともclient: trueで生成済みだったため、import エイリアスのみで解決しています。gen/{app,admin}も既存のものを利用しています。その他
internal/shared/apiclientに集約(統合元 2 つでほぼ同一の実装が重複していたため)。google.golang.org/apiを直接依存へ昇格。internal/shared/server.Runに統一。Dockerfileのビルド対象、.github/actions/set-envのDEPLOY_TARGETS、mise.tomlのbuild/ 起動タスクにapp-apiとadmin-apiを追加。mise.tomlのbuildから漏れていたannouncement-api/user-apiも追加(Dockerfile側には元からあり、CI のmise run buildが検証できていなかったため)。移植の忠実性
internal/配下は統合元のコピーで、ロジックの変更はありません。統合元と 1 ファイルずつ比較した結果は次の通りです。app の「それ以外の差分」6 件はすべて
gofmtによる整形結果です。統合元に gofmt 未適用の箇所が残っていたためで、内訳は構造体フィールドのアラインメント調整が 4 件(external/room_change_model.go、handler/room_change.go、repository/announcement_mock.go、repository/funch_mock.go)、ファイル末尾の余分な空行削除が 2 件(service/academic.go、service/academic_test.go)です。意図的に手を入れたのは以下の 3 点だけです。
internal/infrastructure/clients.goをinternal/shared/apiclientへ集約する際の書き直し(URL 取得をrequireURLに切り出し、初期化順を整理)cmd/*/main.goの起動処理(router.Run→internal/shared/server.Run)と、admin の仕様読み込みパス確認内容
go build ./.../go vet ./.../go test ./...がすべて通過(統合元の既存テストを含む)。gofmt差分なし。マージ前に別途必要な対応
.env.example:ACADEMIC_API_URL/ANNOUNCEMENT_API_URL/FUNCH_API_URL/USER_API_URLの追記が必要です(作業環境の制約でこの PR には含めていません)。deploy.ymlは上記 4 つをenv_varsでデプロイ時に投入していましたが、本リポジトリのcd.ymlは既存サービスも含め env を管理していないため、その方針に合わせて追加していません。app-api/admin-apiのサービス側に 4 つの URL を設定する必要があります。waysubmodule、Taskfile.yml、AGENTS.md/CLAUDE.md、.serena等)は取り込んでいません。🤖 Generated with Claude Code