GitHub リポジトリの開発知識の集中度を推定し、**Bus Factor(属人化リスク)**を算出する API です。
https://busfactor-api.onrender.com/docs
Bus Factor とは、
「何人の主要開発者が離脱するとプロジェクトが崩壊するか」
を示す指標です。
本APIでは、GitHub のコミット情報を元に Bus Factor を近似的に算出します。
- FastAPI を用いた API 設計・実装力の証明
- 外部 API(GitHub API)連携の実装
- キャッシュ設計(DB)の実装
- ポートフォリオとして公開可能なプロダクト作成
- デプロイの経験を積む
Bus Factor は以下の手順で算出されます:
- contributors を取得
- commit 数から ownership を計算
- 貢献度の高い順に並べる
- 累積 ownership が threshold に達するまで人数を数える
ownership = contributions / total_contributions
- デフォルト threshold:
0.5 - window:
180日
※ 厳密な知識量ではなく、commit ベースの近似です
Client
↓
FastAPI
↓
SQLite(キャッシュ)
↓
GitHub API
- FastAPI
- SQLAlchemy
- SQLite(MVP)
- Cloud Run(デプロイ想定)
GET /health
{
"status": "ok"
}GET /rate-limit
{
"limit": 5000,
"remaining": 4920,
"reset": 1710000000
}GET /busfactor/{owner}/{repo}
| パラメータ | 説明 | デフォルト |
|---|---|---|
| window_days | 分析期間 | 180 |
| failure_threshold | 崩壊閾値 | 0.5 |
| refresh | キャッシュ無視 | false |
{
"repository": "owner/repo",
"bus_factor": 2,
"failure_threshold": 0.5,
"window_days": 180,
"cached": true,
"contributors": [
{
"login": "alice",
"contributions": 50,
"ownership": 0.5
}
]
}- SQLite に結果を保存
- TTL: 24時間
- 同一条件は再計算しない
(owner, repo, window_days, failure_threshold)
で一意管理
?refresh=true
- 強制再解析
- 15分に1回まで(レート制御あり)
app/
├── main.py
├── core/
├── routers/
├── services/
├── clients/
├── schemas/
├── db/
└── utils/
- router:HTTP処理
- service:ビジネスロジック
- client:GitHub API
- db:キャッシュ管理
- commit 数ベースの近似
- PR / issue / review は未考慮
- private repo 非対応
- 大規模 repo は制限あり
- file単位 ownership
- PR / issue 分析
- 非同期ジョブ化
- GitHub App 対応
uvicorn app.main:app --reloadSwagger:
http://127.0.0.1:8000/docs