← スキル一覧に戻る

patterns
by chandima
⭐ 0🍴 0📅 2026年1月21日
SKILL.md
name: patterns description: System design and architecture patterns. Covers layered architecture, clean architecture, microservices vs monolith decisions, event-driven patterns, and trade-off analysis frameworks.
Architecture Patterns
System design patterns and frameworks for building scalable, maintainable software.
Core Principles
- Simplicity First - Simplest solution that meets requirements. Avoid speculative generality.
- Separation of Concerns - Single, well-defined responsibility per component.
- Design for Failure - Graceful degradation, error handling, observability.
- Make It Testable - DI, clear interfaces, pure functions.
- Evolve, Don't Revolution - Incremental over big-bang. Strangler pattern.
Trade-off Analysis Framework
| Factor | Questions |
|---|---|
| Complexity | How much does this add? Is it justified? |
| Scalability | Will this work at 10x, 100x scale? |
| Maintainability | Can new developers understand this? |
| Performance | What are latency/throughput characteristics? |
| Cost | Infrastructure and development costs? |
| Risk | What could go wrong? How to mitigate? |
| Time | Implementation time? Opportunity cost? |
Layered Architecture
┌─────────────────────────────────┐
│ Presentation │ ← UI, API endpoints
├─────────────────────────────────┤
│ Application │ ← Use cases, orchestration
├─────────────────────────────────┤
│ Domain │ ← Business logic, entities
├─────────────────────────────────┤
│ Infrastructure │ ← Database, external services
└─────────────────────────────────┘
Key Rule: Dependencies flow downward. Lower layers don't know about upper layers.
Clean Architecture
┌─────────────────┐
│ Entities │ ← Enterprise business rules
├─────────────────┤
│ Use Cases │ ← Application business rules
├─────────────────┤
│ Adapters │ ← Controllers, gateways
├─────────────────┤
│ Frameworks │ ← DB, web, external
└─────────────────┘
Dependencies point INWARD →
Principles:
- Domain at center, no external dependencies
- Use cases orchestrate domain logic
- Adapters connect to external world
- Dependency inversion via interfaces
Microservices vs Monolith
| Monolith | Microservices |
|---|---|
| Simple deployment | Independent scaling |
| Easy debugging | Technology diversity |
| Shared database | Service isolation |
| Team coordination | Team autonomy |
| Lower latency (in-process) | Network overhead |
| Start here | Evolve to this |
Decision Guide
Stay Monolith When:
- Team < 10 developers
- Domain not well understood
- Scaling needs are uniform
- Debugging/tracing complexity matters
Consider Microservices When:
- Independent scaling requirements
- Different tech stacks needed
- Team autonomy is priority
- Domain boundaries are clear
Event-Driven Architecture
When to Use
- Loose coupling between services
- Eventual consistency acceptable
- Need audit trail / event sourcing
- Complex workflows across services
Patterns
| Pattern | Use Case |
|---|---|
| Event Notification | "Something happened" - fire and forget |
| Event-Carried State | Include data, reduce queries |
| Event Sourcing | Audit trail, replay capability |
| CQRS | Separate read/write models |
API Design Patterns
REST Resource Design
GET /users # List
POST /users # Create
GET /users/:id # Read
PUT /users/:id # Replace
PATCH /users/:id # Partial update
DELETE /users/:id # Delete
Versioning Strategies
| Strategy | Example | Pros/Cons |
|---|---|---|
| URL path | /v1/users | Clear, easy routing |
| Header | Accept: application/vnd.api+json;v=1 | Cleaner URLs, harder discovery |
| Query param | ?version=1 | Simple, but ugly |
Caching Patterns
| Pattern | Description | Use Case |
|---|---|---|
| Cache-Aside | App manages cache explicitly | General purpose |
| Read-Through | Cache handles miss automatically | Simplified app logic |
| Write-Through | Write to cache and DB synchronously | Consistency critical |
| Write-Behind | Write to cache, async to DB | High write throughput |
Cache Levels
- Browser/Client - HTTP caching headers
- CDN/Edge - Static assets, public API
- Application - Redis, Memcached
- Database - Query cache, materialized views
Database Patterns
Choosing a Database
| Type | Best For | Examples |
|---|---|---|
| Relational | Transactions, complex queries | PostgreSQL, MySQL |
| Document | Flexible schema, JSON | MongoDB, CouchDB |
| Key-Value | Caching, sessions | Redis, DynamoDB |
| Graph | Relationships | Neo4j, Neptune |
| Time-Series | Metrics, logs | InfluxDB, TimescaleDB |
Scaling Patterns
- Read Replicas - Scale reads, async replication
- Sharding - Horizontal partitioning by key
- CQRS - Separate read/write stores
Analysis Framework
Evaluating Existing Architecture
- Current State - Structure, pain points, tech debt
- Requirements - Functional + non-functional (scalability, latency)
- Gap Analysis - Where current falls short
- Recommendations - Prioritized, with trade-offs
Designing New Systems
- Understand Problem - Users, use cases, success metrics
- Define Constraints - Technical, business, team
- Explore Options - Multiple approaches, trade-offs
- Document Decision - ADR, diagrams, guidelines
Architecture Decision Record (ADR)
# ADR-001: [Title]
## Status
[Proposed | Accepted | Deprecated | Superseded]
## Context
[What problem are we solving? What constraints?]
## Decision
[What we decided to do]
## Consequences
[What are the results? Positive and negative]
Anti-Patterns
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Big Ball of Mud | No structure | Introduce boundaries gradually |
| Golden Hammer | One solution for everything | Right tool for the job |
| Premature Optimization | Complexity without need | Measure first, optimize second |
| Distributed Monolith | Microservices without benefits | Define clear boundaries |
| Anemic Domain Model | Logic in services, not entities | Rich domain objects |
スコア
総合スコア
45/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
○言語
プログラミング言語が設定されている
0/5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です