scope-appropriate-architecture
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseScope-Appropriate Architecture
适配规模的架构
Right-size every architectural decision to the project's actual needs. Not every project needs hexagonal architecture, CQRS, or microservices.
Core principle: Detect the project tier first, then constrain all downstream pattern choices to that tier's complexity ceiling.
让每个架构决策都适配项目的实际需求。并非所有项目都需要六边形架构、CQRS或微服务。
核心原则: 先确定项目层级,再将所有后续的模式选择限制在该层级的复杂度上限内。
The 6 Project Tiers
6个项目层级
| Tier | LOC Ratio | Architecture | DB | Auth | Tests |
|---|---|---|---|---|---|
| 1. Interview/Take-home | 1.0-1.3x | Flat files, no layers | SQLite / JSON | None or basic | 8-15 focused |
| 2. Hackathon/Prototype | 0.8-1.0x | Single file if possible | SQLite / in-memory | None | Zero |
| 3. Startup/MVP | 1.0-1.5x | MVC monolith | Managed Postgres | Clerk/Supabase Auth | Happy path + critical |
| 4. Growth-stage | 1.5-2.0x | Modular monolith | Postgres + Redis | Auth service | Unit + integration |
| 5. Enterprise | 2.0-3.0x | Hexagonal/DDD | Postgres + queues | OAuth2/SAML | Full pyramid |
| 6. Open Source | 1.2-1.8x | Minimal API surface | Configurable | Optional | Exhaustive public API |
LOC Ratio = total lines / core business logic lines. Higher ratio = more infrastructure code relative to business value.
| 层级 | LOC 占比 | 架构 | 数据库 | 认证 | 测试 |
|---|---|---|---|---|---|
| 1. 面试/带回家作业 | 1.0-1.3x | 扁平文件,无分层 | SQLite / JSON | 无或基础认证 | 8-15个聚焦型测试 |
| 2. 黑客松/原型 | 0.8-1.0x | 尽可能单文件 | SQLite / 内存数据库 | 无 | 无 |
| 3. 初创公司/MVP | 1.0-1.5x | MVC单体应用 | 托管式Postgres | Clerk/Supabase Auth | 主路径+关键场景测试 |
| 4. 成长期 | 1.5-2.0x | 模块化单体应用 | Postgres + Redis | 认证服务 | 单元测试+集成测试 |
| 5. 企业级 | 2.0-3.0x | 六边形架构/DDD | Postgres + 消息队列 | OAuth2/SAML | 完整测试金字塔 |
| 6. 开源项目 | 1.2-1.8x | 极简API接口 | 可配置 | 可选 | 全面的公共API测试 |
LOC 占比 = 总代码行数 / 核心业务逻辑行数。占比越高,相对于业务价值的基础设施代码越多。
Auto-Detection Signals
自动检测信号
| Signal | Tier Indicator |
|---|---|
| README contains "take-home", "assignment", "interview" | Tier 1 |
| Time limit mentioned (e.g., "4 hours", "weekend") | Tier 1-2 |
| < 10 files, no CI, no Docker | Tier 1-2 |
| Tier 3+ |
| Tier 3+ |
| Kubernetes/Terraform files present | Tier 4-5 |
| Tier 6 |
Monorepo with | Tier 4-5 |
When confidence is low: Ask the user with .
AskUserQuestion| 信号 | 层级指示 |
|---|---|
| README包含"take-home"、"assignment"、"interview" | 层级1 |
| 提及时间限制(如"4小时"、"周末") | 层级1-2 |
| 少于10个文件,无CI,无Docker | 层级1-2 |
存在 | 层级3+ |
| 层级3+ |
| 存在Kubernetes/Terraform文件 | 层级4-5 |
存在 | 层级6 |
包含 | 层级4-5 |
当置信度较低时: 使用询问用户。
AskUserQuestionPattern Appropriateness Matrix
模式适配矩阵
| Pattern | Interview | Hackathon | MVP | Growth | Enterprise |
|---|---|---|---|---|---|
| Repository pattern | OVERKILL | OVERKILL | BORDERLINE | APPROPRIATE | REQUIRED |
| Event-driven arch | OVERKILL | OVERKILL | OVERKILL | SELECTIVE | APPROPRIATE |
| DI containers | OVERKILL | OVERKILL | LIGHT ONLY | APPROPRIATE | REQUIRED |
| Separate DTO layers | OVERKILL | OVERKILL | 1 EXTRA | 2 LAYERS | ALL LAYERS |
| Microservices | NEVER | NEVER | NEVER | EXTRACT ONLY | APPROPRIATE |
| CQRS | OVERKILL | OVERKILL | OVERKILL | OVERKILL | WHEN JUSTIFIED |
| Hexagonal architecture | OVERKILL | OVERKILL | OVERKILL | BORDERLINE | APPROPRIATE |
| DDD (bounded contexts) | OVERKILL | OVERKILL | OVERKILL | SELECTIVE | APPROPRIATE |
| Message queues | OVERKILL | OVERKILL | BORDERLINE | APPROPRIATE | REQUIRED |
| API versioning | SKIP | SKIP | URL prefix | Header-based | Full strategy |
| Error handling | try/catch | console.log | Error boundary | Error service | RFC 9457 |
| Logging | console.log | none | Structured JSON | Centralized | OpenTelemetry |
Rule of thumb: If a pattern shows OVERKILL for the detected tier, do NOT use it. Suggest the simpler alternative instead.
| 模式 | 面试项目 | 黑客松项目 | MVP | 成长期 | 企业级 |
|---|---|---|---|---|---|
| 仓储模式 | 过度设计 | 过度设计 | 临界 | 合适 | 必需 |
| 事件驱动架构 | 过度设计 | 过度设计 | 过度设计 | 选择性使用 | 合适 |
| DI容器 | 过度设计 | 过度设计 | 仅轻量使用 | 合适 | 必需 |
| 独立DTO层 | 过度设计 | 过度设计 | 1层额外 | 2层 | 全层级 |
| 微服务 | 绝不使用 | 绝不使用 | 绝不使用 | 仅提取核心 | 合适 |
| CQRS | 过度设计 | 过度设计 | 过度设计 | 过度设计 | 合理时使用 |
| 六边形架构 | 过度设计 | 过度设计 | 过度设计 | 临界 | 合适 |
| DDD(限界上下文) | 过度设计 | 过度设计 | 过度设计 | 选择性使用 | 合适 |
| 消息队列 | 过度设计 | 过度设计 | 临界 | 合适 | 必需 |
| API版本控制 | 跳过 | 跳过 | URL前缀 | 基于Header | 完整策略 |
| 错误处理 | try/catch | console.log | 错误边界 | 错误服务 | RFC 9457 |
| 日志 | console.log | 无 | 结构化JSON | 集中式 | OpenTelemetry |
经验法则: 如果某模式在检测到的层级中显示为过度设计,则不要使用它。建议改用更简单的替代方案。
Technology Quick-Reference by Tier
各层级技术速查
| Choice | Interview | Hackathon | MVP | Growth | Enterprise |
|---|---|---|---|---|---|
| Database | SQLite / JSON file | In-memory / SQLite | Managed Postgres | Postgres + Redis | Postgres + queues + cache |
| Auth | Hardcoded / none | None | Clerk / Supabase Auth | Auth service | OAuth2 / SAML / SSO |
| State mgmt | useState | useState | Zustand / Context | Zustand + React Query | Redux / custom + cache |
| CSS | Inline / Tailwind | Tailwind | Tailwind | Tailwind + design tokens | Design system |
| API | Express routes | Single file handler | Next.js API routes | FastAPI / Express | Gateway + services |
| Deployment | localhost | Vercel / Railway | Vercel / Railway | Docker + managed | K8s / ECS |
| CI/CD | None | None | GitHub Actions basic | Multi-stage pipeline | Full pipeline + gates |
| Monitoring | None | None | Error tracking only | APM + logs | Full observability stack |
| 选择 | 面试项目 | 黑客松项目 | MVP | 成长期 | 企业级 |
|---|---|---|---|---|---|
| 数据库 | SQLite / JSON文件 | 内存数据库 / SQLite | 托管式Postgres | Postgres + Redis | Postgres + 消息队列 + 缓存 |
| 认证 | 硬编码 / 无 | 无 | Clerk / Supabase Auth | 认证服务 | OAuth2 / SAML / SSO |
| 状态管理 | useState | useState | Zustand / Context | Zustand + React Query | Redux / 自定义+缓存 |
| CSS | 内联 / Tailwind | Tailwind | Tailwind | Tailwind + 设计令牌 | 设计系统 |
| API | Express路由 | 单文件处理器 | Next.js API路由 | FastAPI / Express | 网关+服务 |
| 部署 | localhost | Vercel / Railway | Vercel / Railway | Docker + 托管服务 | K8s / ECS |
| CI/CD | 无 | 无 | GitHub Actions基础版 | 多阶段流水线 | 完整流水线+ gates |
| 监控 | 无 | 无 | 仅错误追踪 | APM + 日志 | 完整可观测性栈 |
Build vs Buy Decision Tree (Tiers 1-3)
自研vs采购决策树(层级1-3)
For Interview, Hackathon, and MVP tiers, always prefer buying over building:
| Capability | BUY (use SaaS) | BUILD (only if) |
|---|---|---|
| Auth | Clerk, Supabase Auth, Auth0 | Core product IS auth |
| Payments | Stripe | Core product IS payments |
| Resend, SendGrid | Core product IS email | |
| File storage | S3, Cloudflare R2 | Compliance requires on-prem |
| Search | Algolia, Typesense Cloud | > 10M docs or custom ranking |
| Analytics | PostHog, Mixpanel | Unique data requirements |
Time savings: Auth alone is 2-4 weeks build vs 2 hours integrate.
对于面试、黑客松和MVP层级,始终优先采购而非自研:
| 能力 | 采购(使用SaaS) | 自研(仅当) |
|---|---|---|
| 认证 | Clerk, Supabase Auth, Auth0 | 核心产品就是认证 |
| 支付 | Stripe | 核心产品就是支付 |
| 邮件 | Resend, SendGrid | 核心产品就是邮件 |
| 文件存储 | S3, Cloudflare R2 | 合规要求本地部署 |
| 搜索 | Algolia, Typesense Cloud | 超过10M文档或自定义排序 |
| 分析 | PostHog, Mixpanel | 独特的数据需求 |
时间节省: 仅认证一项,自研需2-4周,集成仅需2小时。
Upgrade Path
升级路径
When a project grows beyond its current tier, upgrade incrementally:
Tier 2 (Prototype) → Tier 3 (MVP)
Add: Postgres, basic auth, error boundaries, CI
Tier 3 (MVP) → Tier 4 (Growth)
Add: Redis cache, background jobs, monitoring, module boundaries
Tier 4 (Growth) → Tier 5 (Enterprise)
Add: DI, bounded contexts, message queues, full observability
Extract: First microservice (only the proven bottleneck)Key insight: You can always add complexity later. You cannot easily remove it.
当项目成长超出当前层级时,逐步升级:
Tier 2 (Prototype) → Tier 3 (MVP)
Add: Postgres, basic auth, error boundaries, CI
Tier 3 (MVP) → Tier 4 (Growth)
Add: Redis cache, background jobs, monitoring, module boundaries
Tier 4 (Growth) → Tier 5 (Enterprise)
Add: DI, bounded contexts, message queues, full observability
Extract: First microservice (only the proven bottleneck)核心见解: 你总能在后续添加复杂度,但很难轻易移除它。
When This Skill Activates
该技能的激活场景
This skill is loaded by:
- Phase 0 (context discovery)
brainstorm - Step 0 (context discovery)
implement - YAGNI check
quality-gates - Any skill that needs to right-size a recommendation
The detected tier is passed as context to constrain downstream decisions.
此技能在以下场景加载:
- 阶段0(上下文发现)
brainstorm - 步骤0(上下文发现)
implement - YAGNI检查
quality-gates - 任何需要适配规模的推荐的技能
检测到的层级会作为上下文传递,以限制后续决策。
Related Skills
相关技能
- - Uses tier detection in Phase 0 to constrain ideas
ork:brainstorm - - Uses tier detection in Step 0 to constrain architecture
ork:implement - - YAGNI gate references this skill's tier matrix
ork:quality-gates - - Architecture validation (constrained by tier)
ork:architecture-patterns
- - 在阶段0使用层级检测来限制想法
ork:brainstorm - - 在步骤0使用层级检测来限制架构
ork:implement - - YAGNI检查参考此技能的层级矩阵
ork:quality-gates - - 架构验证(受层级限制)
ork:architecture-patterns
References
参考资料
Load on demand with :
Read("${CLAUDE_SKILL_DIR}/references/<file>")| File | Content |
|---|---|
| Tiers 1-2 in detail |
| Tier 3 patterns and decisions |
| Tiers 4-5 patterns and justification criteria |
| Tier 6 unique considerations |
使用按需加载:
Read("${CLAUDE_SKILL_DIR}/references/<file>")| 文件 | 内容 |
|---|---|
| 层级1-2的详细内容 |
| 层级3的模式和决策 |
| 层级4-5的模式和判断标准 |
| 层级6的独特考量 |