@defai.digital/automatosx 12.8.7 → 13.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/bin.d.ts +8 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +16 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -74239
- package/dist/index.js.map +1 -0
- package/package.json +35 -160
- package/.github/assets/ax-cli.png +0 -0
- package/.github/assets/axlogo.png +0 -0
- package/CHANGELOG.md +0 -81
- package/README.md +0 -790
- package/SECURITY.md +0 -173
- package/dist/mcp/index.d.ts +0 -2
- package/dist/mcp/index.js +0 -43627
- package/examples/AGENTS_INFO.md +0 -187
- package/examples/README.md +0 -434
- package/examples/abilities/accessibility.md +0 -115
- package/examples/abilities/api-design.md +0 -168
- package/examples/abilities/best-practices.md +0 -102
- package/examples/abilities/caching-strategy.md +0 -165
- package/examples/abilities/ci-cd.md +0 -61
- package/examples/abilities/clean-code.md +0 -398
- package/examples/abilities/code-generation.md +0 -333
- package/examples/abilities/code-review.md +0 -51
- package/examples/abilities/component-architecture.md +0 -112
- package/examples/abilities/content-creation.md +0 -97
- package/examples/abilities/data-modeling.md +0 -171
- package/examples/abilities/data-validation.md +0 -50
- package/examples/abilities/db-modeling.md +0 -167
- package/examples/abilities/debugging.md +0 -52
- package/examples/abilities/design-patterns.md +0 -437
- package/examples/abilities/design-system-implementation.md +0 -126
- package/examples/abilities/documentation.md +0 -54
- package/examples/abilities/etl-pipelines.md +0 -44
- package/examples/abilities/feasibility-study.md +0 -20
- package/examples/abilities/general-assistance.md +0 -26
- package/examples/abilities/idea-evaluation.md +0 -21
- package/examples/abilities/infra-as-code.md +0 -57
- package/examples/abilities/job-orchestration.md +0 -44
- package/examples/abilities/literature-review.md +0 -19
- package/examples/abilities/longform-report.md +0 -25
- package/examples/abilities/mathematical-reasoning.md +0 -170
- package/examples/abilities/observability.md +0 -61
- package/examples/abilities/orbital-mechanics.md +0 -50
- package/examples/abilities/our-architecture-decisions.md +0 -180
- package/examples/abilities/our-code-review-checklist.md +0 -149
- package/examples/abilities/our-coding-standards.md +0 -369
- package/examples/abilities/our-project-structure.md +0 -183
- package/examples/abilities/performance.md +0 -89
- package/examples/abilities/problem-solving.md +0 -50
- package/examples/abilities/propulsion-systems.md +0 -50
- package/examples/abilities/quantum-algorithm-design.md +0 -54
- package/examples/abilities/quantum-error-correction.md +0 -56
- package/examples/abilities/quantum-frameworks-transpilation.md +0 -53
- package/examples/abilities/quantum-noise-modeling.md +0 -58
- package/examples/abilities/refactoring.md +0 -223
- package/examples/abilities/release-strategy.md +0 -58
- package/examples/abilities/secrets-policy.md +0 -61
- package/examples/abilities/secure-coding-review.md +0 -60
- package/examples/abilities/software-architecture.md +0 -394
- package/examples/abilities/solid-principles.md +0 -341
- package/examples/abilities/sql-optimization.md +0 -84
- package/examples/abilities/state-management.md +0 -96
- package/examples/abilities/task-planning.md +0 -65
- package/examples/abilities/technical-writing.md +0 -77
- package/examples/abilities/telemetry-diagnostics.md +0 -51
- package/examples/abilities/testing.md +0 -56
- package/examples/abilities/threat-modeling.md +0 -58
- package/examples/abilities/troubleshooting.md +0 -80
- package/examples/abilities/typescript-zod-validation.md +0 -830
- package/examples/agents/AGENTS_INTEGRATION.md +0 -99
- package/examples/agents/aerospace-scientist.yaml +0 -159
- package/examples/agents/architecture.yaml +0 -244
- package/examples/agents/automatosx.config.json +0 -286
- package/examples/agents/backend.yaml +0 -141
- package/examples/agents/ceo.yaml +0 -105
- package/examples/agents/creative-marketer.yaml +0 -173
- package/examples/agents/cto.yaml +0 -118
- package/examples/agents/data-scientist.yaml +0 -200
- package/examples/agents/data.yaml +0 -106
- package/examples/agents/design.yaml +0 -115
- package/examples/agents/devops.yaml +0 -124
- package/examples/agents/frontend.yaml +0 -171
- package/examples/agents/fullstack.yaml +0 -172
- package/examples/agents/mobile.yaml +0 -185
- package/examples/agents/product.yaml +0 -103
- package/examples/agents/quality.yaml +0 -117
- package/examples/agents/quantum-engineer.yaml +0 -166
- package/examples/agents/researcher.yaml +0 -122
- package/examples/agents/security.yaml +0 -115
- package/examples/agents/standard.yaml +0 -214
- package/examples/agents/writer.yaml +0 -122
- package/examples/providers/README.md +0 -117
- package/examples/providers/claude/CLAUDE_INTEGRATION.md +0 -302
- package/examples/providers/claude/mcp/automatosx.json +0 -244
- package/examples/providers/codex/CODEX_INTEGRATION.md +0 -593
- package/examples/providers/codex/README.md +0 -349
- package/examples/providers/codex/usage-examples.ts +0 -421
- package/examples/providers/gemini/GEMINI_INTEGRATION.md +0 -236
- package/examples/providers/gemini/README.md +0 -76
- package/examples/providers/openai-codex-example.ts +0 -421
- package/examples/pytorch_resnet50_training.py +0 -289
- package/examples/specs/automatosx-release.ax.yaml +0 -380
- package/examples/specs/enterprise.ax.yaml +0 -121
- package/examples/specs/enterprise.yaml.mustache +0 -121
- package/examples/specs/government.ax.yaml +0 -148
- package/examples/specs/government.yaml.mustache +0 -148
- package/examples/specs/minimal.ax.yaml +0 -21
- package/examples/specs/minimal.yaml.mustache +0 -21
- package/examples/teams/business.yaml +0 -56
- package/examples/teams/core.yaml +0 -60
- package/examples/teams/design.yaml +0 -58
- package/examples/teams/engineering.yaml +0 -69
- package/examples/teams/research.yaml +0 -56
- package/examples/use-cases/01-web-app-development.md +0 -374
- package/examples/workflows/analyst.yaml +0 -60
- package/examples/workflows/assistant.yaml +0 -48
- package/examples/workflows/basic-agent.yaml +0 -28
- package/examples/workflows/code-reviewer.yaml +0 -52
- package/examples/workflows/debugger.yaml +0 -63
- package/examples/workflows/designer.yaml +0 -69
- package/examples/workflows/developer.yaml +0 -60
- package/examples/workflows/fullstack-developer.yaml +0 -395
- package/examples/workflows/qa-specialist.yaml +0 -71
- package/schema/ability-metadata.json +0 -21
- package/schema/config.json +0 -703
- package/schema/spec-schema.json +0 -608
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# Release Strategy
|
|
2
|
-
|
|
3
|
-
Plan and execute safe, controlled software releases. Use deployment patterns that minimize risk and enable quick rollback.
|
|
4
|
-
|
|
5
|
-
## Deployment Patterns
|
|
6
|
-
|
|
7
|
-
### 1. Blue-Green Deployment
|
|
8
|
-
```bash
|
|
9
|
-
# ✅ Switch traffic instantly
|
|
10
|
-
kubectl apply -f deployment-green.yaml
|
|
11
|
-
curl http://green.example.com/health
|
|
12
|
-
kubectl patch service app -p '{"spec":{"selector":{"version":"green"}}}'
|
|
13
|
-
# Rollback if needed: switch back to blue
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
### 2. Canary Deployment
|
|
17
|
-
```yaml
|
|
18
|
-
# ✅ Good: Gradual rollout (10% canary, 90% stable)
|
|
19
|
-
apiVersion: apps/v1
|
|
20
|
-
kind: Deployment
|
|
21
|
-
metadata:
|
|
22
|
-
name: app-stable
|
|
23
|
-
spec:
|
|
24
|
-
replicas: 9
|
|
25
|
-
---
|
|
26
|
-
apiVersion: apps/v1
|
|
27
|
-
kind: Deployment
|
|
28
|
-
metadata:
|
|
29
|
-
name: app-canary
|
|
30
|
-
spec:
|
|
31
|
-
replicas: 1
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### 3. Feature Flags
|
|
35
|
-
```javascript
|
|
36
|
-
// ✅ Good: Gradual feature rollout
|
|
37
|
-
if (featureFlags.isEnabled('new-checkout', user.id)) {
|
|
38
|
-
return <NewCheckout />;
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Don'ts ❌
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
# ❌ Bad: Big bang release on Friday
|
|
46
|
-
./deploy-all-changes.sh
|
|
47
|
-
# Go home, hope for best
|
|
48
|
-
|
|
49
|
-
# ❌ Bad: No rollback plan
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Best Practices
|
|
53
|
-
- Release during low-traffic periods
|
|
54
|
-
- Have documented rollback procedure
|
|
55
|
-
- Use feature flags for risky changes
|
|
56
|
-
- Monitor key metrics during/after release
|
|
57
|
-
- Automate deployment process
|
|
58
|
-
- Document release notes
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# Secrets Management Policy
|
|
2
|
-
|
|
3
|
-
Securely store, rotate, and access secrets (API keys, passwords, certificates). Never commit secrets to version control.
|
|
4
|
-
|
|
5
|
-
## Do's ✅
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# ✅ Good: Environment variables
|
|
9
|
-
export DATABASE_URL="postgresql://user:password@localhost/db"
|
|
10
|
-
export API_KEY="sk_live_abc123"
|
|
11
|
-
|
|
12
|
-
# Access in code
|
|
13
|
-
const dbUrl = process.env.DATABASE_URL;
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
```javascript
|
|
17
|
-
// ✅ Good: AWS Secrets Manager
|
|
18
|
-
const AWS = require('aws-sdk');
|
|
19
|
-
const client = new AWS.SecretsManager({ region: 'us-east-1' });
|
|
20
|
-
|
|
21
|
-
async function getSecret(name) {
|
|
22
|
-
const data = await client.getSecretValue({ SecretId: name }).promise();
|
|
23
|
-
return JSON.parse(data.SecretString);
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
# ✅ Good: .gitignore secrets
|
|
29
|
-
.env
|
|
30
|
-
.env.local
|
|
31
|
-
secrets/
|
|
32
|
-
*.pem
|
|
33
|
-
*.key
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Don'ts ❌
|
|
37
|
-
|
|
38
|
-
```javascript
|
|
39
|
-
// ❌ Bad: Hardcoded secrets
|
|
40
|
-
const API_KEY = "sk_live_abc123xyz";
|
|
41
|
-
const DB_PASSWORD = "SuperSecret123!";
|
|
42
|
-
|
|
43
|
-
// ❌ Bad: Logging secrets
|
|
44
|
-
logger.info('DB connection', { password: dbPassword });
|
|
45
|
-
|
|
46
|
-
// ❌ Bad: Secrets in URLs
|
|
47
|
-
fetch(`https://api.com/data?api_key=${apiKey}`);
|
|
48
|
-
// ✅ Good: In headers
|
|
49
|
-
fetch('https://api.com/data', {
|
|
50
|
-
headers: { 'Authorization': `Bearer ${apiKey}` }
|
|
51
|
-
});
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Best Practices
|
|
55
|
-
- Never commit secrets to git
|
|
56
|
-
- Use secret management tools (Vault, AWS Secrets Manager)
|
|
57
|
-
- Rotate secrets regularly (90 days)
|
|
58
|
-
- Different secrets for dev/staging/prod
|
|
59
|
-
- Audit secret access
|
|
60
|
-
- Encrypt at rest and in transit
|
|
61
|
-
- Use pre-commit hooks (detect-secrets)
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# Secure Coding Review
|
|
2
|
-
|
|
3
|
-
Review code for security vulnerabilities using OWASP Top 10 and secure coding standards. Identify and fix flaws before production.
|
|
4
|
-
|
|
5
|
-
## OWASP Top 10 Examples
|
|
6
|
-
|
|
7
|
-
### A01: Broken Access Control
|
|
8
|
-
```javascript
|
|
9
|
-
// ❌ Bad: No authorization
|
|
10
|
-
app.get('/api/users/:id/orders', async (req, res) => {
|
|
11
|
-
const orders = await db.getOrders(req.params.id);
|
|
12
|
-
res.json(orders); // Any user can view any orders!
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// ✅ Good: Verify ownership
|
|
16
|
-
app.get('/api/users/:id/orders', auth, async (req, res) => {
|
|
17
|
-
if (req.user.id !== parseInt(req.params.id)) {
|
|
18
|
-
return res.status(403).json({ error: 'Forbidden' });
|
|
19
|
-
}
|
|
20
|
-
const orders = await db.getOrders(req.params.id);
|
|
21
|
-
res.json(orders);
|
|
22
|
-
});
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### A02: Cryptographic Failures
|
|
26
|
-
```javascript
|
|
27
|
-
// ❌ Bad: Weak hashing
|
|
28
|
-
const hash = crypto.createHash('md5').update(password).digest('hex');
|
|
29
|
-
|
|
30
|
-
// ✅ Good: Strong hashing
|
|
31
|
-
const hash = await bcrypt.hash(password, 12);
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### A03: Injection
|
|
35
|
-
```javascript
|
|
36
|
-
// ❌ Bad: SQL Injection
|
|
37
|
-
const query = `SELECT * FROM users WHERE email = '${email}'`;
|
|
38
|
-
|
|
39
|
-
// ✅ Good: Parameterized query
|
|
40
|
-
const query = 'SELECT * FROM users WHERE email = ?';
|
|
41
|
-
const results = await db.query(query, [email]);
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Review Checklist
|
|
45
|
-
- ✅ MFA for sensitive actions
|
|
46
|
-
- ✅ Authorization checks on all endpoints
|
|
47
|
-
- ✅ Input validation and sanitization
|
|
48
|
-
- ✅ Parameterized queries
|
|
49
|
-
- ✅ Secrets not hardcoded
|
|
50
|
-
- ✅ TLS 1.2+ required
|
|
51
|
-
- ✅ No sensitive data in logs
|
|
52
|
-
|
|
53
|
-
## Application Hints
|
|
54
|
-
|
|
55
|
-
When reviewing for security:
|
|
56
|
-
- Check authorization on every endpoint; authentication alone is not sufficient
|
|
57
|
-
- Verify parameterized queries for all database operations, including ORMs
|
|
58
|
-
- Ensure secrets are never hardcoded; check for API keys in config files and env vars
|
|
59
|
-
- Validate all user input at trust boundaries, not deep in business logic
|
|
60
|
-
- Review logging to ensure no PII, tokens, or credentials are exposed
|
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
# Software Architecture Ability
|
|
2
|
-
|
|
3
|
-
Expert knowledge of software architecture patterns, principles, and system design for building scalable, maintainable applications.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Software architecture is the fundamental organization of a system, embodied in its components, their relationships, and the principles governing its design and evolution.
|
|
8
|
-
|
|
9
|
-
## Architectural Principles
|
|
10
|
-
|
|
11
|
-
### 1. Separation of Concerns
|
|
12
|
-
|
|
13
|
-
Divide application into distinct sections, each addressing a separate concern.
|
|
14
|
-
|
|
15
|
-
**Benefits**:
|
|
16
|
-
- Easier to understand and maintain
|
|
17
|
-
- Enables parallel development
|
|
18
|
-
- Facilitates testing and reuse
|
|
19
|
-
|
|
20
|
-
**Examples**:
|
|
21
|
-
- Presentation vs. Business Logic vs. Data Access
|
|
22
|
-
- Read models vs. Write models (CQRS)
|
|
23
|
-
- Frontend vs. Backend
|
|
24
|
-
|
|
25
|
-
### 2. Modularity and Encapsulation
|
|
26
|
-
|
|
27
|
-
Break system into independent, interchangeable modules with well-defined interfaces.
|
|
28
|
-
|
|
29
|
-
**Principles**:
|
|
30
|
-
- High cohesion: Related functionality together
|
|
31
|
-
- Low coupling: Minimal dependencies between modules
|
|
32
|
-
- Information hiding: Internal implementation details hidden
|
|
33
|
-
|
|
34
|
-
### 3. Abstraction
|
|
35
|
-
|
|
36
|
-
Hide complexity behind simpler interfaces.
|
|
37
|
-
|
|
38
|
-
**Levels**:
|
|
39
|
-
- Hardware → Operating System
|
|
40
|
-
- Operating System → Runtime
|
|
41
|
-
- Runtime → Framework
|
|
42
|
-
- Framework → Application
|
|
43
|
-
|
|
44
|
-
### 4. Layering
|
|
45
|
-
|
|
46
|
-
Organize system into horizontal layers with clear responsibilities.
|
|
47
|
-
|
|
48
|
-
**Rules**:
|
|
49
|
-
- Each layer depends only on layers below
|
|
50
|
-
- Higher layers use services of lower layers
|
|
51
|
-
- No circular dependencies
|
|
52
|
-
|
|
53
|
-
### 5. Don't Repeat Yourself (DRY)
|
|
54
|
-
|
|
55
|
-
Every piece of knowledge should have a single authoritative representation.
|
|
56
|
-
|
|
57
|
-
### 6. YAGNI (You Aren't Gonna Need It)
|
|
58
|
-
|
|
59
|
-
Don't add functionality until it's necessary.
|
|
60
|
-
|
|
61
|
-
## Common Architectural Patterns
|
|
62
|
-
|
|
63
|
-
### Layered Architecture
|
|
64
|
-
|
|
65
|
-
**Structure**: Organized into horizontal layers
|
|
66
|
-
**Layers** (typical):
|
|
67
|
-
1. Presentation Layer (UI)
|
|
68
|
-
2. Application Layer (Use Cases)
|
|
69
|
-
3. Domain Layer (Business Logic)
|
|
70
|
-
4. Infrastructure Layer (Data Access, External Services)
|
|
71
|
-
|
|
72
|
-
**When to use**:
|
|
73
|
-
- Traditional monolithic applications
|
|
74
|
-
- Clear separation of concerns needed
|
|
75
|
-
- Team organized by technical layers
|
|
76
|
-
|
|
77
|
-
**Pros**:
|
|
78
|
-
- Simple and well-understood
|
|
79
|
-
- Clear separation of concerns
|
|
80
|
-
- Easy to test layers independently
|
|
81
|
-
|
|
82
|
-
**Cons**:
|
|
83
|
-
- Can become tightly coupled
|
|
84
|
-
- Changes may ripple through layers
|
|
85
|
-
- Scalability limitations
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
┌─────────────────────────────┐
|
|
89
|
-
│ Presentation Layer │
|
|
90
|
-
├─────────────────────────────┤
|
|
91
|
-
│ Application Layer │
|
|
92
|
-
├─────────────────────────────┤
|
|
93
|
-
│ Domain Layer │
|
|
94
|
-
├─────────────────────────────┤
|
|
95
|
-
│ Infrastructure Layer │
|
|
96
|
-
└─────────────────────────────┘
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Hexagonal Architecture (Ports and Adapters)
|
|
100
|
-
|
|
101
|
-
**Structure**: Core business logic surrounded by adapters for external systems
|
|
102
|
-
|
|
103
|
-
**Components**:
|
|
104
|
-
- **Core**: Domain logic (pure, no dependencies)
|
|
105
|
-
- **Ports**: Interfaces defining how core interacts with outside
|
|
106
|
-
- **Adapters**: Implementations of ports (DB, HTTP, etc.)
|
|
107
|
-
|
|
108
|
-
**When to use**:
|
|
109
|
-
- Domain-driven design
|
|
110
|
-
- Need to swap implementations easily
|
|
111
|
-
- Comprehensive test coverage desired
|
|
112
|
-
|
|
113
|
-
**Pros**:
|
|
114
|
-
- Core is independent of frameworks
|
|
115
|
-
- Easy to test (mock adapters)
|
|
116
|
-
- Flexibility in implementation choices
|
|
117
|
-
|
|
118
|
-
**Cons**:
|
|
119
|
-
- More complex than layered
|
|
120
|
-
- Requires discipline to maintain boundaries
|
|
121
|
-
- More abstractions and interfaces
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
┌────────────────────┐
|
|
125
|
-
│ Adapters (DB, │
|
|
126
|
-
│ HTTP, etc.) │
|
|
127
|
-
└────────┬───────────┘
|
|
128
|
-
│
|
|
129
|
-
┌────────▼───────────┐
|
|
130
|
-
│ Ports │
|
|
131
|
-
│ (Interfaces) │
|
|
132
|
-
└────────┬───────────┘
|
|
133
|
-
│
|
|
134
|
-
┌────────▼───────────┐
|
|
135
|
-
│ Domain │
|
|
136
|
-
│ (Business Logic) │
|
|
137
|
-
└────────────────────┘
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Microservices Architecture
|
|
141
|
-
|
|
142
|
-
**Structure**: Application as collection of small, independent services
|
|
143
|
-
|
|
144
|
-
**Characteristics**:
|
|
145
|
-
- Each service is independently deployable
|
|
146
|
-
- Services communicate via APIs (HTTP, messaging)
|
|
147
|
-
- Each service has its own database
|
|
148
|
-
- Organized around business capabilities
|
|
149
|
-
|
|
150
|
-
**When to use**:
|
|
151
|
-
- Large, complex applications
|
|
152
|
-
- Need for independent scaling
|
|
153
|
-
- Multiple teams working independently
|
|
154
|
-
- Polyglot persistence needs
|
|
155
|
-
|
|
156
|
-
**Pros**:
|
|
157
|
-
- Independent deployment and scaling
|
|
158
|
-
- Technology diversity
|
|
159
|
-
- Fault isolation
|
|
160
|
-
- Team autonomy
|
|
161
|
-
|
|
162
|
-
**Cons**:
|
|
163
|
-
- Distributed system complexity
|
|
164
|
-
- Network latency
|
|
165
|
-
- Data consistency challenges
|
|
166
|
-
- Operational overhead
|
|
167
|
-
|
|
168
|
-
### Event-Driven Architecture
|
|
169
|
-
|
|
170
|
-
**Structure**: Components communicate through events
|
|
171
|
-
|
|
172
|
-
**Components**:
|
|
173
|
-
- **Event Producers**: Generate events
|
|
174
|
-
- **Event Channels**: Transport events
|
|
175
|
-
- **Event Consumers**: React to events
|
|
176
|
-
|
|
177
|
-
**Patterns**:
|
|
178
|
-
- Event Notification
|
|
179
|
-
- Event-Carried State Transfer
|
|
180
|
-
- Event Sourcing
|
|
181
|
-
|
|
182
|
-
**When to use**:
|
|
183
|
-
- Asynchronous processing needed
|
|
184
|
-
- Loose coupling desired
|
|
185
|
-
- Real-time updates required
|
|
186
|
-
- Complex workflows
|
|
187
|
-
|
|
188
|
-
**Pros**:
|
|
189
|
-
- Loose coupling
|
|
190
|
-
- Scalability
|
|
191
|
-
- Flexibility
|
|
192
|
-
- Asynchronous processing
|
|
193
|
-
|
|
194
|
-
**Cons**:
|
|
195
|
-
- Complexity in debugging
|
|
196
|
-
- Eventual consistency
|
|
197
|
-
- Event versioning challenges
|
|
198
|
-
|
|
199
|
-
### CQRS (Command Query Responsibility Segregation)
|
|
200
|
-
|
|
201
|
-
**Structure**: Separate models for reading and writing data
|
|
202
|
-
|
|
203
|
-
**Components**:
|
|
204
|
-
- **Command Model**: Handles writes (create, update, delete)
|
|
205
|
-
- **Query Model**: Handles reads (optimized for specific views)
|
|
206
|
-
|
|
207
|
-
**When to use**:
|
|
208
|
-
- Read and write patterns differ significantly
|
|
209
|
-
- Need to scale reads and writes independently
|
|
210
|
-
- Complex domain logic
|
|
211
|
-
- Event sourcing
|
|
212
|
-
|
|
213
|
-
**Pros**:
|
|
214
|
-
- Optimized for different access patterns
|
|
215
|
-
- Independent scaling
|
|
216
|
-
- Clear command/query separation
|
|
217
|
-
|
|
218
|
-
**Cons**:
|
|
219
|
-
- Increased complexity
|
|
220
|
-
- Eventual consistency
|
|
221
|
-
- Synchronization overhead
|
|
222
|
-
|
|
223
|
-
## Architectural Decision Making
|
|
224
|
-
|
|
225
|
-
### Architecture Trade-offs
|
|
226
|
-
|
|
227
|
-
**Performance vs. Maintainability**:
|
|
228
|
-
- Optimize critical paths
|
|
229
|
-
- Keep non-critical code clean and simple
|
|
230
|
-
|
|
231
|
-
**Flexibility vs. Simplicity**:
|
|
232
|
-
- Don't over-engineer for future needs
|
|
233
|
-
- Refactor when patterns emerge
|
|
234
|
-
|
|
235
|
-
**Consistency vs. Availability (CAP Theorem)**:
|
|
236
|
-
- Can't have all three: Consistency, Availability, Partition Tolerance
|
|
237
|
-
- Choose based on business requirements
|
|
238
|
-
|
|
239
|
-
### Evaluating Architectures
|
|
240
|
-
|
|
241
|
-
**Quality Attributes**:
|
|
242
|
-
- **Performance**: Response time, throughput
|
|
243
|
-
- **Scalability**: Handle increasing load
|
|
244
|
-
- **Availability**: Uptime, fault tolerance
|
|
245
|
-
- **Security**: Authentication, authorization, data protection
|
|
246
|
-
- **Maintainability**: Easy to modify and extend
|
|
247
|
-
- **Testability**: Easy to verify correctness
|
|
248
|
-
- **Deployability**: Easy to deploy and operate
|
|
249
|
-
|
|
250
|
-
**Architecture Review Checklist**:
|
|
251
|
-
- [ ] Clear separation of concerns
|
|
252
|
-
- [ ] Appropriate abstraction levels
|
|
253
|
-
- [ ] Well-defined component boundaries
|
|
254
|
-
- [ ] Explicit dependencies
|
|
255
|
-
- [ ] Scalability considerations
|
|
256
|
-
- [ ] Security considerations
|
|
257
|
-
- [ ] Testability built in
|
|
258
|
-
- [ ] Operational concerns addressed
|
|
259
|
-
|
|
260
|
-
## System Design Patterns
|
|
261
|
-
|
|
262
|
-
### Database Patterns
|
|
263
|
-
|
|
264
|
-
**Repository Pattern**:
|
|
265
|
-
- Abstract data access logic
|
|
266
|
-
- Decouple domain from persistence
|
|
267
|
-
|
|
268
|
-
**Unit of Work**:
|
|
269
|
-
- Maintain list of objects affected by transaction
|
|
270
|
-
- Coordinate writing changes
|
|
271
|
-
|
|
272
|
-
**Database per Service** (Microservices):
|
|
273
|
-
- Each service owns its database
|
|
274
|
-
- No shared databases
|
|
275
|
-
|
|
276
|
-
### Communication Patterns
|
|
277
|
-
|
|
278
|
-
**API Gateway**:
|
|
279
|
-
- Single entry point for clients
|
|
280
|
-
- Request routing and composition
|
|
281
|
-
- Cross-cutting concerns (auth, logging)
|
|
282
|
-
|
|
283
|
-
**Service Mesh**:
|
|
284
|
-
- Infrastructure layer for service-to-service communication
|
|
285
|
-
- Handles retries, timeouts, circuit breaking
|
|
286
|
-
|
|
287
|
-
**Message Queue**:
|
|
288
|
-
- Asynchronous communication
|
|
289
|
-
- Decoupling producers and consumers
|
|
290
|
-
- Load leveling
|
|
291
|
-
|
|
292
|
-
### Resilience Patterns
|
|
293
|
-
|
|
294
|
-
**Circuit Breaker**:
|
|
295
|
-
- Prevent cascading failures
|
|
296
|
-
- Fail fast when service unavailable
|
|
297
|
-
- Automatic recovery attempts
|
|
298
|
-
|
|
299
|
-
**Retry with Backoff**:
|
|
300
|
-
- Retry failed operations
|
|
301
|
-
- Exponential backoff to avoid overwhelming
|
|
302
|
-
- Maximum retry limit
|
|
303
|
-
|
|
304
|
-
**Bulkhead**:
|
|
305
|
-
- Isolate resources to prevent total failure
|
|
306
|
-
- Similar to ship compartments
|
|
307
|
-
- Limit impact of failures
|
|
308
|
-
|
|
309
|
-
**Timeout**:
|
|
310
|
-
- Set maximum wait time
|
|
311
|
-
- Prevent hanging operations
|
|
312
|
-
- Graceful degradation
|
|
313
|
-
|
|
314
|
-
## Architecture Documentation
|
|
315
|
-
|
|
316
|
-
### C4 Model
|
|
317
|
-
|
|
318
|
-
**Context Diagram**: System and its users
|
|
319
|
-
**Container Diagram**: High-level components
|
|
320
|
-
**Component Diagram**: Internal structure
|
|
321
|
-
**Code Diagram**: Class-level details (optional)
|
|
322
|
-
|
|
323
|
-
### Architecture Decision Records (ADR)
|
|
324
|
-
|
|
325
|
-
**Template**:
|
|
326
|
-
```
|
|
327
|
-
# ADR-001: Use PostgreSQL for Primary Database
|
|
328
|
-
|
|
329
|
-
## Status
|
|
330
|
-
Accepted
|
|
331
|
-
|
|
332
|
-
## Context
|
|
333
|
-
We need a database that supports complex queries, transactions, and scales to millions of records.
|
|
334
|
-
|
|
335
|
-
## Decision
|
|
336
|
-
We will use PostgreSQL as our primary relational database.
|
|
337
|
-
|
|
338
|
-
## Consequences
|
|
339
|
-
**Positive**:
|
|
340
|
-
- ACID compliance
|
|
341
|
-
- Rich query capabilities
|
|
342
|
-
- Proven scalability
|
|
343
|
-
- Strong ecosystem
|
|
344
|
-
|
|
345
|
-
**Negative**:
|
|
346
|
-
- Requires specialized knowledge
|
|
347
|
-
- Vertical scaling limitations
|
|
348
|
-
- Operational overhead
|
|
349
|
-
|
|
350
|
-
## Alternatives Considered
|
|
351
|
-
- MySQL: Less feature-rich
|
|
352
|
-
- MongoDB: Consistency concerns
|
|
353
|
-
- DynamoDB: Vendor lock-in
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
## Anti-patterns to Avoid
|
|
357
|
-
|
|
358
|
-
### Big Ball of Mud
|
|
359
|
-
- No clear architecture
|
|
360
|
-
- Everything depends on everything
|
|
361
|
-
- **Solution**: Gradual refactoring, introduce boundaries
|
|
362
|
-
|
|
363
|
-
### Monolithic Database
|
|
364
|
-
- All services share one database
|
|
365
|
-
- Tight coupling
|
|
366
|
-
- **Solution**: Database per service, API composition
|
|
367
|
-
|
|
368
|
-
### Distributed Monolith
|
|
369
|
-
- Microservices that must be deployed together
|
|
370
|
-
- Worst of both worlds
|
|
371
|
-
- **Solution**: True service independence or consolidate
|
|
372
|
-
|
|
373
|
-
### God Object
|
|
374
|
-
- Single class/service knows/does everything
|
|
375
|
-
- **Solution**: Single Responsibility Principle
|
|
376
|
-
|
|
377
|
-
## Best Practices
|
|
378
|
-
|
|
379
|
-
1. **Start Simple**: Don't over-engineer early
|
|
380
|
-
2. **Evolve Architecture**: Refactor as you learn
|
|
381
|
-
3. **Document Decisions**: Use ADRs
|
|
382
|
-
4. **Define Boundaries**: Clear contracts between components
|
|
383
|
-
5. **Test Architecture**: Fitness functions, architecture tests
|
|
384
|
-
6. **Monitor**: Metrics, logging, tracing
|
|
385
|
-
7. **Security by Design**: Not bolted on later
|
|
386
|
-
8. **Operational Concerns**: Deployment, monitoring, debugging
|
|
387
|
-
|
|
388
|
-
## Further Reading
|
|
389
|
-
|
|
390
|
-
- "Software Architecture: The Hard Parts" by Neal Ford et al.
|
|
391
|
-
- "Building Microservices" by Sam Newman
|
|
392
|
-
- "Domain-Driven Design" by Eric Evans
|
|
393
|
-
- "Clean Architecture" by Robert C. Martin
|
|
394
|
-
- "Fundamentals of Software Architecture" by Mark Richards and Neal Ford
|