s9n-devops-agent 2.0.14 → 2.0.18-dev.1
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/House_Rules_Contracts/API_CONTRACT.md +612 -0
- package/House_Rules_Contracts/DATABASE_SCHEMA_CONTRACT.md +373 -0
- package/House_Rules_Contracts/DEVOPS_AGENT_INSTRUCTIONS.md +743 -0
- package/House_Rules_Contracts/FEATURES_CONTRACT.md +655 -0
- package/House_Rules_Contracts/INFRA_CONTRACT.md +638 -0
- package/House_Rules_Contracts/README.md +671 -0
- package/House_Rules_Contracts/SQL_CONTRACT.json +346 -0
- package/House_Rules_Contracts/THIRD_PARTY_INTEGRATIONS.md +604 -0
- package/README.md +93 -143
- package/bin/cs-devops-agent +20 -2
- package/houserules.md +1412 -0
- package/houserules_structured.md +1442 -0
- package/package.json +6 -2
- package/scripts/generate-ai-commit.js +135 -0
- package/scripts/local-install.sh +42 -0
- package/src/agent-chat.js +457 -0
- package/src/credentials-manager.js +1 -1
- package/src/cs-devops-agent-worker.js +84 -4
- package/src/house-rules-manager.js +4 -14
- package/src/session-coordinator.js +165 -15
- package/src/setup-cs-devops-agent.js +218 -242
- package/src/worktree-manager.js +2 -1
- package/start-devops-session.sh +9 -2
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
# Third Party Integrations Contract
|
|
2
|
+
|
|
3
|
+
**Last Updated:** 2024-12-02
|
|
4
|
+
**Version:** 1.0.0
|
|
5
|
+
**Status:** Initial Template
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
|
|
11
|
+
This contract documents **all third-party service integrations** in the project. Coding agents **MUST check this file before integrating external services** to:
|
|
12
|
+
- Reuse existing integrations and binding modules
|
|
13
|
+
- Avoid duplicate API clients
|
|
14
|
+
- Maintain consistent error handling
|
|
15
|
+
- Centralize API key management
|
|
16
|
+
- Prevent vendor lock-in through abstraction layers
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Change Log
|
|
21
|
+
|
|
22
|
+
| Date | Version | Agent/Author | Changes | Impact |
|
|
23
|
+
|------|---------|--------------|---------|--------|
|
|
24
|
+
| 2024-12-02 | 1.0.0 | DevOps Agent | Initial template creation | N/A - Template only |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Integration Overview
|
|
29
|
+
|
|
30
|
+
| Service | Purpose | Status | Binding Module | Monthly Cost | Critical |
|
|
31
|
+
|---------|---------|--------|----------------|--------------|----------|
|
|
32
|
+
| [Service Name] | [What it does] | Active/Deprecated | [Module path] | $X | YES/NO |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Integrations
|
|
37
|
+
|
|
38
|
+
### Integration Template
|
|
39
|
+
|
|
40
|
+
#### [Service Name]
|
|
41
|
+
|
|
42
|
+
**Added:** [YYYY-MM-DD]
|
|
43
|
+
**Last Modified:** [YYYY-MM-DD]
|
|
44
|
+
**Status:** `active` | `deprecated` | `testing`
|
|
45
|
+
**Deprecation Date:** [YYYY-MM-DD] *(if applicable)*
|
|
46
|
+
|
|
47
|
+
**Purpose:**
|
|
48
|
+
[Why we use this service and what problem it solves]
|
|
49
|
+
|
|
50
|
+
**Provider Information:**
|
|
51
|
+
- **Website:** [https://service.com](https://service.com)
|
|
52
|
+
- **Documentation:** [https://docs.service.com](https://docs.service.com)
|
|
53
|
+
- **Support:** [support email/link]
|
|
54
|
+
- **Status Page:** [https://status.service.com](https://status.service.com)
|
|
55
|
+
|
|
56
|
+
**Plan & Pricing:**
|
|
57
|
+
- **Plan:** [Free/Starter/Pro/Enterprise]
|
|
58
|
+
- **Monthly Cost:** $[amount]
|
|
59
|
+
- **Rate Limits:** [e.g., 1000 requests/hour]
|
|
60
|
+
- **Quotas:** [e.g., 10GB storage, 1M API calls]
|
|
61
|
+
- **Overage Charges:** $[amount] per [unit]
|
|
62
|
+
|
|
63
|
+
**Authentication:**
|
|
64
|
+
- **Method:** API Key / OAuth 2.0 / Basic Auth / JWT
|
|
65
|
+
- **Key Location:** Environment variable `[VAR_NAME]`
|
|
66
|
+
- **Key Rotation:** [Frequency and process]
|
|
67
|
+
- **Scopes/Permissions:** [Required permissions]
|
|
68
|
+
|
|
69
|
+
**Binding Module:**
|
|
70
|
+
- **Location:** `src/integrations/[service-name]/`
|
|
71
|
+
- **Main File:** `src/integrations/[service-name]/client.js`
|
|
72
|
+
- **Configuration:** `src/integrations/[service-name]/config.js`
|
|
73
|
+
- **Types/Interfaces:** `src/integrations/[service-name]/types.js`
|
|
74
|
+
|
|
75
|
+
**Module Structure:**
|
|
76
|
+
```
|
|
77
|
+
src/integrations/[service-name]/
|
|
78
|
+
├── client.js # Main client class
|
|
79
|
+
├── config.js # Configuration and env vars
|
|
80
|
+
├── types.js # Type definitions
|
|
81
|
+
├── errors.js # Custom error classes
|
|
82
|
+
├── utils.js # Helper functions
|
|
83
|
+
└── README.md # Integration-specific docs
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**API Client Class:**
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
/**
|
|
90
|
+
* [Service Name] API Client
|
|
91
|
+
*
|
|
92
|
+
* Provides abstraction layer for [Service] API.
|
|
93
|
+
* All modules MUST use this client instead of direct API calls.
|
|
94
|
+
*/
|
|
95
|
+
class ServiceNameClient {
|
|
96
|
+
constructor(apiKey, options = {}) {
|
|
97
|
+
this.apiKey = apiKey;
|
|
98
|
+
this.baseUrl = options.baseUrl || 'https://api.service.com/v1';
|
|
99
|
+
this.timeout = options.timeout || 30000;
|
|
100
|
+
this.retryAttempts = options.retryAttempts || 3;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Example method
|
|
105
|
+
*/
|
|
106
|
+
async methodName(params) {
|
|
107
|
+
// Implementation with error handling, retries, logging
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
module.exports = ServiceNameClient;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Environment Variables:**
|
|
115
|
+
|
|
116
|
+
| Variable | Required | Default | Description | Example |
|
|
117
|
+
|----------|----------|---------|-------------|---------|
|
|
118
|
+
| `SERVICE_API_KEY` | YES | - | API authentication key | `sk_live_...` |
|
|
119
|
+
| `SERVICE_BASE_URL` | NO | `https://api...` | API base URL | `https://api.service.com` |
|
|
120
|
+
| `SERVICE_TIMEOUT` | NO | `30000` | Request timeout (ms) | `60000` |
|
|
121
|
+
| `SERVICE_RETRY_ATTEMPTS` | NO | `3` | Max retry attempts | `5` |
|
|
122
|
+
|
|
123
|
+
**Used By Modules:**
|
|
124
|
+
|
|
125
|
+
| Module | File | Function | Usage |
|
|
126
|
+
|--------|------|----------|-------|
|
|
127
|
+
| [module-name] | `src/path/to/file.js` | `functionName()` | [How it uses the service] |
|
|
128
|
+
|
|
129
|
+
**API Endpoints Used:**
|
|
130
|
+
|
|
131
|
+
| Endpoint | Method | Purpose | Rate Limit | Cost |
|
|
132
|
+
|----------|--------|---------|------------|------|
|
|
133
|
+
| `/endpoint` | POST | [What it does] | 100/min | $0.01/call |
|
|
134
|
+
|
|
135
|
+
**Data Flow:**
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
[Your Module]
|
|
139
|
+
↓
|
|
140
|
+
[Binding Module: ServiceNameClient]
|
|
141
|
+
↓
|
|
142
|
+
[Service API]
|
|
143
|
+
↓
|
|
144
|
+
[Response Processing]
|
|
145
|
+
↓
|
|
146
|
+
[Return to Your Module]
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Error Handling:**
|
|
150
|
+
|
|
151
|
+
| Error Type | HTTP Code | Handling Strategy | Retry |
|
|
152
|
+
|------------|-----------|-------------------|-------|
|
|
153
|
+
| Rate Limit | 429 | Exponential backoff | YES |
|
|
154
|
+
| Auth Error | 401 | Log and alert | NO |
|
|
155
|
+
| Server Error | 500 | Retry with backoff | YES |
|
|
156
|
+
| Validation | 400 | Return to caller | NO |
|
|
157
|
+
|
|
158
|
+
**Custom Error Classes:**
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
class ServiceNameError extends Error {
|
|
162
|
+
constructor(message, code, originalError) {
|
|
163
|
+
super(message);
|
|
164
|
+
this.name = 'ServiceNameError';
|
|
165
|
+
this.code = code;
|
|
166
|
+
this.originalError = originalError;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
class ServiceNameRateLimitError extends ServiceNameError { ... }
|
|
171
|
+
class ServiceNameAuthError extends ServiceNameError { ... }
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Retry Logic:**
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
async function withRetry(fn, maxAttempts = 3) {
|
|
178
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
179
|
+
try {
|
|
180
|
+
return await fn();
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (attempt === maxAttempts || !isRetryable(error)) {
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
await sleep(Math.pow(2, attempt) * 1000); // Exponential backoff
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Logging:**
|
|
192
|
+
|
|
193
|
+
- **Success:** Log at `debug` level with request/response summary
|
|
194
|
+
- **Errors:** Log at `error` level with full context
|
|
195
|
+
- **Rate Limits:** Log at `warn` level with retry info
|
|
196
|
+
- **Sensitive Data:** Never log API keys, tokens, or PII
|
|
197
|
+
|
|
198
|
+
**Testing:**
|
|
199
|
+
|
|
200
|
+
- **Unit Tests:** `test_cases/integrations/[service-name].test.js`
|
|
201
|
+
- **Integration Tests:** `test_cases/integration/[service-name].integration.test.js`
|
|
202
|
+
- **Mocks:** `test_cases/mocks/[service-name].mock.js`
|
|
203
|
+
- **Coverage:** [X]%
|
|
204
|
+
|
|
205
|
+
**Mocking for Tests:**
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
// Mock client for testing
|
|
209
|
+
class MockServiceNameClient {
|
|
210
|
+
async methodName(params) {
|
|
211
|
+
// Return mock data
|
|
212
|
+
return { success: true, data: mockData };
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Monitoring:**
|
|
218
|
+
|
|
219
|
+
- **Metrics Tracked:**
|
|
220
|
+
- Request count
|
|
221
|
+
- Error rate
|
|
222
|
+
- Response time (p50, p95, p99)
|
|
223
|
+
- Rate limit hits
|
|
224
|
+
- Cost per day/month
|
|
225
|
+
|
|
226
|
+
- **Alerts:**
|
|
227
|
+
- Error rate > 5%
|
|
228
|
+
- Response time > 5s
|
|
229
|
+
- Rate limit exceeded
|
|
230
|
+
- Daily cost > $X
|
|
231
|
+
|
|
232
|
+
**Fallback Strategy:**
|
|
233
|
+
|
|
234
|
+
- **Primary:** [Service Name]
|
|
235
|
+
- **Fallback:** [Alternative service or manual process]
|
|
236
|
+
- **Degraded Mode:** [What happens if service is down]
|
|
237
|
+
|
|
238
|
+
**Migration Notes:**
|
|
239
|
+
|
|
240
|
+
If replacing this service:
|
|
241
|
+
1. [Steps to migrate to alternative]
|
|
242
|
+
2. [Data export process]
|
|
243
|
+
3. [Code changes required]
|
|
244
|
+
4. [Testing checklist]
|
|
245
|
+
|
|
246
|
+
**Security Considerations:**
|
|
247
|
+
|
|
248
|
+
- API keys stored in environment variables (never in code)
|
|
249
|
+
- Keys rotated every [frequency]
|
|
250
|
+
- Minimum required permissions/scopes
|
|
251
|
+
- Data encryption in transit (TLS 1.2+)
|
|
252
|
+
- Data encryption at rest (if applicable)
|
|
253
|
+
- Compliance: [GDPR, SOC2, HIPAA, etc.]
|
|
254
|
+
|
|
255
|
+
**Performance Notes:**
|
|
256
|
+
|
|
257
|
+
- Average response time: [X]ms
|
|
258
|
+
- Timeout configured: [X]ms
|
|
259
|
+
- Connection pooling: [YES/NO]
|
|
260
|
+
- Caching strategy: [Description]
|
|
261
|
+
- Batch operations: [Supported/Not supported]
|
|
262
|
+
|
|
263
|
+
**Dependencies:**
|
|
264
|
+
|
|
265
|
+
**NPM Packages:**
|
|
266
|
+
- `[package-name]@[version]` - [Purpose]
|
|
267
|
+
|
|
268
|
+
**Internal Dependencies:**
|
|
269
|
+
- `src/utils/http-client.js` - HTTP wrapper
|
|
270
|
+
- `src/utils/logger.js` - Logging
|
|
271
|
+
- `src/config/env.js` - Environment config
|
|
272
|
+
|
|
273
|
+
**Changelog:**
|
|
274
|
+
|
|
275
|
+
| Date | Version | Changes | Breaking |
|
|
276
|
+
|------|---------|---------|----------|
|
|
277
|
+
| 2024-01-15 | 1.0.0 | Initial integration | N/A |
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Example Integrations
|
|
282
|
+
|
|
283
|
+
### SendGrid (Email Service)
|
|
284
|
+
|
|
285
|
+
**Added:** 2024-01-15
|
|
286
|
+
**Last Modified:** 2024-01-15
|
|
287
|
+
**Status:** `active`
|
|
288
|
+
|
|
289
|
+
**Purpose:**
|
|
290
|
+
Transactional email delivery for user notifications, password resets, and system alerts.
|
|
291
|
+
|
|
292
|
+
**Provider Information:**
|
|
293
|
+
- **Website:** [https://sendgrid.com](https://sendgrid.com)
|
|
294
|
+
- **Documentation:** [https://docs.sendgrid.com](https://docs.sendgrid.com)
|
|
295
|
+
- **Support:** support@sendgrid.com
|
|
296
|
+
- **Status Page:** [https://status.sendgrid.com](https://status.sendgrid.com)
|
|
297
|
+
|
|
298
|
+
**Plan & Pricing:**
|
|
299
|
+
- **Plan:** Pro
|
|
300
|
+
- **Monthly Cost:** $89.95
|
|
301
|
+
- **Rate Limits:** 100,000 emails/month
|
|
302
|
+
- **Quotas:** 1M API calls/month
|
|
303
|
+
- **Overage Charges:** $0.00085 per email
|
|
304
|
+
|
|
305
|
+
**Authentication:**
|
|
306
|
+
- **Method:** API Key
|
|
307
|
+
- **Key Location:** `SENDGRID_API_KEY`
|
|
308
|
+
- **Key Rotation:** Quarterly
|
|
309
|
+
- **Scopes:** `mail.send`, `mail.batch.send`
|
|
310
|
+
|
|
311
|
+
**Binding Module:**
|
|
312
|
+
- **Location:** `src/integrations/sendgrid/`
|
|
313
|
+
- **Main File:** `src/integrations/sendgrid/client.js`
|
|
314
|
+
|
|
315
|
+
**Environment Variables:**
|
|
316
|
+
|
|
317
|
+
| Variable | Required | Default | Description |
|
|
318
|
+
|----------|----------|---------|-------------|
|
|
319
|
+
| `SENDGRID_API_KEY` | YES | - | SendGrid API key |
|
|
320
|
+
| `SENDGRID_FROM_EMAIL` | YES | - | Default sender email |
|
|
321
|
+
| `SENDGRID_FROM_NAME` | NO | `App Name` | Default sender name |
|
|
322
|
+
|
|
323
|
+
**Used By Modules:**
|
|
324
|
+
|
|
325
|
+
| Module | File | Function | Usage |
|
|
326
|
+
|--------|------|----------|-------|
|
|
327
|
+
| auth-service | `src/auth/register.js` | `sendVerificationEmail()` | User email verification |
|
|
328
|
+
| auth-service | `src/auth/password-reset.js` | `sendPasswordResetEmail()` | Password reset emails |
|
|
329
|
+
| notification-service | `src/notifications/email.js` | `sendNotification()` | User notifications |
|
|
330
|
+
|
|
331
|
+
**API Endpoints Used:**
|
|
332
|
+
|
|
333
|
+
| Endpoint | Method | Purpose | Rate Limit |
|
|
334
|
+
|----------|--------|---------|------------|
|
|
335
|
+
| `/v3/mail/send` | POST | Send single email | 600/min |
|
|
336
|
+
| `/v3/mail/batch` | POST | Send batch emails | 100/min |
|
|
337
|
+
|
|
338
|
+
**Error Handling:**
|
|
339
|
+
|
|
340
|
+
| Error Type | HTTP Code | Handling Strategy | Retry |
|
|
341
|
+
|------------|-----------|-------------------|-------|
|
|
342
|
+
| Rate Limit | 429 | Wait and retry | YES |
|
|
343
|
+
| Auth Error | 401 | Alert admin | NO |
|
|
344
|
+
| Invalid Email | 400 | Log and skip | NO |
|
|
345
|
+
| Server Error | 500 | Retry 3x | YES |
|
|
346
|
+
|
|
347
|
+
**Monitoring:**
|
|
348
|
+
- Daily email count
|
|
349
|
+
- Delivery rate (target: >99%)
|
|
350
|
+
- Bounce rate (alert if >2%)
|
|
351
|
+
- Spam complaints (alert if >0.1%)
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
### Stripe (Payment Processing)
|
|
356
|
+
|
|
357
|
+
**Added:** 2024-01-20
|
|
358
|
+
**Last Modified:** 2024-01-20
|
|
359
|
+
**Status:** `active`
|
|
360
|
+
|
|
361
|
+
**Purpose:**
|
|
362
|
+
Payment processing, subscription management, and invoice generation.
|
|
363
|
+
|
|
364
|
+
**Provider Information:**
|
|
365
|
+
- **Website:** [https://stripe.com](https://stripe.com)
|
|
366
|
+
- **Documentation:** [https://stripe.com/docs](https://stripe.com/docs)
|
|
367
|
+
- **Support:** Stripe Dashboard
|
|
368
|
+
- **Status Page:** [https://status.stripe.com](https://status.stripe.com)
|
|
369
|
+
|
|
370
|
+
**Plan & Pricing:**
|
|
371
|
+
- **Plan:** Standard
|
|
372
|
+
- **Monthly Cost:** $0 base + transaction fees
|
|
373
|
+
- **Transaction Fee:** 2.9% + $0.30 per charge
|
|
374
|
+
- **Rate Limits:** 100 requests/second
|
|
375
|
+
|
|
376
|
+
**Authentication:**
|
|
377
|
+
- **Method:** API Key (Secret Key)
|
|
378
|
+
- **Key Location:** `STRIPE_SECRET_KEY`
|
|
379
|
+
- **Publishable Key:** `STRIPE_PUBLISHABLE_KEY` (for frontend)
|
|
380
|
+
- **Webhook Secret:** `STRIPE_WEBHOOK_SECRET`
|
|
381
|
+
|
|
382
|
+
**Binding Module:**
|
|
383
|
+
- **Location:** `src/integrations/stripe/`
|
|
384
|
+
- **Main File:** `src/integrations/stripe/client.js`
|
|
385
|
+
|
|
386
|
+
**Environment Variables:**
|
|
387
|
+
|
|
388
|
+
| Variable | Required | Default | Description |
|
|
389
|
+
|----------|----------|---------|-------------|
|
|
390
|
+
| `STRIPE_SECRET_KEY` | YES | - | Stripe secret API key |
|
|
391
|
+
| `STRIPE_PUBLISHABLE_KEY` | YES | - | Stripe publishable key (frontend) |
|
|
392
|
+
| `STRIPE_WEBHOOK_SECRET` | YES | - | Webhook signature verification |
|
|
393
|
+
|
|
394
|
+
**Used By Modules:**
|
|
395
|
+
|
|
396
|
+
| Module | File | Function | Usage |
|
|
397
|
+
|--------|------|----------|-------|
|
|
398
|
+
| payment-service | `src/payments/checkout.js` | `createPaymentIntent()` | Process payments |
|
|
399
|
+
| subscription-service | `src/subscriptions/manage.js` | `createSubscription()` | Manage subscriptions |
|
|
400
|
+
| webhook-handler | `src/webhooks/stripe.js` | `handleWebhook()` | Process Stripe events |
|
|
401
|
+
|
|
402
|
+
**Webhook Events Handled:**
|
|
403
|
+
|
|
404
|
+
| Event | Handler | Purpose |
|
|
405
|
+
|-------|---------|---------|
|
|
406
|
+
| `payment_intent.succeeded` | `handlePaymentSuccess()` | Confirm payment |
|
|
407
|
+
| `payment_intent.failed` | `handlePaymentFailure()` | Handle failed payment |
|
|
408
|
+
| `customer.subscription.created` | `handleSubscriptionCreated()` | New subscription |
|
|
409
|
+
| `customer.subscription.deleted` | `handleSubscriptionCancelled()` | Cancelled subscription |
|
|
410
|
+
|
|
411
|
+
**Security:**
|
|
412
|
+
- PCI DSS compliance via Stripe
|
|
413
|
+
- No credit card data stored locally
|
|
414
|
+
- Webhook signature verification required
|
|
415
|
+
- API keys never exposed to frontend
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
### AWS S3 (File Storage)
|
|
420
|
+
|
|
421
|
+
**Added:** 2024-01-10
|
|
422
|
+
**Last Modified:** 2024-01-10
|
|
423
|
+
**Status:** `active`
|
|
424
|
+
|
|
425
|
+
**Purpose:**
|
|
426
|
+
Object storage for user uploads, backups, and static assets.
|
|
427
|
+
|
|
428
|
+
**Provider Information:**
|
|
429
|
+
- **Website:** [https://aws.amazon.com/s3](https://aws.amazon.com/s3)
|
|
430
|
+
- **Documentation:** [https://docs.aws.amazon.com/s3](https://docs.aws.amazon.com/s3)
|
|
431
|
+
- **Support:** AWS Support Console
|
|
432
|
+
|
|
433
|
+
**Plan & Pricing:**
|
|
434
|
+
- **Storage:** $0.023 per GB/month
|
|
435
|
+
- **Requests:** $0.0004 per 1000 GET requests
|
|
436
|
+
- **Data Transfer:** $0.09 per GB (out)
|
|
437
|
+
- **Estimated Monthly:** $50
|
|
438
|
+
|
|
439
|
+
**Authentication:**
|
|
440
|
+
- **Method:** IAM Access Keys
|
|
441
|
+
- **Access Key ID:** `AWS_ACCESS_KEY_ID`
|
|
442
|
+
- **Secret Access Key:** `AWS_SECRET_ACCESS_KEY`
|
|
443
|
+
- **Region:** `AWS_REGION`
|
|
444
|
+
|
|
445
|
+
**Binding Module:**
|
|
446
|
+
- **Location:** `src/integrations/aws-s3/`
|
|
447
|
+
- **Main File:** `src/integrations/aws-s3/client.js`
|
|
448
|
+
|
|
449
|
+
**Environment Variables:**
|
|
450
|
+
|
|
451
|
+
| Variable | Required | Default | Description |
|
|
452
|
+
|----------|----------|---------|-------------|
|
|
453
|
+
| `AWS_ACCESS_KEY_ID` | YES | - | AWS access key |
|
|
454
|
+
| `AWS_SECRET_ACCESS_KEY` | YES | - | AWS secret key |
|
|
455
|
+
| `AWS_REGION` | YES | - | AWS region (e.g., us-east-1) |
|
|
456
|
+
| `AWS_S3_BUCKET` | YES | - | S3 bucket name |
|
|
457
|
+
|
|
458
|
+
**Used By Modules:**
|
|
459
|
+
|
|
460
|
+
| Module | File | Function | Usage |
|
|
461
|
+
|--------|------|----------|-------|
|
|
462
|
+
| upload-service | `src/uploads/handler.js` | `uploadFile()` | User file uploads |
|
|
463
|
+
| backup-service | `src/backups/database.js` | `backupDatabase()` | Database backups |
|
|
464
|
+
| asset-service | `src/assets/manager.js` | `storeAsset()` | Static asset storage |
|
|
465
|
+
|
|
466
|
+
**Bucket Configuration:**
|
|
467
|
+
- **Bucket Name:** `[your-app]-[environment]`
|
|
468
|
+
- **Versioning:** Enabled
|
|
469
|
+
- **Encryption:** AES-256
|
|
470
|
+
- **Public Access:** Blocked (use signed URLs)
|
|
471
|
+
- **Lifecycle Policy:** Delete after 90 days (for temp files)
|
|
472
|
+
|
|
473
|
+
**Security:**
|
|
474
|
+
- IAM role with minimum required permissions
|
|
475
|
+
- Bucket policy restricts access
|
|
476
|
+
- Signed URLs for temporary access (expire in 1 hour)
|
|
477
|
+
- Server-side encryption enabled
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
## Integration Categories
|
|
482
|
+
|
|
483
|
+
### Communication
|
|
484
|
+
- **SendGrid** - Email delivery
|
|
485
|
+
- **Twilio** - SMS notifications
|
|
486
|
+
- **Slack** - Team notifications
|
|
487
|
+
|
|
488
|
+
### Payments
|
|
489
|
+
- **Stripe** - Payment processing
|
|
490
|
+
- **PayPal** - Alternative payment method
|
|
491
|
+
|
|
492
|
+
### Storage
|
|
493
|
+
- **AWS S3** - Object storage
|
|
494
|
+
- **Cloudinary** - Image/video hosting
|
|
495
|
+
|
|
496
|
+
### Analytics
|
|
497
|
+
- **Google Analytics** - Web analytics
|
|
498
|
+
- **Mixpanel** - Product analytics
|
|
499
|
+
- **Sentry** - Error tracking
|
|
500
|
+
|
|
501
|
+
### Authentication
|
|
502
|
+
- **Auth0** - Identity management
|
|
503
|
+
- **Google OAuth** - Social login
|
|
504
|
+
- **GitHub OAuth** - Developer login
|
|
505
|
+
|
|
506
|
+
### Infrastructure
|
|
507
|
+
- **AWS** - Cloud infrastructure
|
|
508
|
+
- **Vercel** - Frontend hosting
|
|
509
|
+
- **MongoDB Atlas** - Database hosting
|
|
510
|
+
|
|
511
|
+
---
|
|
512
|
+
|
|
513
|
+
## Notes for Coding Agents
|
|
514
|
+
|
|
515
|
+
### CRITICAL RULES:
|
|
516
|
+
|
|
517
|
+
1. **ALWAYS check this contract before integrating external services**
|
|
518
|
+
2. **REUSE existing binding modules** - never create duplicate clients
|
|
519
|
+
3. **NEVER hardcode API keys** - always use environment variables
|
|
520
|
+
4. **USE the binding module** - never call third-party APIs directly
|
|
521
|
+
5. **UPDATE this contract** when adding new integrations
|
|
522
|
+
6. **DOCUMENT all environment variables** in INFRA_CONTRACT.md
|
|
523
|
+
7. **ADD proper error handling** using the binding module's error classes
|
|
524
|
+
8. **IMPLEMENT retry logic** for transient failures
|
|
525
|
+
9. **ADD monitoring and alerts** for critical integrations
|
|
526
|
+
10. **WRITE tests with mocks** - don't call real APIs in tests
|
|
527
|
+
|
|
528
|
+
### Workflow:
|
|
529
|
+
|
|
530
|
+
```
|
|
531
|
+
1. Read THIRD_PARTY_INTEGRATIONS.md
|
|
532
|
+
2. Search for existing integration for the service you need
|
|
533
|
+
3. If integration exists:
|
|
534
|
+
- Import the binding module
|
|
535
|
+
- Use the provided client class
|
|
536
|
+
- Add your module to "Used By Modules" section
|
|
537
|
+
- Follow the documented error handling
|
|
538
|
+
4. If integration doesn't exist:
|
|
539
|
+
- Check if similar service already integrated (avoid duplication)
|
|
540
|
+
- Create new binding module following the template structure
|
|
541
|
+
- Implement client class with error handling and retries
|
|
542
|
+
- Add environment variables to INFRA_CONTRACT.md
|
|
543
|
+
- Document everything in this contract
|
|
544
|
+
- Create tests with mocks
|
|
545
|
+
5. Update changelog and version number
|
|
546
|
+
6. Never call third-party APIs directly - always use binding module
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
### Benefits of Binding Modules:
|
|
550
|
+
|
|
551
|
+
- **Abstraction:** Easy to swap providers without changing application code
|
|
552
|
+
- **Consistency:** Standardized error handling and logging
|
|
553
|
+
- **Testing:** Mockable interfaces for unit tests
|
|
554
|
+
- **Monitoring:** Centralized metrics and alerts
|
|
555
|
+
- **Security:** Single place to manage API keys and rotation
|
|
556
|
+
- **Maintenance:** Update integration logic in one place
|
|
557
|
+
|
|
558
|
+
---
|
|
559
|
+
|
|
560
|
+
## Initial Population Instructions
|
|
561
|
+
|
|
562
|
+
**For DevOps Agent / Coding Agents:**
|
|
563
|
+
|
|
564
|
+
When populating this template for the first time:
|
|
565
|
+
|
|
566
|
+
1. **Scan codebase for third-party API calls:**
|
|
567
|
+
- Search for API client imports
|
|
568
|
+
- Look for HTTP requests to external domains
|
|
569
|
+
- Check package.json for SDK dependencies
|
|
570
|
+
- Review environment variables for API keys
|
|
571
|
+
|
|
572
|
+
2. **Identify all integrations:**
|
|
573
|
+
- Payment processors (Stripe, PayPal)
|
|
574
|
+
- Email services (SendGrid, Mailgun)
|
|
575
|
+
- Cloud storage (AWS S3, Google Cloud Storage)
|
|
576
|
+
- Authentication (Auth0, OAuth providers)
|
|
577
|
+
- Analytics (Google Analytics, Mixpanel)
|
|
578
|
+
- Monitoring (Sentry, DataDog)
|
|
579
|
+
|
|
580
|
+
3. **Document each integration:**
|
|
581
|
+
- Purpose and use cases
|
|
582
|
+
- Binding module location
|
|
583
|
+
- Environment variables
|
|
584
|
+
- Modules that use it
|
|
585
|
+
- Error handling strategy
|
|
586
|
+
- Cost and rate limits
|
|
587
|
+
|
|
588
|
+
4. **Create binding modules if missing:**
|
|
589
|
+
- Wrap direct API calls in abstraction layer
|
|
590
|
+
- Implement error handling and retries
|
|
591
|
+
- Add logging and monitoring
|
|
592
|
+
- Create mock clients for testing
|
|
593
|
+
|
|
594
|
+
**Search Patterns:**
|
|
595
|
+
- `require('stripe')`, `import stripe from`
|
|
596
|
+
- `require('@sendgrid/mail')`
|
|
597
|
+
- `require('aws-sdk')`, `require('@aws-sdk')`
|
|
598
|
+
- `axios.post('https://api.external.com')`
|
|
599
|
+
- Environment variables: `process.env.API_KEY`
|
|
600
|
+
- Config files: `config/*.js`, `.env.example`
|
|
601
|
+
|
|
602
|
+
---
|
|
603
|
+
|
|
604
|
+
*This contract is a living document. Update it with every new integration.*
|