senior-architect
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSenior Architect
资深架构师
Architecture design and analysis tools for making informed technical decisions.
用于制定明智技术决策的架构设计与分析工具。
Table of Contents
目录
Quick Start
快速开始
bash
undefinedbash
undefinedGenerate architecture diagram from project
从项目生成架构图
python scripts/architecture_diagram_generator.py ./my-project --format mermaid
python scripts/architecture_diagram_generator.py ./my-project --format mermaid
Analyze dependencies for issues
分析依赖问题
python scripts/dependency_analyzer.py ./my-project --output json
python scripts/dependency_analyzer.py ./my-project --output json
Get architecture assessment
获取架构评估
python scripts/project_architect.py ./my-project --verbose
---python scripts/project_architect.py ./my-project --verbose
---Tools Overview
工具概览
1. Architecture Diagram Generator
1. 架构图生成器
Generates architecture diagrams from project structure in multiple formats.
Solves: "I need to visualize my system architecture for documentation or team discussion"
Input: Project directory path
Output: Diagram code (Mermaid, PlantUML, or ASCII)
Supported diagram types:
- - Shows modules and their relationships
component - - Shows architectural layers (presentation, business, data)
layer - - Shows deployment topology
deployment
Usage:
bash
undefined从项目结构生成多种格式的架构图。
解决问题: "我需要将系统架构可视化,用于文档编写或团队讨论"
输入: 项目目录路径
输出: 图代码(Mermaid、PlantUML或ASCII格式)
支持的图类型:
- - 展示模块及其关系
component - - 展示架构分层(表现层、业务层、数据层)
layer - - 展示部署拓扑
deployment
使用方式:
bash
undefinedMermaid format (default)
Mermaid格式(默认)
python scripts/architecture_diagram_generator.py ./project --format mermaid --type component
python scripts/architecture_diagram_generator.py ./project --format mermaid --type component
PlantUML format
PlantUML格式
python scripts/architecture_diagram_generator.py ./project --format plantuml --type layer
python scripts/architecture_diagram_generator.py ./project --format plantuml --type layer
ASCII format (terminal-friendly)
ASCII格式(终端友好型)
python scripts/architecture_diagram_generator.py ./project --format ascii
python scripts/architecture_diagram_generator.py ./project --format ascii
Save to file
保存到文件
python scripts/architecture_diagram_generator.py ./project -o architecture.md
**Example output (Mermaid):**
```mermaid
graph TD
A[API Gateway] --> B[Auth Service]
A --> C[User Service]
B --> D[(PostgreSQL)]
C --> Dpython scripts/architecture_diagram_generator.py ./project -o architecture.md
**示例输出(Mermaid格式):**
```mermaid
graph TD
A[API Gateway] --> B[Auth Service]
A --> C[User Service]
B --> D[(PostgreSQL)]
C --> D2. Dependency Analyzer
2. 依赖分析器
Analyzes project dependencies for coupling, circular dependencies, and outdated packages.
Solves: "I need to understand my dependency tree and identify potential issues"
Input: Project directory path
Output: Analysis report (JSON or human-readable)
Analyzes:
- Dependency tree (direct and transitive)
- Circular dependencies between modules
- Coupling score (0-100)
- Outdated packages
Supported package managers:
- npm/yarn ()
package.json - Python (,
requirements.txt)pyproject.toml - Go ()
go.mod - Rust ()
Cargo.toml
Usage:
bash
undefined分析项目依赖,检查耦合度、循环依赖和过时包。
解决问题: "我需要了解依赖树并识别潜在问题"
输入: 项目目录路径
输出: 分析报告(JSON格式或易读格式)
分析内容:
- 依赖树(直接依赖与传递依赖)
- 模块间的循环依赖
- 耦合度评分(0-100)
- 过时包
支持的包管理器:
- npm/yarn ()
package.json - Python (,
requirements.txt)pyproject.toml - Go ()
go.mod - Rust ()
Cargo.toml
使用方式:
bash
undefinedHuman-readable report
易读格式报告
python scripts/dependency_analyzer.py ./project
python scripts/dependency_analyzer.py ./project
JSON output for CI/CD integration
JSON格式输出,用于CI/CD集成
python scripts/dependency_analyzer.py ./project --output json
python scripts/dependency_analyzer.py ./project --output json
Check only for circular dependencies
仅检查循环依赖
python scripts/dependency_analyzer.py ./project --check circular
python scripts/dependency_analyzer.py ./project --check circular
Verbose mode with recommendations
详细模式,包含建议
python scripts/dependency_analyzer.py ./project --verbose
**Example output:**Dependency Analysis Report
Total dependencies: 47 (32 direct, 15 transitive)
Coupling score: 72/100 (moderate)
Issues found:
- CIRCULAR: auth → user → permissions → auth
- OUTDATED: lodash 4.17.15 → 4.17.21 (security)
Recommendations:
- Extract shared interface to break circular dependency
- Update lodash to fix CVE-2020-8203
---python scripts/dependency_analyzer.py ./project --verbose
**示例输出:**依赖分析报告
总依赖数:47(32个直接依赖,15个传递依赖)
耦合度评分:72/100(中等)
发现的问题:
- 循环依赖:auth → user → permissions → auth
- 过时包:lodash 4.17.15 → 4.17.21(存在安全问题)
建议:
- 提取共享接口以打破循环依赖
- 更新lodash以修复CVE-2020-8203漏洞
---3. Project Architect
3. 项目架构师
Analyzes project structure and detects architectural patterns, code smells, and improvement opportunities.
Solves: "I want to understand the current architecture and identify areas for improvement"
Input: Project directory path
Output: Architecture assessment report
Detects:
- Architectural patterns (MVC, layered, hexagonal, microservices indicators)
- Code organization issues (god classes, mixed concerns)
- Layer violations
- Missing architectural components
Usage:
bash
undefined分析项目结构,检测架构模式、代码异味和改进空间。
解决问题: "我想了解当前架构并找出可改进的领域"
输入: 项目目录路径
输出: 架构评估报告
检测内容:
- 架构模式(MVC、分层架构、六边形架构、微服务特征)
- 代码组织问题(上帝类、关注点混杂)
- 分层违规
- 缺失的架构组件
使用方式:
bash
undefinedFull assessment
完整评估
python scripts/project_architect.py ./project
python scripts/project_architect.py ./project
Verbose with detailed recommendations
详细模式,包含具体建议
python scripts/project_architect.py ./project --verbose
python scripts/project_architect.py ./project --verbose
JSON output
JSON格式输出
python scripts/project_architect.py ./project --output json
python scripts/project_architect.py ./project --output json
Check specific aspect
检查特定方面
python scripts/project_architect.py ./project --check layers
**Example output:**Architecture Assessment
Detected pattern: Layered Architecture (confidence: 85%)
Structure analysis:
✓ controllers/ - Presentation layer detected
✓ services/ - Business logic layer detected
✓ repositories/ - Data access layer detected
⚠ models/ - Mixed domain and DTOs
Issues:
- LARGE FILE: UserService.ts (1,847 lines) - consider splitting
- MIXED CONCERNS: PaymentController contains business logic
Recommendations:
- Split UserService into focused services
- Move business logic from controllers to services
- Separate domain models from DTOs
---python scripts/project_architect.py ./project --check layers
**示例输出:**架构评估
检测到的模式:分层架构(置信度:85%)
结构分析:
✓ controllers/ - 检测到表现层
✓ services/ - 检测到业务逻辑层
✓ repositories/ - 检测到数据访问层
⚠ models/ - 领域模型与DTO混杂
问题:
- 大文件:UserService.ts(1847行)- 建议拆分
- 关注点混杂:PaymentController包含业务逻辑
建议:
- 将UserService拆分为多个专注的服务
- 将控制器中的业务逻辑迁移至服务层
- 将领域模型与DTO分离
---Decision Workflows
决策流程
Database Selection Workflow
数据库选型流程
Use when choosing a database for a new project or migrating existing data.
Step 1: Identify data characteristics
| Characteristic | Points to SQL | Points to NoSQL |
|---|---|---|
| Structured with relationships | ✓ | |
| ACID transactions required | ✓ | |
| Flexible/evolving schema | ✓ | |
| Document-oriented data | ✓ | |
| Time-series data | ✓ (specialized) |
Step 2: Evaluate scale requirements
- <1M records, single region → PostgreSQL or MySQL
- 1M-100M records, read-heavy → PostgreSQL with read replicas
-
100M records, global distribution → CockroachDB, Spanner, or DynamoDB
- High write throughput (>10K/sec) → Cassandra or ScyllaDB
Step 3: Check consistency requirements
- Strong consistency required → SQL or CockroachDB
- Eventual consistency acceptable → DynamoDB, Cassandra, MongoDB
Step 4: Document decision
Create an ADR (Architecture Decision Record) with:
- Context and requirements
- Options considered
- Decision and rationale
- Trade-offs accepted
Quick reference:
PostgreSQL → Default choice for most applications
MongoDB → Document store, flexible schema
Redis → Caching, sessions, real-time features
DynamoDB → Serverless, auto-scaling, AWS-native
TimescaleDB → Time-series data with SQL interface在为新项目选择数据库或迁移现有数据时使用。
步骤1:识别数据特征
| 特征 | 倾向SQL | 倾向NoSQL |
|---|---|---|
| 结构化且存在关联关系 | ✓ | |
| 需要ACID事务 | ✓ | |
| 灵活/演进式 schema | ✓ | |
| 面向文档的数据 | ✓ | |
| 时序数据 | ✓(专用型) |
步骤2:评估规模需求
- <100万条记录,单区域 → PostgreSQL或MySQL
- 100万-1亿条记录,读密集型 → 带只读副本的PostgreSQL
-
1亿条记录,全球分布 → CockroachDB、Spanner或DynamoDB
- 高写入吞吐量(>1万次/秒) → Cassandra或ScyllaDB
步骤3:检查一致性需求
- 需要强一致性 → SQL或CockroachDB
- 可接受最终一致性 → DynamoDB、Cassandra、MongoDB
步骤4:记录决策
创建架构决策记录(ADR),包含:
- 背景与需求
- 考虑的选项
- 决策与理由
- 已接受的权衡
快速参考:
PostgreSQL → 大多数应用的默认选择
MongoDB → 文档存储,灵活schema
Redis → 缓存、会话、实时功能
DynamoDB → 无服务器、自动扩缩容、AWS原生
TimescaleDB → 带SQL接口的时序数据存储Architecture Pattern Selection Workflow
架构模式选择流程
Use when designing a new system or refactoring existing architecture.
Step 1: Assess team and project size
| Team Size | Recommended Starting Point |
|---|---|
| 1-3 developers | Modular monolith |
| 4-10 developers | Modular monolith or service-oriented |
| 10+ developers | Consider microservices |
Step 2: Evaluate deployment requirements
- Single deployment unit acceptable → Monolith
- Independent scaling needed → Microservices
- Mixed (some services scale differently) → Hybrid
Step 3: Consider data boundaries
- Shared database acceptable → Monolith or modular monolith
- Strict data isolation required → Microservices with separate DBs
- Event-driven communication fits → Event-sourcing/CQRS
Step 4: Match pattern to requirements
| Requirement | Recommended Pattern |
|---|---|
| Rapid MVP development | Modular Monolith |
| Independent team deployment | Microservices |
| Complex domain logic | Domain-Driven Design |
| High read/write ratio difference | CQRS |
| Audit trail required | Event Sourcing |
| Third-party integrations | Hexagonal/Ports & Adapters |
See for detailed pattern descriptions.
references/architecture_patterns.md在设计新系统或重构现有架构时使用。
步骤1:评估团队与项目规模
| 团队规模 | 推荐起始方案 |
|---|---|
| 1-3名开发者 | 模块化单体架构 |
| 4-10名开发者 | 模块化单体架构或面向服务架构 |
| 10名以上开发者 | 考虑微服务 |
步骤2:评估部署需求
- 可接受单一部署单元 → 单体架构
- 需要独立扩缩容 → 微服务
- 混合场景(部分服务扩缩容需求不同) → 混合架构
步骤3:考虑数据边界
- 可接受共享数据库 → 单体架构或模块化单体架构
- 需要严格数据隔离 → 带独立数据库的微服务
- 事件驱动通信适配 → 事件溯源/CQRS
步骤4:匹配模式与需求
| 需求 | 推荐模式 |
|---|---|
| 快速开发MVP | 模块化单体架构 |
| 团队独立部署 | 微服务 |
| 复杂领域逻辑 | 领域驱动设计 |
| 读写比差异大 | CQRS |
| 需要审计追踪 | 事件溯源 |
| 第三方集成 | 六边形架构/端口与适配器 |
查看获取模式的详细说明。
references/architecture_patterns.mdMonolith vs Microservices Decision
单体架构 vs 微服务决策
Choose Monolith when:
- Team is small (<10 developers)
- Domain boundaries are unclear
- Rapid iteration is priority
- Operational complexity must be minimized
- Shared database is acceptable
Choose Microservices when:
- Teams can own services end-to-end
- Independent deployment is critical
- Different scaling requirements per component
- Technology diversity is needed
- Domain boundaries are well understood
Hybrid approach:
Start with a modular monolith. Extract services only when:
- A module has significantly different scaling needs
- A team needs independent deployment
- Technology constraints require separation
选择单体架构的场景:
- 团队规模小(<10名开发者)
- 领域边界不清晰
- 快速迭代为优先事项
- 必须最小化运维复杂度
- 可接受共享数据库
选择微服务的场景:
- 团队可以端到端负责服务
- 独立部署至关重要
- 各组件扩缩容需求不同
- 需要技术多样性
- 领域边界清晰
混合方案:
从模块化单体架构开始。仅在以下情况时拆分服务:
- 某个模块的扩缩容需求与其他模块差异显著
- 团队需要独立部署权限
- 技术限制要求拆分
Reference Documentation
参考文档
Load these files for detailed information:
| File | Contains | Load when user asks about |
|---|---|---|
| 9 architecture patterns with trade-offs, code examples, and when to use | "which pattern?", "microservices vs monolith", "event-driven", "CQRS" |
| 6 step-by-step workflows for system design tasks | "how to design?", "capacity planning", "API design", "migration" |
| Decision matrices for technology choices | "which database?", "which framework?", "which cloud?", "which cache?" |
加载以下文件获取详细信息:
| 文件 | 包含内容 | 用户询问以下内容时加载 |
|---|---|---|
| 9种架构模式,包含权衡、代码示例及适用场景 | "哪种模式?"、"微服务 vs 单体架构"、"事件驱动"、"CQRS" |
| 6个系统设计任务的分步流程 | "如何设计?"、"容量规划"、"API设计"、"迁移" |
| 技术选型决策矩阵 | "哪种数据库?"、"哪种框架?"、"哪种云?"、"哪种缓存?" |
Tech Stack Coverage
技术栈覆盖
Languages: TypeScript, JavaScript, Python, Go, Swift, Kotlin, Rust
Frontend: React, Next.js, Vue, Angular, React Native, Flutter
Backend: Node.js, Express, FastAPI, Go, GraphQL, REST
Databases: PostgreSQL, MySQL, MongoDB, Redis, DynamoDB, Cassandra
Infrastructure: Docker, Kubernetes, Terraform, AWS, GCP, Azure
CI/CD: GitHub Actions, GitLab CI, CircleCI, Jenkins
语言: TypeScript、JavaScript、Python、Go、Swift、Kotlin、Rust
前端: React、Next.js、Vue、Angular、React Native、Flutter
后端: Node.js、Express、FastAPI、Go、GraphQL、REST
数据库: PostgreSQL、MySQL、MongoDB、Redis、DynamoDB、Cassandra
基础设施: Docker、Kubernetes、Terraform、AWS、GCP、Azure
CI/CD: GitHub Actions、GitLab CI、CircleCI、Jenkins
Common Commands
常用命令
bash
undefinedbash
undefinedArchitecture visualization
架构可视化
python scripts/architecture_diagram_generator.py . --format mermaid
python scripts/architecture_diagram_generator.py . --format plantuml
python scripts/architecture_diagram_generator.py . --format ascii
python scripts/architecture_diagram_generator.py . --format mermaid
python scripts/architecture_diagram_generator.py . --format plantuml
python scripts/architecture_diagram_generator.py . --format ascii
Dependency analysis
依赖分析
python scripts/dependency_analyzer.py . --verbose
python scripts/dependency_analyzer.py . --check circular
python scripts/dependency_analyzer.py . --output json
python scripts/dependency_analyzer.py . --verbose
python scripts/dependency_analyzer.py . --check circular
python scripts/dependency_analyzer.py . --output json
Architecture assessment
架构评估
python scripts/project_architect.py . --verbose
python scripts/project_architect.py . --check layers
python scripts/project_architect.py . --output json
---python scripts/project_architect.py . --verbose
python scripts/project_architect.py . --check layers
python scripts/project_architect.py . --output json
---Getting Help
获取帮助
- Run any script with for usage information
--help - Check reference documentation for detailed patterns and workflows
- Use flag for detailed explanations and recommendations
--verbose
- 运行任意脚本时添加参数查看使用说明
--help - 查看参考文档获取模式与流程的详细信息
- 使用参数获取详细解释与建议
--verbose