@defai.digital/automatosx 12.8.7 → 13.1.3
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/README.md +48 -754
- 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/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,115 +0,0 @@
|
|
|
1
|
-
# Accessibility (A11y)
|
|
2
|
-
|
|
3
|
-
Build inclusive web applications following WCAG guidelines.
|
|
4
|
-
|
|
5
|
-
## Core Principles (WCAG)
|
|
6
|
-
|
|
7
|
-
1. **Perceivable** - Users must be able to perceive the information
|
|
8
|
-
2. **Operable** - Users must be able to operate the interface
|
|
9
|
-
3. **Understandable** - Users must understand the information and interface
|
|
10
|
-
4. **Robust** - Content must work with current and future technologies
|
|
11
|
-
|
|
12
|
-
## Essential Practices
|
|
13
|
-
|
|
14
|
-
### 1. Semantic HTML
|
|
15
|
-
- Use proper HTML elements (button, nav, header, main, footer, article)
|
|
16
|
-
- Avoid div/span for interactive elements
|
|
17
|
-
- Use headings (h1-h6) in logical order
|
|
18
|
-
- Use lists (ul, ol) for groups of items
|
|
19
|
-
- Use form elements with proper labels
|
|
20
|
-
|
|
21
|
-
### 2. ARIA Attributes
|
|
22
|
-
- Use aria-label for icons and buttons without text
|
|
23
|
-
- Use aria-describedby for additional context
|
|
24
|
-
- Use aria-live for dynamic content updates
|
|
25
|
-
- Use aria-expanded for collapsible sections
|
|
26
|
-
- Use aria-hidden="true" for decorative elements
|
|
27
|
-
- Don't over-use ARIA (semantic HTML is better)
|
|
28
|
-
|
|
29
|
-
### 3. Keyboard Navigation
|
|
30
|
-
- All interactive elements must be keyboard accessible (Tab, Enter, Space)
|
|
31
|
-
- Provide visible focus indicators (:focus-visible)
|
|
32
|
-
- Implement skip links for main content
|
|
33
|
-
- Use tabindex="0" to add elements to tab order
|
|
34
|
-
- Use tabindex="-1" to remove from tab order (programmatically focusable)
|
|
35
|
-
- Never use positive tabindex values
|
|
36
|
-
|
|
37
|
-
### 4. Color and Contrast
|
|
38
|
-
- Minimum contrast ratio 4.5:1 for normal text
|
|
39
|
-
- Minimum contrast ratio 3:1 for large text (18pt+)
|
|
40
|
-
- Don't rely on color alone to convey information
|
|
41
|
-
- Provide text alternatives for color-coded information
|
|
42
|
-
- Test with color blindness simulators
|
|
43
|
-
|
|
44
|
-
### 5. Forms
|
|
45
|
-
- Use <label> for every form input
|
|
46
|
-
- Provide clear error messages
|
|
47
|
-
- Use aria-invalid and aria-describedby for errors
|
|
48
|
-
- Group related inputs with fieldset/legend
|
|
49
|
-
- Mark required fields clearly (aria-required="true")
|
|
50
|
-
- Provide autocomplete attributes where appropriate
|
|
51
|
-
|
|
52
|
-
### 6. Images and Media
|
|
53
|
-
- Provide alt text for all images
|
|
54
|
-
- Use empty alt="" for decorative images
|
|
55
|
-
- Provide captions for videos
|
|
56
|
-
- Provide transcripts for audio content
|
|
57
|
-
- Don't use images of text (use real text)
|
|
58
|
-
|
|
59
|
-
### 7. Focus Management
|
|
60
|
-
- Manage focus for modals (trap focus, restore on close)
|
|
61
|
-
- Focus first interactive element when opening dialogs
|
|
62
|
-
- Provide focus indicators for all interactive elements
|
|
63
|
-
- Use :focus-visible to show focus only for keyboard users
|
|
64
|
-
- Announce route changes for screen readers
|
|
65
|
-
|
|
66
|
-
### 8. Screen Reader Support
|
|
67
|
-
- Use live regions (aria-live) for dynamic updates
|
|
68
|
-
- Provide meaningful page titles
|
|
69
|
-
- Use aria-label when visual label isn't enough
|
|
70
|
-
- Test with screen readers (NVDA, JAWS, VoiceOver)
|
|
71
|
-
- Announce loading states and errors
|
|
72
|
-
|
|
73
|
-
## Common Patterns
|
|
74
|
-
|
|
75
|
-
### Modal Dialogs
|
|
76
|
-
- Trap focus within modal
|
|
77
|
-
- Close on Escape key
|
|
78
|
-
- Return focus to trigger element on close
|
|
79
|
-
- Use role="dialog" and aria-modal="true"
|
|
80
|
-
- Provide accessible close button
|
|
81
|
-
|
|
82
|
-
### Dropdown Menus
|
|
83
|
-
- Use aria-expanded to indicate state
|
|
84
|
-
- Navigate with arrow keys
|
|
85
|
-
- Close on Escape
|
|
86
|
-
- Close on click outside
|
|
87
|
-
- Focus first item when opened
|
|
88
|
-
|
|
89
|
-
### Form Validation
|
|
90
|
-
- Associate errors with fields (aria-describedby)
|
|
91
|
-
- Mark invalid fields (aria-invalid="true")
|
|
92
|
-
- Announce errors to screen readers
|
|
93
|
-
- Provide clear, specific error messages
|
|
94
|
-
- Don't rely on color alone
|
|
95
|
-
|
|
96
|
-
## Testing Tools
|
|
97
|
-
|
|
98
|
-
- axe DevTools (Chrome extension)
|
|
99
|
-
- Lighthouse accessibility audit
|
|
100
|
-
- WAVE (Web Accessibility Evaluation Tool)
|
|
101
|
-
- Keyboard navigation testing (Tab, Shift+Tab, Enter, Space, Esc, Arrow keys)
|
|
102
|
-
- Screen reader testing (VoiceOver on Mac, NVDA/JAWS on Windows)
|
|
103
|
-
|
|
104
|
-
## Quick Checklist
|
|
105
|
-
|
|
106
|
-
- [ ] All interactive elements keyboard accessible
|
|
107
|
-
- [ ] Proper semantic HTML used
|
|
108
|
-
- [ ] All images have appropriate alt text
|
|
109
|
-
- [ ] Color contrast meets WCAG AA (4.5:1)
|
|
110
|
-
- [ ] Forms have proper labels and error handling
|
|
111
|
-
- [ ] Focus management for modals/dialogs
|
|
112
|
-
- [ ] ARIA attributes used correctly (when needed)
|
|
113
|
-
- [ ] Tested with keyboard navigation
|
|
114
|
-
- [ ] Tested with screen reader
|
|
115
|
-
- [ ] No accessibility errors in axe DevTools
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
# API Design
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
Design RESTful, GraphQL, and other API architectures following industry best practices, focusing on developer experience, performance, and maintainability.
|
|
5
|
-
|
|
6
|
-
## Core Principles
|
|
7
|
-
|
|
8
|
-
### 1. RESTful Design
|
|
9
|
-
- Resource-oriented URL structure
|
|
10
|
-
- Proper HTTP method usage (GET, POST, PUT, PATCH, DELETE)
|
|
11
|
-
- Stateless communication
|
|
12
|
-
- HATEOAS when appropriate
|
|
13
|
-
|
|
14
|
-
### 2. GraphQL Design
|
|
15
|
-
- Schema-first approach
|
|
16
|
-
- Efficient resolver implementation
|
|
17
|
-
- Query complexity analysis
|
|
18
|
-
- Pagination and batching strategies
|
|
19
|
-
|
|
20
|
-
### 3. API Versioning
|
|
21
|
-
- URL versioning (`/v1/`, `/v2/`)
|
|
22
|
-
- Header versioning (`Accept: application/vnd.api+json; version=1`)
|
|
23
|
-
- Deprecation policies and timelines
|
|
24
|
-
|
|
25
|
-
### 4. Error Handling
|
|
26
|
-
- Consistent error response structure
|
|
27
|
-
- Meaningful HTTP status codes
|
|
28
|
-
- Detailed error messages for debugging
|
|
29
|
-
- Error code cataloging
|
|
30
|
-
|
|
31
|
-
### 5. Authentication & Authorization
|
|
32
|
-
- Token-based authentication (JWT, OAuth 2.0)
|
|
33
|
-
- API key management
|
|
34
|
-
- Rate limiting per user/client
|
|
35
|
-
- Scope-based permissions
|
|
36
|
-
|
|
37
|
-
## Design Patterns
|
|
38
|
-
|
|
39
|
-
### Request/Response Patterns
|
|
40
|
-
```
|
|
41
|
-
GET /api/v1/resources/{id}
|
|
42
|
-
→ 200 OK with resource
|
|
43
|
-
→ 404 Not Found
|
|
44
|
-
→ 401 Unauthorized
|
|
45
|
-
|
|
46
|
-
POST /api/v1/resources
|
|
47
|
-
→ 201 Created with Location header
|
|
48
|
-
→ 400 Bad Request with validation errors
|
|
49
|
-
→ 409 Conflict for duplicates
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Pagination
|
|
53
|
-
- Cursor-based for large datasets
|
|
54
|
-
- Offset/limit for smaller datasets
|
|
55
|
-
- Include metadata (total count, has_next, cursors)
|
|
56
|
-
|
|
57
|
-
### Filtering & Sorting
|
|
58
|
-
- Query parameters: `?filter[status]=active&sort=-created_at`
|
|
59
|
-
- Standardized field names
|
|
60
|
-
- Documentation of supported operators
|
|
61
|
-
|
|
62
|
-
## Documentation Standards
|
|
63
|
-
|
|
64
|
-
### OpenAPI/Swagger
|
|
65
|
-
- Complete endpoint descriptions
|
|
66
|
-
- Request/response schemas
|
|
67
|
-
- Example payloads
|
|
68
|
-
- Authentication requirements
|
|
69
|
-
|
|
70
|
-
### API Documentation Must Include
|
|
71
|
-
- Quick start guide
|
|
72
|
-
- Authentication flow
|
|
73
|
-
- Rate limits
|
|
74
|
-
- Error codes reference
|
|
75
|
-
- Changelog with version history
|
|
76
|
-
|
|
77
|
-
## Performance Considerations
|
|
78
|
-
|
|
79
|
-
### 1. Response Optimization
|
|
80
|
-
- Minimal payload size
|
|
81
|
-
- Field selection (`?fields=id,name`)
|
|
82
|
-
- Compression (gzip, brotli)
|
|
83
|
-
- Caching headers (ETag, Cache-Control)
|
|
84
|
-
|
|
85
|
-
### 2. Request Optimization
|
|
86
|
-
- Batch endpoints for multiple operations
|
|
87
|
-
- Webhook support for async operations
|
|
88
|
-
- WebSocket for real-time updates
|
|
89
|
-
|
|
90
|
-
### 3. Monitoring
|
|
91
|
-
- Response time percentiles (p50, p95, p99)
|
|
92
|
-
- Error rates by endpoint
|
|
93
|
-
- Rate limit hit metrics
|
|
94
|
-
- Payload size distribution
|
|
95
|
-
|
|
96
|
-
## Security Guidelines
|
|
97
|
-
|
|
98
|
-
### Input Validation
|
|
99
|
-
- Schema validation for all requests
|
|
100
|
-
- Sanitize user input
|
|
101
|
-
- Size limits on payloads
|
|
102
|
-
- Content-type verification
|
|
103
|
-
|
|
104
|
-
### Rate Limiting
|
|
105
|
-
- Per-endpoint limits
|
|
106
|
-
- User/API key throttling
|
|
107
|
-
- Gradual backoff responses
|
|
108
|
-
- 429 Too Many Requests with Retry-After
|
|
109
|
-
|
|
110
|
-
### CORS Configuration
|
|
111
|
-
- Explicit origin whitelisting
|
|
112
|
-
- Credential handling
|
|
113
|
-
- Preflight request caching
|
|
114
|
-
|
|
115
|
-
## Contract Testing
|
|
116
|
-
|
|
117
|
-
### Schema Validation
|
|
118
|
-
- Request validation against OpenAPI spec
|
|
119
|
-
- Response validation
|
|
120
|
-
- Breaking change detection
|
|
121
|
-
|
|
122
|
-
### Backward Compatibility
|
|
123
|
-
- Additive changes only (new fields)
|
|
124
|
-
- Deprecation warnings before removal
|
|
125
|
-
- Versioning for breaking changes
|
|
126
|
-
|
|
127
|
-
## Tools & Technologies
|
|
128
|
-
|
|
129
|
-
### Design
|
|
130
|
-
- OpenAPI 3.x specification
|
|
131
|
-
- Postman/Insomnia for testing
|
|
132
|
-
- GraphQL Playground
|
|
133
|
-
- API Blueprint
|
|
134
|
-
|
|
135
|
-
### Testing
|
|
136
|
-
- Contract testing (Pact)
|
|
137
|
-
- Load testing (k6, JMeter)
|
|
138
|
-
- Security scanning (OWASP ZAP)
|
|
139
|
-
|
|
140
|
-
### Documentation
|
|
141
|
-
- Swagger UI
|
|
142
|
-
- ReDoc
|
|
143
|
-
- GraphQL Voyager
|
|
144
|
-
- Stoplight Studio
|
|
145
|
-
|
|
146
|
-
## Checklist for New API
|
|
147
|
-
|
|
148
|
-
- [ ] OpenAPI spec created and validated
|
|
149
|
-
- [ ] Authentication/authorization implemented
|
|
150
|
-
- [ ] Rate limiting configured
|
|
151
|
-
- [ ] Error responses standardized
|
|
152
|
-
- [ ] CORS properly configured
|
|
153
|
-
- [ ] Input validation on all endpoints
|
|
154
|
-
- [ ] Response caching strategy defined
|
|
155
|
-
- [ ] API documentation published
|
|
156
|
-
- [ ] Monitoring/alerting set up
|
|
157
|
-
- [ ] Contract tests written
|
|
158
|
-
- [ ] Load testing performed
|
|
159
|
-
- [ ] Security audit completed
|
|
160
|
-
|
|
161
|
-
## Application Hints
|
|
162
|
-
|
|
163
|
-
When designing APIs:
|
|
164
|
-
- Prioritize backward compatibility; breaking changes require explicit versioning strategy
|
|
165
|
-
- Validate request/response schemas before implementation (use OpenAPI spec as contract)
|
|
166
|
-
- Consider rate limiting and pagination for all list endpoints from the start
|
|
167
|
-
- Check idempotency requirements for payment, financial, or state-changing operations
|
|
168
|
-
- Document error codes and response formats before writing endpoint logic
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
# Best Practices Ability
|
|
2
|
-
|
|
3
|
-
Apply industry-standard best practices across development.
|
|
4
|
-
|
|
5
|
-
## Code Quality
|
|
6
|
-
|
|
7
|
-
1. **Readability**
|
|
8
|
-
- Clear, descriptive names
|
|
9
|
-
- Consistent formatting
|
|
10
|
-
- Meaningful comments
|
|
11
|
-
- Self-documenting code
|
|
12
|
-
|
|
13
|
-
2. **Simplicity**
|
|
14
|
-
- KISS (Keep It Simple, Stupid)
|
|
15
|
-
- Avoid over-engineering
|
|
16
|
-
- Solve today's problem
|
|
17
|
-
- Refactor when needed
|
|
18
|
-
|
|
19
|
-
3. **Maintainability**
|
|
20
|
-
- DRY (Don't Repeat Yourself)
|
|
21
|
-
- SOLID principles
|
|
22
|
-
- Low coupling, high cohesion
|
|
23
|
-
- Modular design
|
|
24
|
-
|
|
25
|
-
4. **Reliability**
|
|
26
|
-
- Error handling
|
|
27
|
-
- Input validation
|
|
28
|
-
- Defensive programming
|
|
29
|
-
- Comprehensive testing
|
|
30
|
-
|
|
31
|
-
## Development Practices
|
|
32
|
-
|
|
33
|
-
### Version Control (Git)
|
|
34
|
-
|
|
35
|
-
- Commit often, push daily
|
|
36
|
-
- Write meaningful commit messages
|
|
37
|
-
- Use feature branches
|
|
38
|
-
- Review before merging
|
|
39
|
-
- Keep main/master deployable
|
|
40
|
-
|
|
41
|
-
### Code Review
|
|
42
|
-
|
|
43
|
-
- Review all changes
|
|
44
|
-
- Be constructive and respectful
|
|
45
|
-
- Check for bugs, style, design
|
|
46
|
-
- Suggest alternatives
|
|
47
|
-
- Approve only when ready
|
|
48
|
-
|
|
49
|
-
### Testing
|
|
50
|
-
|
|
51
|
-
- Write tests first (TDD)
|
|
52
|
-
- Test behavior, not implementation
|
|
53
|
-
- Aim for 80%+ coverage
|
|
54
|
-
- Fast test execution
|
|
55
|
-
- Fix failing tests immediately
|
|
56
|
-
|
|
57
|
-
### Security
|
|
58
|
-
|
|
59
|
-
- Never commit secrets
|
|
60
|
-
- Validate all inputs
|
|
61
|
-
- Use parameterized queries
|
|
62
|
-
- Keep dependencies updated
|
|
63
|
-
- Follow OWASP guidelines
|
|
64
|
-
|
|
65
|
-
## Architecture Principles
|
|
66
|
-
|
|
67
|
-
1. **Separation of Concerns**
|
|
68
|
-
- Each module has one responsibility
|
|
69
|
-
- Clear boundaries
|
|
70
|
-
- Minimal dependencies
|
|
71
|
-
|
|
72
|
-
2. **Dependency Injection**
|
|
73
|
-
- Don't create dependencies internally
|
|
74
|
-
- Inject through constructor/parameters
|
|
75
|
-
- Easier testing and flexibility
|
|
76
|
-
|
|
77
|
-
3. **Interface-Based Design**
|
|
78
|
-
- Program to interfaces, not implementations
|
|
79
|
-
- Enables polymorphism
|
|
80
|
-
- Facilitates testing (mocking)
|
|
81
|
-
|
|
82
|
-
4. **Configuration Over Hardcoding**
|
|
83
|
-
- Use config files/environment variables
|
|
84
|
-
- Don't hardcode URLs, paths, credentials
|
|
85
|
-
- Environment-specific configs
|
|
86
|
-
|
|
87
|
-
## Performance
|
|
88
|
-
|
|
89
|
-
- Profile before optimizing
|
|
90
|
-
- Optimize bottlenecks only
|
|
91
|
-
- Use caching strategically
|
|
92
|
-
- Minimize database queries
|
|
93
|
-
- Lazy load when possible
|
|
94
|
-
- Consider asynchronous operations
|
|
95
|
-
|
|
96
|
-
## Documentation
|
|
97
|
-
|
|
98
|
-
- README for every project
|
|
99
|
-
- API documentation (JSDoc, OpenAPI)
|
|
100
|
-
- Code comments for "why"
|
|
101
|
-
- Architecture diagrams
|
|
102
|
-
- Changelog/release notes
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# Caching Strategy
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
Design and implement multi-layer caching strategies to optimize application performance, reduce database load, and improve user experience.
|
|
5
|
-
|
|
6
|
-
## Caching Layers
|
|
7
|
-
|
|
8
|
-
### 1. Client-Side Caching
|
|
9
|
-
- Browser cache (Cache-Control, ETag)
|
|
10
|
-
- Service Worker caching
|
|
11
|
-
- Local Storage / IndexedDB
|
|
12
|
-
- CDN edge caching
|
|
13
|
-
|
|
14
|
-
### 2. Application-Level Caching
|
|
15
|
-
- In-memory cache (Redis, Memcached)
|
|
16
|
-
- Application process cache
|
|
17
|
-
- Query result caching
|
|
18
|
-
- Computed value caching
|
|
19
|
-
|
|
20
|
-
### 3. Database Caching
|
|
21
|
-
- Query result cache
|
|
22
|
-
- Prepared statement cache
|
|
23
|
-
- Connection pool
|
|
24
|
-
- Buffer pool (InnoDB)
|
|
25
|
-
|
|
26
|
-
## Cache Patterns
|
|
27
|
-
|
|
28
|
-
### Cache-Aside (Lazy Loading)
|
|
29
|
-
1. Check cache
|
|
30
|
-
2. If miss → Query database
|
|
31
|
-
3. Store in cache
|
|
32
|
-
4. Return data
|
|
33
|
-
|
|
34
|
-
**Use when**: Read-heavy, acceptable stale data
|
|
35
|
-
|
|
36
|
-
### Write-Through
|
|
37
|
-
1. Write to cache
|
|
38
|
-
2. Write to database (synchronous)
|
|
39
|
-
3. Return success
|
|
40
|
-
|
|
41
|
-
**Use when**: Data consistency critical
|
|
42
|
-
|
|
43
|
-
### Write-Behind (Write-Back)
|
|
44
|
-
1. Write to cache
|
|
45
|
-
2. Queue database write (async)
|
|
46
|
-
3. Return success
|
|
47
|
-
|
|
48
|
-
**Use when**: High write throughput needed
|
|
49
|
-
|
|
50
|
-
### Read-Through
|
|
51
|
-
Cache handles database reads automatically
|
|
52
|
-
|
|
53
|
-
**Use when**: Simplify application logic
|
|
54
|
-
|
|
55
|
-
### Refresh-Ahead
|
|
56
|
-
Proactively refresh before expiration
|
|
57
|
-
|
|
58
|
-
**Use when**: Predictable access patterns
|
|
59
|
-
|
|
60
|
-
## Cache Invalidation
|
|
61
|
-
|
|
62
|
-
### Time-Based (TTL)
|
|
63
|
-
**Pros**: Simple, predictable
|
|
64
|
-
**Cons**: May serve stale data
|
|
65
|
-
|
|
66
|
-
### Event-Based
|
|
67
|
-
**Pros**: Always fresh
|
|
68
|
-
**Cons**: Complex invalidation logic
|
|
69
|
-
|
|
70
|
-
### Tag-Based
|
|
71
|
-
**Pros**: Flexible, bulk invalidation
|
|
72
|
-
**Cons**: Overhead in management
|
|
73
|
-
|
|
74
|
-
## Cache Key Design
|
|
75
|
-
|
|
76
|
-
### Naming Conventions
|
|
77
|
-
`<namespace>:<entity>:<id>:<attribute>`
|
|
78
|
-
|
|
79
|
-
Examples:
|
|
80
|
-
- `user:123:profile`
|
|
81
|
-
- `product:456:inventory`
|
|
82
|
-
- `session:abc123:cart`
|
|
83
|
-
|
|
84
|
-
### Hierarchical Keys
|
|
85
|
-
`app:v1:user:123:settings`
|
|
86
|
-
|
|
87
|
-
### Composite Keys
|
|
88
|
-
- `search:query:<hash>:page:1`
|
|
89
|
-
- `filter:category:electronics:brand:apple`
|
|
90
|
-
|
|
91
|
-
## Performance Optimization
|
|
92
|
-
|
|
93
|
-
### Connection Pooling
|
|
94
|
-
- Min/max pool size tuning
|
|
95
|
-
- Connection timeout configuration
|
|
96
|
-
- Health checks for stale connections
|
|
97
|
-
|
|
98
|
-
### Compression
|
|
99
|
-
- Compress large values (>1KB)
|
|
100
|
-
- Trade CPU for memory savings
|
|
101
|
-
- Use MessagePack or Snappy
|
|
102
|
-
|
|
103
|
-
### Batch Operations
|
|
104
|
-
- Pipeline multiple commands
|
|
105
|
-
- Reduce network round trips
|
|
106
|
-
|
|
107
|
-
### Read Replicas
|
|
108
|
-
- Separate read/write connections
|
|
109
|
-
- Route heavy reads to replicas
|
|
110
|
-
- Monitor replication lag
|
|
111
|
-
|
|
112
|
-
## Monitoring & Metrics
|
|
113
|
-
|
|
114
|
-
### Key Metrics
|
|
115
|
-
- Hit rate (hits / (hits + misses))
|
|
116
|
-
- Miss rate
|
|
117
|
-
- Eviction rate
|
|
118
|
-
- Memory usage
|
|
119
|
-
- Latency (p50, p95, p99)
|
|
120
|
-
|
|
121
|
-
### Alerts
|
|
122
|
-
- Hit rate < 80%
|
|
123
|
-
- Memory usage > 85%
|
|
124
|
-
- Eviction rate spike
|
|
125
|
-
- Replication lag > 1s
|
|
126
|
-
|
|
127
|
-
## Eviction Policies
|
|
128
|
-
- **noeviction**: Return error when full
|
|
129
|
-
- **allkeys-lru**: Evict least recently used
|
|
130
|
-
- **volatile-lru**: Evict LRU with TTL set
|
|
131
|
-
- **allkeys-random**: Random eviction
|
|
132
|
-
- **volatile-ttl**: Evict soonest expiring
|
|
133
|
-
|
|
134
|
-
## Common Pitfalls
|
|
135
|
-
|
|
136
|
-
### Cache Stampede
|
|
137
|
-
**Problem**: Many requests hit DB on cache miss
|
|
138
|
-
**Solution**: Probabilistic early expiration, lock-based refresh, always return stale data while refreshing
|
|
139
|
-
|
|
140
|
-
### Cache Penetration
|
|
141
|
-
**Problem**: Queries for non-existent data bypass cache
|
|
142
|
-
**Solution**: Cache null results with short TTL
|
|
143
|
-
|
|
144
|
-
### Hot Key Problem
|
|
145
|
-
**Problem**: Single key gets massive traffic
|
|
146
|
-
**Solution**: Key sharding, local cache, load balancing
|
|
147
|
-
|
|
148
|
-
### Cache Avalanche
|
|
149
|
-
**Problem**: Many keys expire simultaneously
|
|
150
|
-
**Solution**: Add jitter to TTL (TTL ± random)
|
|
151
|
-
|
|
152
|
-
## Design Checklist
|
|
153
|
-
|
|
154
|
-
- [ ] Cache layers identified (client, app, DB)
|
|
155
|
-
- [ ] Cache pattern selected (cache-aside, write-through, etc.)
|
|
156
|
-
- [ ] Invalidation strategy defined
|
|
157
|
-
- [ ] Key naming convention established
|
|
158
|
-
- [ ] TTL values justified
|
|
159
|
-
- [ ] Eviction policy configured
|
|
160
|
-
- [ ] Connection pooling set up
|
|
161
|
-
- [ ] Monitoring/alerting configured
|
|
162
|
-
- [ ] Security measures implemented
|
|
163
|
-
- [ ] Cache stampede prevention
|
|
164
|
-
- [ ] Performance testing completed
|
|
165
|
-
- [ ] Documentation updated
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# CI/CD Pipelines
|
|
2
|
-
|
|
3
|
-
Automate build, test, and deployment processes. Implement continuous integration and continuous delivery for reliable, fast releases.
|
|
4
|
-
|
|
5
|
-
## Do's ✅
|
|
6
|
-
|
|
7
|
-
```yaml
|
|
8
|
-
# ✅ Good: Comprehensive pipeline (GitHub Actions)
|
|
9
|
-
name: CI/CD
|
|
10
|
-
on:
|
|
11
|
-
push:
|
|
12
|
-
branches: [main]
|
|
13
|
-
pull_request:
|
|
14
|
-
|
|
15
|
-
jobs:
|
|
16
|
-
test:
|
|
17
|
-
runs-on: ubuntu-latest
|
|
18
|
-
steps:
|
|
19
|
-
- uses: actions/checkout@v3
|
|
20
|
-
- uses: actions/setup-node@v3
|
|
21
|
-
with:
|
|
22
|
-
node-version: '18'
|
|
23
|
-
cache: 'npm'
|
|
24
|
-
- run: npm ci
|
|
25
|
-
- run: npm run lint
|
|
26
|
-
- run: npm test
|
|
27
|
-
- run: npm run build
|
|
28
|
-
|
|
29
|
-
deploy:
|
|
30
|
-
needs: test
|
|
31
|
-
if: github.ref == 'refs/heads/main'
|
|
32
|
-
runs-on: ubuntu-latest
|
|
33
|
-
steps:
|
|
34
|
-
- name: Deploy
|
|
35
|
-
run: ./deploy.sh production
|
|
36
|
-
env:
|
|
37
|
-
AWS_KEY: ${{ secrets.AWS_KEY }}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Don'ts ❌
|
|
41
|
-
|
|
42
|
-
```yaml
|
|
43
|
-
# ❌ Bad: Deploy without testing
|
|
44
|
-
on: push
|
|
45
|
-
jobs:
|
|
46
|
-
deploy:
|
|
47
|
-
steps:
|
|
48
|
-
- run: ./deploy.sh # YOLO!
|
|
49
|
-
|
|
50
|
-
# ❌ Bad: Secrets in code
|
|
51
|
-
env:
|
|
52
|
-
API_KEY: "sk_live_abc123" # Never!
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Best Practices
|
|
56
|
-
- Run tests on every commit
|
|
57
|
-
- Use secrets management
|
|
58
|
-
- Implement rollback strategies
|
|
59
|
-
- Use artifact caching
|
|
60
|
-
- Implement deployment gates for production
|
|
61
|
-
- Monitor deployment health
|