@defai.digital/automatosx 5.6.35 → 5.7.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/CHANGELOG.md +142 -0
- package/README.md +44 -2
- package/dist/index.js +1129 -345
- package/examples/agents/.automatosx/abilities/accessibility.md +115 -0
- package/examples/agents/.automatosx/abilities/api-design.md +159 -0
- package/examples/agents/.automatosx/abilities/best-practices.md +102 -0
- package/examples/agents/.automatosx/abilities/caching-strategy.md +165 -0
- package/examples/agents/.automatosx/abilities/ci-cd.md +61 -0
- package/examples/agents/.automatosx/abilities/clean-code.md +398 -0
- package/examples/agents/.automatosx/abilities/code-generation.md +95 -0
- package/examples/agents/.automatosx/abilities/code-review.md +42 -0
- package/examples/agents/.automatosx/abilities/component-architecture.md +112 -0
- package/examples/agents/.automatosx/abilities/content-creation.md +97 -0
- package/examples/agents/.automatosx/abilities/data-modeling.md +171 -0
- package/examples/agents/.automatosx/abilities/data-validation.md +50 -0
- package/examples/agents/.automatosx/abilities/db-modeling.md +158 -0
- package/examples/agents/.automatosx/abilities/debugging.md +43 -0
- package/examples/agents/.automatosx/abilities/dependency-audit.md +60 -0
- package/examples/agents/.automatosx/abilities/design-patterns.md +437 -0
- package/examples/agents/.automatosx/abilities/design-system-implementation.md +126 -0
- package/examples/agents/.automatosx/abilities/documentation.md +54 -0
- package/examples/agents/.automatosx/abilities/error-analysis.md +107 -0
- package/examples/agents/.automatosx/abilities/etl-pipelines.md +44 -0
- package/examples/agents/.automatosx/abilities/feasibility-study.md +20 -0
- package/examples/agents/.automatosx/abilities/general-assistance.md +26 -0
- package/examples/agents/.automatosx/abilities/idea-evaluation.md +21 -0
- package/examples/agents/.automatosx/abilities/infra-as-code.md +57 -0
- package/examples/agents/.automatosx/abilities/job-orchestration.md +44 -0
- package/examples/agents/.automatosx/abilities/literature-review.md +19 -0
- package/examples/agents/.automatosx/abilities/logical-analysis.md +21 -0
- package/examples/agents/.automatosx/abilities/longform-report.md +25 -0
- package/examples/agents/.automatosx/abilities/mathematical-reasoning.md +170 -0
- package/examples/agents/.automatosx/abilities/mission-analysis.md +49 -0
- package/examples/agents/.automatosx/abilities/observability.md +61 -0
- package/examples/agents/.automatosx/abilities/orbital-mechanics.md +50 -0
- package/examples/agents/.automatosx/abilities/our-architecture-decisions.md +180 -0
- package/examples/agents/.automatosx/abilities/our-code-review-checklist.md +149 -0
- package/examples/agents/.automatosx/abilities/our-coding-standards.md +270 -0
- package/examples/agents/.automatosx/abilities/our-project-structure.md +183 -0
- package/examples/agents/.automatosx/abilities/performance-analysis.md +56 -0
- package/examples/agents/.automatosx/abilities/performance.md +80 -0
- package/examples/agents/.automatosx/abilities/problem-solving.md +50 -0
- package/examples/agents/.automatosx/abilities/propulsion-systems.md +50 -0
- package/examples/agents/.automatosx/abilities/quantum-algorithm-design.md +54 -0
- package/examples/agents/.automatosx/abilities/quantum-error-correction.md +56 -0
- package/examples/agents/.automatosx/abilities/quantum-frameworks-transpilation.md +53 -0
- package/examples/agents/.automatosx/abilities/quantum-noise-modeling.md +58 -0
- package/examples/agents/.automatosx/abilities/refactoring.md +223 -0
- package/examples/agents/.automatosx/abilities/release-strategy.md +58 -0
- package/examples/agents/.automatosx/abilities/risk-assessment.md +19 -0
- package/examples/agents/.automatosx/abilities/secrets-policy.md +61 -0
- package/examples/agents/.automatosx/abilities/secure-coding-review.md +51 -0
- package/examples/agents/.automatosx/abilities/security-audit.md +65 -0
- package/examples/agents/.automatosx/abilities/software-architecture.md +394 -0
- package/examples/agents/.automatosx/abilities/solid-principles.md +341 -0
- package/examples/agents/.automatosx/abilities/sql-optimization.md +84 -0
- package/examples/agents/.automatosx/abilities/state-management.md +96 -0
- package/examples/agents/.automatosx/abilities/task-planning.md +65 -0
- package/examples/agents/.automatosx/abilities/technical-writing.md +77 -0
- package/examples/agents/.automatosx/abilities/telemetry-diagnostics.md +51 -0
- package/examples/agents/.automatosx/abilities/testing.md +47 -0
- package/examples/agents/.automatosx/abilities/threat-modeling.md +49 -0
- package/examples/agents/.automatosx/abilities/troubleshooting.md +80 -0
- package/examples/agents/.automatosx/agents/aerospace-scientist.yaml +75 -0
- package/examples/agents/.automatosx/agents/backend.yaml +152 -0
- package/examples/agents/.automatosx/agents/ceo.yaml +63 -0
- package/examples/agents/.automatosx/agents/creative-marketer.yaml +121 -0
- package/examples/agents/.automatosx/agents/cto.yaml +72 -0
- package/examples/agents/.automatosx/agents/data-scientist.yaml +124 -0
- package/examples/agents/.automatosx/agents/data.yaml +77 -0
- package/examples/agents/.automatosx/agents/design.yaml +74 -0
- package/examples/agents/.automatosx/agents/devops.yaml +89 -0
- package/examples/agents/.automatosx/agents/frontend.yaml +139 -0
- package/examples/agents/.automatosx/agents/fullstack.yaml +151 -0
- package/examples/agents/.automatosx/agents/mobile.yaml +161 -0
- package/examples/agents/.automatosx/agents/product.yaml +72 -0
- package/examples/agents/.automatosx/agents/quality.yaml +79 -0
- package/examples/agents/.automatosx/agents/quantum-engineer.yaml +75 -0
- package/examples/agents/.automatosx/agents/researcher.yaml +71 -0
- package/examples/agents/.automatosx/agents/security.yaml +86 -0
- package/examples/agents/.automatosx/agents/stan.yaml +189 -0
- package/examples/agents/.automatosx/agents/writer.yaml +78 -0
- package/examples/agents/.automatosx/teams/business.yaml +56 -0
- package/examples/agents/.automatosx/teams/core.yaml +60 -0
- package/examples/agents/.automatosx/teams/design.yaml +58 -0
- package/examples/agents/.automatosx/teams/engineering.yaml +69 -0
- package/examples/agents/.automatosx/teams/research.yaml +56 -0
- package/examples/agents/.automatosx/templates/analyst.yaml +60 -0
- package/examples/agents/.automatosx/templates/assistant.yaml +48 -0
- package/examples/agents/.automatosx/templates/basic-agent.yaml +28 -0
- package/examples/agents/.automatosx/templates/code-reviewer.yaml +52 -0
- package/examples/agents/.automatosx/templates/debugger.yaml +63 -0
- package/examples/agents/.automatosx/templates/designer.yaml +69 -0
- package/examples/agents/.automatosx/templates/developer.yaml +60 -0
- package/examples/agents/.automatosx/templates/fullstack-developer.yaml +395 -0
- package/examples/agents/.automatosx/templates/qa-specialist.yaml +71 -0
- package/examples/agents/.claude/commands/ax-agent.md +37 -0
- package/examples/agents/.claude/commands/ax-clear.md +22 -0
- package/examples/agents/.claude/commands/ax-init.md +25 -0
- package/examples/agents/.claude/commands/ax-list.md +19 -0
- package/examples/agents/.claude/commands/ax-memory.md +25 -0
- package/examples/agents/.claude/commands/ax-status.md +24 -0
- package/examples/agents/.claude/commands/ax-update.md +28 -0
- package/examples/agents/.claude/mcp/automatosx.json +244 -0
- package/examples/agents/CLAUDE.md +262 -0
- package/package.json +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Content Creation Ability
|
|
2
|
+
|
|
3
|
+
Create engaging, informative content for various audiences.
|
|
4
|
+
|
|
5
|
+
## Content Types
|
|
6
|
+
|
|
7
|
+
1. **Blog Posts**
|
|
8
|
+
- Catchy title
|
|
9
|
+
- Hook in first paragraph
|
|
10
|
+
- Clear structure (intro, body, conclusion)
|
|
11
|
+
- Scannable (headings, bullets, short paragraphs)
|
|
12
|
+
- Call to action
|
|
13
|
+
|
|
14
|
+
2. **Tutorials**
|
|
15
|
+
- Clear learning objectives
|
|
16
|
+
- Prerequisites listed
|
|
17
|
+
- Step-by-step instructions
|
|
18
|
+
- Code examples
|
|
19
|
+
- Screenshots/diagrams
|
|
20
|
+
- What you learned / next steps
|
|
21
|
+
|
|
22
|
+
3. **Documentation**
|
|
23
|
+
- Purpose and overview
|
|
24
|
+
- Installation/setup
|
|
25
|
+
- Usage examples
|
|
26
|
+
- API reference
|
|
27
|
+
- Troubleshooting
|
|
28
|
+
- FAQ
|
|
29
|
+
|
|
30
|
+
4. **Presentations**
|
|
31
|
+
- One idea per slide
|
|
32
|
+
- Visual > text
|
|
33
|
+
- Tell a story
|
|
34
|
+
- Practice delivery
|
|
35
|
+
- End with key takeaways
|
|
36
|
+
|
|
37
|
+
## Writing Process
|
|
38
|
+
|
|
39
|
+
1. **Research**
|
|
40
|
+
- Understand the topic
|
|
41
|
+
- Know your audience
|
|
42
|
+
- Check existing content
|
|
43
|
+
- Gather examples
|
|
44
|
+
|
|
45
|
+
2. **Outline**
|
|
46
|
+
- Main points
|
|
47
|
+
- Logical flow
|
|
48
|
+
- Supporting details
|
|
49
|
+
- Conclusion
|
|
50
|
+
|
|
51
|
+
3. **Draft**
|
|
52
|
+
- Get ideas down
|
|
53
|
+
- Don't self-edit yet
|
|
54
|
+
- Write more than needed
|
|
55
|
+
- Focus on clarity
|
|
56
|
+
|
|
57
|
+
4. **Edit**
|
|
58
|
+
- Cut unnecessary content
|
|
59
|
+
- Improve clarity
|
|
60
|
+
- Fix grammar/spelling
|
|
61
|
+
- Check flow and structure
|
|
62
|
+
|
|
63
|
+
5. **Review**
|
|
64
|
+
- Read aloud
|
|
65
|
+
- Get feedback
|
|
66
|
+
- Check accuracy
|
|
67
|
+
- Final polish
|
|
68
|
+
|
|
69
|
+
## Writing Tips
|
|
70
|
+
|
|
71
|
+
**Clarity:**
|
|
72
|
+
|
|
73
|
+
- Use simple words
|
|
74
|
+
- Short sentences
|
|
75
|
+
- Active voice
|
|
76
|
+
- Concrete examples
|
|
77
|
+
|
|
78
|
+
**Engagement:**
|
|
79
|
+
|
|
80
|
+
- Hook readers early
|
|
81
|
+
- Use stories and examples
|
|
82
|
+
- Ask questions
|
|
83
|
+
- Vary sentence length
|
|
84
|
+
|
|
85
|
+
**Structure:**
|
|
86
|
+
|
|
87
|
+
- Clear headings
|
|
88
|
+
- Logical progression
|
|
89
|
+
- Bullet points for lists
|
|
90
|
+
- White space for readability
|
|
91
|
+
|
|
92
|
+
**Credibility:**
|
|
93
|
+
|
|
94
|
+
- Cite sources
|
|
95
|
+
- Use data and statistics
|
|
96
|
+
- Show expertise
|
|
97
|
+
- Acknowledge limitations
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Data Modeling
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
Design efficient, scalable data models for relational and NoSQL databases. Focus on normalization, relationships, and schema design that supports business requirements while maintaining data integrity.
|
|
5
|
+
|
|
6
|
+
## Core Principles
|
|
7
|
+
|
|
8
|
+
### 1. Normalization (Relational)
|
|
9
|
+
Eliminate data redundancy through normal forms (1NF, 2NF, 3NF, BCNF).
|
|
10
|
+
|
|
11
|
+
### 2. Denormalization (When Needed)
|
|
12
|
+
Strategic denormalization for read-heavy workloads and performance optimization.
|
|
13
|
+
|
|
14
|
+
### 3. Schema Design Patterns
|
|
15
|
+
- **Star Schema**: Dimensional modeling for analytics (fact + dimension tables)
|
|
16
|
+
- **Snowflake Schema**: Normalized dimensional model
|
|
17
|
+
- **Data Vault**: Flexible, auditable data warehouse modeling
|
|
18
|
+
|
|
19
|
+
## Do's ✅
|
|
20
|
+
|
|
21
|
+
### Relational Data Model
|
|
22
|
+
```sql
|
|
23
|
+
-- ✅ Good: Normalized design
|
|
24
|
+
CREATE TABLE users (
|
|
25
|
+
id SERIAL PRIMARY KEY,
|
|
26
|
+
email VARCHAR(255) UNIQUE NOT NULL,
|
|
27
|
+
created_at TIMESTAMP DEFAULT NOW()
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
CREATE TABLE orders (
|
|
31
|
+
id SERIAL PRIMARY KEY,
|
|
32
|
+
user_id INTEGER REFERENCES users(id),
|
|
33
|
+
total_amount DECIMAL(10,2),
|
|
34
|
+
status VARCHAR(50),
|
|
35
|
+
created_at TIMESTAMP DEFAULT NOW()
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
CREATE TABLE order_items (
|
|
39
|
+
id SERIAL PRIMARY KEY,
|
|
40
|
+
order_id INTEGER REFERENCES orders(id),
|
|
41
|
+
product_id INTEGER REFERENCES products(id),
|
|
42
|
+
quantity INTEGER,
|
|
43
|
+
price DECIMAL(10,2)
|
|
44
|
+
);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Indexes
|
|
48
|
+
```sql
|
|
49
|
+
-- ✅ Good: Index frequently queried columns
|
|
50
|
+
CREATE INDEX idx_orders_user_id ON orders(user_id);
|
|
51
|
+
CREATE INDEX idx_orders_created_at ON orders(created_at);
|
|
52
|
+
CREATE INDEX idx_order_items_order_id ON order_items(order_id);
|
|
53
|
+
|
|
54
|
+
-- ✅ Good: Composite index for multi-column queries
|
|
55
|
+
CREATE INDEX idx_orders_user_status ON orders(user_id, status);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### NoSQL Data Model (MongoDB)
|
|
59
|
+
```javascript
|
|
60
|
+
// ✅ Good: Embedded documents for one-to-few
|
|
61
|
+
{
|
|
62
|
+
_id: ObjectId("..."),
|
|
63
|
+
user_email: "user@example.com",
|
|
64
|
+
addresses: [
|
|
65
|
+
{ type: "home", street: "123 Main St", city: "NYC" },
|
|
66
|
+
{ type: "work", street: "456 Office Ave", city: "LA" }
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ✅ Good: References for one-to-many
|
|
71
|
+
// User document
|
|
72
|
+
{
|
|
73
|
+
_id: ObjectId("user123"),
|
|
74
|
+
email: "user@example.com"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Order documents (separate collection)
|
|
78
|
+
{
|
|
79
|
+
_id: ObjectId("order456"),
|
|
80
|
+
user_id: ObjectId("user123"),
|
|
81
|
+
items: [...],
|
|
82
|
+
total: 99.99
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Don'ts ❌
|
|
87
|
+
|
|
88
|
+
### Over-Normalization
|
|
89
|
+
```sql
|
|
90
|
+
-- ❌ Bad: Excessive normalization
|
|
91
|
+
CREATE TABLE user_first_names (
|
|
92
|
+
user_id INTEGER REFERENCES users(id),
|
|
93
|
+
first_name VARCHAR(100)
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
CREATE TABLE user_last_names (
|
|
97
|
+
user_id INTEGER REFERENCES users(id),
|
|
98
|
+
last_name VARCHAR(100)
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
-- ✅ Good: Appropriate normalization
|
|
102
|
+
CREATE TABLE users (
|
|
103
|
+
id SERIAL PRIMARY KEY,
|
|
104
|
+
first_name VARCHAR(100),
|
|
105
|
+
last_name VARCHAR(100),
|
|
106
|
+
email VARCHAR(255) UNIQUE
|
|
107
|
+
);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Missing Constraints
|
|
111
|
+
```sql
|
|
112
|
+
-- ❌ Bad: No constraints
|
|
113
|
+
CREATE TABLE orders (
|
|
114
|
+
id INTEGER,
|
|
115
|
+
user_id INTEGER,
|
|
116
|
+
total DECIMAL
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
-- ✅ Good: Proper constraints
|
|
120
|
+
CREATE TABLE orders (
|
|
121
|
+
id SERIAL PRIMARY KEY,
|
|
122
|
+
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
123
|
+
total DECIMAL(10,2) CHECK (total >= 0),
|
|
124
|
+
status VARCHAR(50) DEFAULT 'pending',
|
|
125
|
+
created_at TIMESTAMP NOT NULL DEFAULT NOW()
|
|
126
|
+
);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Embedding Large Arrays (NoSQL)
|
|
130
|
+
```javascript
|
|
131
|
+
// ❌ Bad: Unbounded array growth
|
|
132
|
+
{
|
|
133
|
+
user_id: "user123",
|
|
134
|
+
orders: [ /* Could grow to thousands */ ]
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ✅ Good: Reference pattern
|
|
138
|
+
{
|
|
139
|
+
user_id: "user123",
|
|
140
|
+
recent_orders: [ /* Last 5 orders */ ],
|
|
141
|
+
total_order_count: 1247
|
|
142
|
+
}
|
|
143
|
+
// Store full orders in separate collection
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Best Practices
|
|
147
|
+
|
|
148
|
+
### 1. Use Appropriate Data Types
|
|
149
|
+
- `TIMESTAMP` for dates (not VARCHAR)
|
|
150
|
+
- `DECIMAL` for money (not FLOAT)
|
|
151
|
+
- `ENUM` or `CHECK` constraints for fixed options
|
|
152
|
+
- `UUID` for distributed primary keys
|
|
153
|
+
|
|
154
|
+
### 2. Plan for Growth
|
|
155
|
+
- Partition large tables by date/region
|
|
156
|
+
- Use sharding for horizontal scalability
|
|
157
|
+
- Implement archival strategy for old data
|
|
158
|
+
|
|
159
|
+
### 3. Document Relationships
|
|
160
|
+
```
|
|
161
|
+
Users (1) ← (M) Orders (1) ← (M) OrderItems (M) → (1) Products
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 4. Version Schema Changes
|
|
165
|
+
Use migration tools (Flyway, Liquibase, Alembic) for schema versioning.
|
|
166
|
+
|
|
167
|
+
## Resources
|
|
168
|
+
|
|
169
|
+
- [Database Normalization](https://en.wikipedia.org/wiki/Database_normalization)
|
|
170
|
+
- [MongoDB Schema Design Patterns](https://www.mongodb.com/blog/post/building-with-patterns-a-summary)
|
|
171
|
+
- [PostgreSQL Documentation](https://www.postgresql.org/docs/)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Data Validation
|
|
2
|
+
|
|
3
|
+
Implement comprehensive data quality checks to ensure accuracy, completeness, and consistency. Catch data issues early before they impact downstream systems.
|
|
4
|
+
|
|
5
|
+
## Do's ✅
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# ✅ Good: Schema validation with Pydantic
|
|
9
|
+
from pydantic import BaseModel, validator
|
|
10
|
+
|
|
11
|
+
class UserRecord(BaseModel):
|
|
12
|
+
id: int
|
|
13
|
+
email: str
|
|
14
|
+
age: int
|
|
15
|
+
|
|
16
|
+
@validator('email')
|
|
17
|
+
def email_must_be_valid(cls, v):
|
|
18
|
+
if '@' not in v:
|
|
19
|
+
raise ValueError('Invalid email')
|
|
20
|
+
return v
|
|
21
|
+
|
|
22
|
+
# ✅ Good: Data quality checks
|
|
23
|
+
def validate_data(df):
|
|
24
|
+
checks = [
|
|
25
|
+
('No nulls', df[['id', 'email']].notnull().all().all()),
|
|
26
|
+
('Unique IDs', df['id'].is_unique),
|
|
27
|
+
('Valid ages', df['age'].between(0, 150).all()),
|
|
28
|
+
]
|
|
29
|
+
failed = [check for check, passed in checks if not passed]
|
|
30
|
+
if failed:
|
|
31
|
+
raise ValueError(f"Validation failed: {failed}")
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Don'ts ❌
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
# ❌ Bad: No validation
|
|
38
|
+
df = pd.read_csv('data.csv')
|
|
39
|
+
df.to_sql('users', engine) # Hope for the best!
|
|
40
|
+
|
|
41
|
+
# ❌ Bad: Silent failures
|
|
42
|
+
df = df.dropna() # What was dropped? Why?
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Best Practices
|
|
46
|
+
- Define data quality SLAs
|
|
47
|
+
- Implement continuous monitoring
|
|
48
|
+
- Document validation rules
|
|
49
|
+
- Use validation frameworks (Great Expectations, Pandera)
|
|
50
|
+
- Create data quality dashboards
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Database Modeling
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
Design efficient, scalable, and maintainable database schemas for relational and NoSQL databases, focusing on data integrity, performance, and evolution.
|
|
5
|
+
|
|
6
|
+
## Core Principles
|
|
7
|
+
|
|
8
|
+
### 1. Normalization & Denormalization
|
|
9
|
+
- 3NF for transactional systems
|
|
10
|
+
- Strategic denormalization for read-heavy workloads
|
|
11
|
+
- Balance between data integrity and query performance
|
|
12
|
+
|
|
13
|
+
### 2. Data Integrity
|
|
14
|
+
- Primary keys on all tables
|
|
15
|
+
- Foreign key constraints
|
|
16
|
+
- Check constraints for data validation
|
|
17
|
+
- Unique constraints for business rules
|
|
18
|
+
|
|
19
|
+
### 3. Indexing Strategy
|
|
20
|
+
- Primary key indexes (clustered)
|
|
21
|
+
- Secondary indexes for frequent queries
|
|
22
|
+
- Composite indexes for multi-column filters
|
|
23
|
+
- Index maintenance and statistics
|
|
24
|
+
|
|
25
|
+
### 4. Schema Evolution
|
|
26
|
+
- Migration strategy (forward-only)
|
|
27
|
+
- Backward compatibility during deploys
|
|
28
|
+
- Column additions vs. breaking changes
|
|
29
|
+
- Versioning for schema changes
|
|
30
|
+
|
|
31
|
+
## Relational Database Design
|
|
32
|
+
|
|
33
|
+
### Table Design Essentials
|
|
34
|
+
- Primary key (BIGSERIAL, UUID)
|
|
35
|
+
- Timestamps (created_at, updated_at)
|
|
36
|
+
- Soft delete (deleted_at)
|
|
37
|
+
- Proper data types
|
|
38
|
+
|
|
39
|
+
### Relationship Patterns
|
|
40
|
+
- One-to-Many: Foreign key in child table
|
|
41
|
+
- Many-to-Many: Junction table with composite primary key
|
|
42
|
+
- One-to-One: Rare; consider column addition instead
|
|
43
|
+
|
|
44
|
+
### Partitioning Strategies
|
|
45
|
+
- Range partitioning (dates, IDs)
|
|
46
|
+
- List partitioning (regions, categories)
|
|
47
|
+
- Hash partitioning (even distribution)
|
|
48
|
+
- When to partition: >10M rows, predictable access patterns
|
|
49
|
+
|
|
50
|
+
## NoSQL Design Patterns
|
|
51
|
+
|
|
52
|
+
### Document Stores (MongoDB, DynamoDB)
|
|
53
|
+
- Embed vs. reference decision tree
|
|
54
|
+
- Avoid unbounded arrays
|
|
55
|
+
- Duplicate data strategically
|
|
56
|
+
- Query pattern drives schema
|
|
57
|
+
|
|
58
|
+
### Key-Value Stores (Redis, DynamoDB)
|
|
59
|
+
- Compound key design
|
|
60
|
+
- TTL for expiring data
|
|
61
|
+
- Secondary indexes trade-offs
|
|
62
|
+
|
|
63
|
+
### Graph Databases (Neo4j)
|
|
64
|
+
- Node and relationship properties
|
|
65
|
+
- Index on frequently queried properties
|
|
66
|
+
- Cypher query optimization
|
|
67
|
+
|
|
68
|
+
## Performance Optimization
|
|
69
|
+
|
|
70
|
+
### Query Performance
|
|
71
|
+
- EXPLAIN ANALYZE for execution plans
|
|
72
|
+
- Index usage verification
|
|
73
|
+
- Avoid N+1 queries (eager loading)
|
|
74
|
+
- Connection pooling configuration
|
|
75
|
+
|
|
76
|
+
### Write Optimization
|
|
77
|
+
- Batch inserts for bulk data
|
|
78
|
+
- Async writes for non-critical data
|
|
79
|
+
- Write-ahead logging (WAL) tuning
|
|
80
|
+
|
|
81
|
+
### Read Optimization
|
|
82
|
+
- Read replicas for scaling
|
|
83
|
+
- Query result caching
|
|
84
|
+
- Materialized views for complex aggregations
|
|
85
|
+
|
|
86
|
+
## Data Types Best Practices
|
|
87
|
+
|
|
88
|
+
### Choosing Types
|
|
89
|
+
- VARCHAR vs. TEXT vs. CHAR
|
|
90
|
+
- INTEGER vs. BIGINT (consider growth)
|
|
91
|
+
- DECIMAL for money (never FLOAT)
|
|
92
|
+
- TIMESTAMPTZ for dates (always use timezone)
|
|
93
|
+
- JSON/JSONB for semi-structured data
|
|
94
|
+
|
|
95
|
+
### Type Performance
|
|
96
|
+
- Smaller types = better performance
|
|
97
|
+
- Fixed-length types for indexes
|
|
98
|
+
- Avoid TEXT in WHERE clauses without indexes
|
|
99
|
+
|
|
100
|
+
## Migration Strategies
|
|
101
|
+
|
|
102
|
+
### Safe Migration Patterns
|
|
103
|
+
1. Add nullable column → Backfill → Add NOT NULL
|
|
104
|
+
2. Create new table → Dual write → Swap → Drop old
|
|
105
|
+
3. Add index CONCURRENTLY (PostgreSQL)
|
|
106
|
+
4. Rename via view (zero-downtime)
|
|
107
|
+
|
|
108
|
+
### Rollback Strategies
|
|
109
|
+
- Idempotent migrations
|
|
110
|
+
- Reversible changes
|
|
111
|
+
- Feature flags for data migrations
|
|
112
|
+
- Separate schema and data migrations
|
|
113
|
+
|
|
114
|
+
## Security & Compliance
|
|
115
|
+
|
|
116
|
+
### Access Control
|
|
117
|
+
- Principle of least privilege
|
|
118
|
+
- Row-level security (RLS)
|
|
119
|
+
- Column-level permissions
|
|
120
|
+
- Audit logging for sensitive data
|
|
121
|
+
|
|
122
|
+
### Data Encryption
|
|
123
|
+
- Encryption at rest
|
|
124
|
+
- Encryption in transit (SSL/TLS)
|
|
125
|
+
- Column-level encryption for PII
|
|
126
|
+
- Key rotation policies
|
|
127
|
+
|
|
128
|
+
### GDPR/Privacy
|
|
129
|
+
- Soft delete vs. hard delete
|
|
130
|
+
- Data retention policies
|
|
131
|
+
- PII identification and protection
|
|
132
|
+
- Right to be forgotten implementation
|
|
133
|
+
|
|
134
|
+
## Common Patterns
|
|
135
|
+
|
|
136
|
+
### Soft Delete
|
|
137
|
+
Use `deleted_at` timestamp with partial index
|
|
138
|
+
|
|
139
|
+
### Audit Trails
|
|
140
|
+
Track created_at, created_by, updated_at, updated_by
|
|
141
|
+
|
|
142
|
+
### Status/State Machine
|
|
143
|
+
Use CHECK constraints for valid states
|
|
144
|
+
|
|
145
|
+
## Design Checklist
|
|
146
|
+
|
|
147
|
+
- [ ] All tables have primary keys
|
|
148
|
+
- [ ] Foreign key constraints defined
|
|
149
|
+
- [ ] Indexes cover frequent query patterns
|
|
150
|
+
- [ ] Data types appropriately sized
|
|
151
|
+
- [ ] Nullable columns justified
|
|
152
|
+
- [ ] Constraints enforce business rules
|
|
153
|
+
- [ ] Migration scripts tested
|
|
154
|
+
- [ ] Rollback plan documented
|
|
155
|
+
- [ ] Performance testing completed
|
|
156
|
+
- [ ] Schema documented
|
|
157
|
+
- [ ] Backup/restore verified
|
|
158
|
+
- [ ] Security audit completed
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Debugging Ability
|
|
2
|
+
|
|
3
|
+
Systematically identify and fix bugs in code.
|
|
4
|
+
|
|
5
|
+
## Debugging Process
|
|
6
|
+
|
|
7
|
+
1. **Reproduce** the issue
|
|
8
|
+
- Understand error messages
|
|
9
|
+
- Identify conditions that trigger the bug
|
|
10
|
+
- Create minimal reproduction case
|
|
11
|
+
|
|
12
|
+
2. **Investigate** the problem
|
|
13
|
+
- Read stack traces carefully
|
|
14
|
+
- Add logging and breakpoints
|
|
15
|
+
- Check recent changes (git diff)
|
|
16
|
+
- Verify assumptions
|
|
17
|
+
|
|
18
|
+
3. **Isolate** the root cause
|
|
19
|
+
- Use binary search (comment out code blocks)
|
|
20
|
+
- Test components individually
|
|
21
|
+
- Check inputs and outputs
|
|
22
|
+
- Trace execution flow
|
|
23
|
+
|
|
24
|
+
4. **Fix** the bug
|
|
25
|
+
- Implement targeted fix
|
|
26
|
+
- Avoid introducing new bugs
|
|
27
|
+
- Update related code if needed
|
|
28
|
+
- Add regression test
|
|
29
|
+
|
|
30
|
+
5. **Verify** the solution
|
|
31
|
+
- Test the fix thoroughly
|
|
32
|
+
- Check for side effects
|
|
33
|
+
- Run full test suite
|
|
34
|
+
- Document the fix
|
|
35
|
+
|
|
36
|
+
## Common Bug Types
|
|
37
|
+
|
|
38
|
+
- Off-by-one errors
|
|
39
|
+
- Null/undefined reference errors
|
|
40
|
+
- Race conditions and timing issues
|
|
41
|
+
- Type mismatches
|
|
42
|
+
- Resource leaks (memory, file handles)
|
|
43
|
+
- Logic errors in conditionals
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Dependency Audit
|
|
2
|
+
|
|
3
|
+
Scan and manage third-party dependencies for known vulnerabilities. Keep dependencies updated and minimize supply chain risks.
|
|
4
|
+
|
|
5
|
+
## Do's ✅
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# ✅ Good: Regular scanning
|
|
9
|
+
npm audit
|
|
10
|
+
npm audit fix
|
|
11
|
+
|
|
12
|
+
npx snyk test
|
|
13
|
+
npx snyk monitor
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```yaml
|
|
17
|
+
# ✅ Good: Automated CI scanning
|
|
18
|
+
name: Security
|
|
19
|
+
on: [push, pull_request]
|
|
20
|
+
jobs:
|
|
21
|
+
security:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v3
|
|
25
|
+
- name: Run Snyk
|
|
26
|
+
uses: snyk/actions/node@master
|
|
27
|
+
env:
|
|
28
|
+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
// ✅ Good: Pin versions
|
|
33
|
+
{
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"express": "4.18.2"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Don'ts ❌
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# ❌ Bad: Ignoring warnings
|
|
44
|
+
npm audit
|
|
45
|
+
# 15 vulnerabilities found
|
|
46
|
+
# (deploys anyway)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
// ❌ Bad: Unmaintained packages
|
|
51
|
+
const pkg = require('abandoned-library'); // Last update 5 years ago
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Best Practices
|
|
55
|
+
- Run `npm audit` in CI pipeline
|
|
56
|
+
- Use Dependabot/Renovate for auto-updates
|
|
57
|
+
- Review changelogs before updating
|
|
58
|
+
- Have rollback plan
|
|
59
|
+
- Monitor security advisories
|
|
60
|
+
- Use minimal dependencies
|