mcpField

saas-architecture-deep-dive

github.com/founderjourney開発45 回インストール
リポジトリ

saas-architecture-deep-dive について

saas-architecture-deep-diveは、SaaSアーキテクチャの設計と説明に使うリファレンススキルです。判断指針、パターン、チェックリストを通じて、マルチテナント、課金、スケーリング、設計上のトレードオフを検討できます。

主な機能

  1. 01マルチテナントモデルの選定指針
  2. 02テナント分離とコンテキストのパターン
  3. 03課金モデルの指針
  4. 04アーキテクチャ上の比較検討
  5. 05設計チェックリストとリファレンス

活用シーン

  1. 01SaaSのテナントモデル選定
  2. 02課金方法と機能アクセスの計画
  3. 03スケーリングとサービス構成の評価

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/founderjourney/claude-skills --skill saas-architecture-deep-dive

インストール後、Claude Code で/saas-architecture-deep-diveを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
billing-integration.md
multi-tenancy-patterns.md
scaling-strategies.md
your-architecture-answers.md

詳細

SaaS アーキテクチャの詳細解説

SaaS アーキテクチャを習得し、シニアレベルの確かな知識をもって説明するためのシステムです。

メインワークフロー

1. ニーズを特定する
ユーザーの発言…アクション
「マルチテナンシーを説明して」multi-tenancy-patterns.mdを参照
「SaaS システムを設計して」Decision Framework(以下)へ進む
「決済/課金を統合して」billing-integration.mdを参照
「システムをスケールさせて」scaling-strategies.mdを参照
「アーキテクチャを説明して」your-architecture-answers.mdを参照

2. Decision Framework:SaaS を設計する

ステップ 1:要件

Preguntas clave:
- Cuantos tenants esperamos? (10, 100, 10000?)
- Que tan sensibles son los datos? (compliance requirements?)
- Tenants similares o muy diferentes en uso?
- Budget de infraestructura?

ステップ 2:テナンシーモデルを選択する

POCOS TENANTS + DATOS SENSIBLES + ALTO BUDGET
→ SILO (database per tenant)

MUCHOS TENANTS + DATOS NO SENSIBLES + BAJO BUDGET
→ POOL (shared database, tenant_id)

BALANCE
→ BRIDGE (schema per tenant)

ステップ 3:分離境界を定義する

- Data isolation: como separar datos por tenant
- Compute isolation: recursos compartidos o dedicados
- Network isolation: VPCs, subnets separados?

ステップ 4:課金モデル

- Flat rate: simple, predecible
- Usage-based: justo, complejo de trackear
- Tiered: balance, feature gates
- Hybrid: base + overage

3. SaaS の主要パターン
マルチテナンシー(概要)
モデル分離コスト複雑さ用途
サイロ高高中ヘルスケア、金融
プール低低低一般的な SaaS
ブリッジ中中高エンタープライズ SaaS

詳しくはmulti-tenancy-patterns.mdを参照してください。

テナントコンテキスト
// Middleware pattern
const tenantMiddleware = (req, res, next) => {
  const tenantId = req.headers['x-tenant-id'] || extractFromJWT(req);
  if (!tenantId) return res.status(401).json({ error: 'Tenant required' });
  req.tenant = tenantId;
  next();
};

// Query builder injection
const withTenant = (query, tenantId) => {
  return query.where('tenant_id', tenantId);
};
機能フラグ
// Feature flag pattern por plan
const features = {
  free: ['basic_reports'],
  pro: ['basic_reports', 'advanced_reports', 'api_access'],
  enterprise: ['basic_reports', 'advanced_reports', 'api_access', 'sso', 'audit_logs']
};

const hasFeature = (tenant, feature) => {
  return features[tenant.plan]?.includes(feature) ?? false;
};

4. よくあるトレードオフ

モノリスとマイクロサービス

Monolito cuando:
- Equipo pequeno (<5 devs)
- Dominio no claramente separable
- Time-to-market prioritario

Microservicios cuando:
- Equipos independientes por servicio
- Scaling muy diferente por componente
- Diferentes stacks por servicio tienen sentido

SaaS における SQL と NoSQL

SQL (PostgreSQL) cuando:
- Datos relacionales (users, orders, subscriptions)
- Transacciones importantes (pagos)
- Queries complejas con JOINs

NoSQL (MongoDB) cuando:
- Schemas muy variables por tenant
- Write-heavy workloads
- Document-centric data

同期処理と非同期処理

Sync cuando:
- Usuario espera resultado inmediato
- Operacion rapida (<500ms)
- Feedback importante para UX

Async cuando:
- Operaciones largas (emails, reports)
- Puede fallar y necesita retry
- No bloquea al usuario

5. SaaS アーキテクチャのチェックリスト
DATA LAYER
[ ] Tenant isolation implementado
[ ] Backup strategy por tenant o global
[ ] Data retention policies definidas
[ ] Audit logging para compliance

APPLICATION LAYER
[ ] Tenant context en cada request
[ ] Feature flags por plan
[ ] Rate limiting por tenant
[ ] Error handling con tenant context

INFRASTRUCTURE
[ ] Scaling strategy definida
[ ] Monitoring por tenant
[ ] Cost allocation posible
[ ] Disaster recovery plan

BILLING
[ ] Subscription lifecycle manejado
[ ] Usage tracking si aplica
[ ] Webhook handlers para Stripe events
[ ] Dunning flow para pagos fallidos

参考資料

ファイル内容用途
multi-tenancy-patterns.mdプール、サイロ、ブリッジの詳細マルチテナンシーを設計する
billing-integration.mdStripe のサブスクリプション、ウェブフック課金を統合する
scaling-strategies.md水平スケーリング、垂直スケーリング、シャーディングシステムをスケールさせる
your-architecture-answers.mdHostelOS、Digitaliza の解説自身の経験を説明する

コメント