zerocarbon-quickstart 1.0.0

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.
@@ -0,0 +1,437 @@
1
+ # Deployment Guide - Developer Love Demo
2
+
3
+ ## 🎯 Goal
4
+ Deploy a "Hello World" carbon emissions demo that YC partners can test in under 5 minutes.
5
+
6
+ ---
7
+
8
+ ## 📋 Pre-Deployment Checklist
9
+
10
+ ### 1. Update Production API URLs
11
+ Currently using `https://api.zerocarbon.codes` - ensure this points to your **production API**.
12
+
13
+ - [ ] Update API base URL in `index.js`
14
+ - [ ] Update API base URL in `quickstart.py`
15
+ - [ ] Update API base URL in `web-demo.html`
16
+ - [ ] Test all endpoints return valid data
17
+
18
+ ### 2. Enable Public API Testing
19
+ For the demo to work, your API must:
20
+
21
+ - [ ] Allow unauthenticated requests to `/v1/emissions/calculate`
22
+ - [ ] Allow unauthenticated requests to `/v1/calculate/flight`
23
+ - [ ] Allow unauthenticated requests to `/v1/calculate/fuel`
24
+ - [ ] Set rate limit: 1000 requests/day per IP (generous for testing)
25
+ - [ ] Return proper CORS headers for web demo
26
+
27
+ **Add to your API routes:**
28
+ ```typescript
29
+ // Middleware for public endpoints
30
+ export const allowPublicTesting = (req: Request, res: Response, next: NextFunction) => {
31
+ // Skip auth for testing endpoints
32
+ if (req.path.startsWith('/v1/calculate') || req.path === '/v1/emissions/calculate') {
33
+ const ip = req.ip || req.headers['x-forwarded-for'];
34
+
35
+ // Check rate limit (1000/day per IP)
36
+ if (isRateLimited(ip)) {
37
+ return res.status(429).json({
38
+ error: 'Rate limit exceeded. Get free API key: https://app.zerocarbon.codes/signup'
39
+ });
40
+ }
41
+
42
+ return next();
43
+ }
44
+
45
+ // Regular auth for other endpoints
46
+ return verifyAuth(req, res, next);
47
+ };
48
+ ```
49
+
50
+ ### 3. Set Up Monitoring
51
+ Track how many people test your demo:
52
+
53
+ - [ ] Add analytics to quickstart.zerocarbon.codes
54
+ - [ ] Log IP addresses hitting public endpoints
55
+ - [ ] Set up alerts for >100 tests/day (viral signal)
56
+ - [ ] Track conversion: demo → signup → paid
57
+
58
+ ---
59
+
60
+ ## 🚀 Deployment Steps
61
+
62
+ ### Step 1: Deploy Web Demo
63
+
64
+ **Option A: Vercel (Fastest)**
65
+ ```bash
66
+ cd quickstart
67
+ npx vercel --prod
68
+
69
+ # Set custom domain
70
+ vercel domains add quickstart.zerocarbon.codes
71
+ ```
72
+
73
+ **Option B: Netlify**
74
+ ```bash
75
+ cd quickstart
76
+ netlify deploy --prod --dir=.
77
+
78
+ # Add redirect rules in netlify.toml
79
+ ```
80
+
81
+ **Option C: CloudFlare Pages**
82
+ ```bash
83
+ # Via dashboard: New Project → Connect Git → Deploy
84
+ # Set build command: none
85
+ # Set output directory: quickstart/
86
+ ```
87
+
88
+ **Test it:**
89
+ ```bash
90
+ curl https://quickstart.zerocarbon.codes/web-demo.html
91
+ ```
92
+
93
+ ### Step 2: Publish NPM Package
94
+
95
+ ```bash
96
+ cd quickstart
97
+
98
+ # Login to NPM
99
+ npm login
100
+
101
+ # Update package.json with unique name
102
+ # Change "zerocarbon-quickstart" to "your-company-quickstart" if taken
103
+
104
+ # Publish
105
+ npm publish --access public
106
+
107
+ # Test installation
108
+ npm install -g zerocarbon-quickstart
109
+ npx zerocarbon-quickstart
110
+ ```
111
+
112
+ **Important:** Your package name must be unique on NPM. If `zerocarbon-quickstart` is taken, use:
113
+ - `@zerocarbon/quickstart`
114
+ - `zerocarbon-api-demo`
115
+ - `carbon-quickstart`
116
+
117
+ ### Step 3: Deploy to Replit
118
+
119
+ 1. Go to [Replit.com](https://replit.com)
120
+ 2. Click "Create Repl" → "Import from GitHub"
121
+ 3. Enter your GitHub repo URL (or upload files directly)
122
+ 4. Make repl public
123
+ 5. Get shareable link: `https://replit.com/@yourusername/quickstart`
124
+
125
+ **Configure Replit:**
126
+ - Set run command: `node index.js`
127
+ - Set language: Node.js
128
+ - Enable "Always on" (optional, costs credits)
129
+
130
+ ### Step 4: Deploy to CodeSandbox
131
+
132
+ 1. Go to [CodeSandbox.io](https://codesandbox.io)
133
+ 2. Click "Create Sandbox" → "Import from GitHub"
134
+ 3. Enter your repo URL
135
+ 4. Make sandbox public
136
+ 5. Get shareable link: `https://codesandbox.io/s/zerocarbon-quickstart`
137
+
138
+ **Configure CodeSandbox:**
139
+ - Set main file: `index.js`
140
+ - Enable "Hot Reloading"
141
+
142
+ ### Step 5: Create GitHub Repository
143
+
144
+ ```bash
145
+ cd quickstart
146
+ git init
147
+ git add .
148
+ git commit -m "Initial commit: ZeroCarbon API Quickstart"
149
+
150
+ # Create repo on GitHub, then:
151
+ git remote add origin https://github.com/zerocarbon/quickstart.git
152
+ git push -u origin main
153
+
154
+ # Add README badges
155
+ # Add demo GIF/video
156
+ # Add clear instructions
157
+ ```
158
+
159
+ **Repository Structure:**
160
+ ```
161
+ quickstart/
162
+ ├── README.md # Main documentation
163
+ ├── YC_APPLICATION_GUIDE.md # YC-specific guide
164
+ ├── DEPLOYMENT_GUIDE.md # This file
165
+ ├── index.js # Node.js demo
166
+ ├── package.json
167
+ ├── quickstart.py # Python demo
168
+ ├── curl-examples.sh # cURL examples
169
+ ├── web-demo.html # Interactive web demo
170
+ ├── .replitrc # Replit config
171
+ └── .codesandbox/
172
+ └── tasks.json # CodeSandbox config
173
+ ```
174
+
175
+ ---
176
+
177
+ ## 🧪 Testing Checklist
178
+
179
+ Before announcing:
180
+
181
+ ### Test on Multiple Platforms
182
+ - [ ] **Mac Terminal:** `npx zerocarbon-quickstart` works
183
+ - [ ] **Windows PowerShell:** Works without errors
184
+ - [ ] **Linux Terminal:** Works
185
+ - [ ] **Replit:** Opens and runs immediately
186
+ - [ ] **CodeSandbox:** Opens and runs
187
+ - [ ] **Web browser:** https://quickstart.zerocarbon.codes loads
188
+
189
+ ### Test API Endpoints
190
+ - [ ] Electricity calculation returns valid data
191
+ - [ ] Flight calculation works (SFO → JFK)
192
+ - [ ] Vehicle calculation works
193
+ - [ ] Natural gas calculation works
194
+ - [ ] All return proper JSON format
195
+ - [ ] Error messages are helpful
196
+
197
+ ### Test Different Networks
198
+ - [ ] Test from home WiFi
199
+ - [ ] Test from mobile data
200
+ - [ ] Test from VPN (simulates YC office)
201
+ - [ ] Test from different countries (IP)
202
+
203
+ ### Performance
204
+ - [ ] Demo loads in <2 seconds
205
+ - [ ] API responds in <500ms
206
+ - [ ] No rate limit errors during normal use
207
+ - [ ] Handles 100 concurrent users
208
+
209
+ ---
210
+
211
+ ## 🎯 YC Application Integration
212
+
213
+ ### 1. Update Application Text
214
+
215
+ **In "How do you know people want your product?":**
216
+ ```
217
+ We're the fastest carbon API to integrate. Try it yourself:
218
+
219
+ 1. Run `npx zerocarbon-quickstart` in your terminal
220
+ 2. Or visit: https://quickstart.zerocarbon.codes
221
+ 3. Or open: https://replit.com/@zerocarbon/quickstart
222
+
223
+ Developers get their first emissions calculation in under 5 minutes.
224
+ 50 beta users integrated in 18 minutes average (vs. 2-3 hours for competitors).
225
+
226
+ The best part? This demo makes the same API calls our paying customers use.
227
+ It's not a fake demo—it's our production API with zero friction.
228
+ ```
229
+
230
+ ### 2. Add to "Product Demo" Section
231
+
232
+ **Primary CTA:**
233
+ > "Try our API live: https://quickstart.zerocarbon.codes"
234
+
235
+ **Secondary CTA:**
236
+ > "Zero installation: `npx zerocarbon-quickstart`"
237
+
238
+ ### 3. For Video Interview
239
+
240
+ Have this ready to share screen:
241
+ 1. Open terminal
242
+ 2. Run `npx zerocarbon-quickstart`
243
+ 3. Show results in real-time
244
+ 4. Say: "This is what every developer experiences. Zero friction."
245
+
246
+ ---
247
+
248
+ ## 📊 Post-Launch Monitoring
249
+
250
+ ### Metrics to Track
251
+
252
+ **Usage Metrics:**
253
+ - NPM downloads per day
254
+ - Web demo visits per day
255
+ - Replit forks
256
+ - CodeSandbox opens
257
+ - API calls from demo endpoints
258
+
259
+ **Conversion Metrics:**
260
+ - Demo → API signup %
261
+ - Demo → Paid customer %
262
+ - Time from demo to first paid API call
263
+ - Demo → YC application submission (if tracking)
264
+
265
+ **Virality Metrics:**
266
+ - Twitter mentions of demo link
267
+ - GitHub stars on quickstart repo
268
+ - Reddit posts about demo
269
+ - HN upvotes (if posted)
270
+
271
+ ### Set Up Alerts
272
+
273
+ **High Priority:**
274
+ - >100 demo runs in 24 hours (potential virality)
275
+ - API errors >5% (fix immediately)
276
+ - Demo downtime >1 minute
277
+
278
+ **Medium Priority:**
279
+ - Rate limit hits (scale or adjust limits)
280
+ - Slow API responses >1s
281
+ - Browser console errors
282
+
283
+ ---
284
+
285
+ ## 🚨 Emergency Procedures
286
+
287
+ ### If Demo Goes Viral
288
+
289
+ **Scenario:** YC partner tweets demo → 10,000 developers try it
290
+
291
+ **Actions:**
292
+ 1. **Scale API immediately:**
293
+ - Add Cloudflare in front
294
+ - Increase rate limits temporarily
295
+ - Cache common calculations
296
+
297
+ 2. **Monitor costs:**
298
+ - Track API compute costs
299
+ - Set billing alerts
300
+ - Be ready to add rate limits
301
+
302
+ 3. **Capture leads:**
303
+ - Add "Want API key?" banner
304
+ - Offer priority access
305
+ - Track conversion rate
306
+
307
+ ### If API Goes Down
308
+
309
+ **Scenario:** Demo fails during YC partner test
310
+
311
+ **Backup Plan:**
312
+ - Add fallback to mock data in demos
313
+ - Show "API temporarily unavailable" message
314
+ - Capture email for notification when fixed
315
+
316
+ **Prevention:**
317
+ - Set up uptime monitoring (UptimeRobot, Pingdom)
318
+ - Have backup API endpoint ready
319
+ - Test failover before launch
320
+
321
+ ---
322
+
323
+ ## ✅ Pre-YC Submission Checklist
324
+
325
+ **24 Hours Before Submission:**
326
+ - [ ] Test demo from 3 different devices
327
+ - [ ] Verify all links work in application
328
+ - [ ] Check API is responding <500ms
329
+ - [ ] Monitor setup and working
330
+ - [ ] Rate limits tested and appropriate
331
+ - [ ] Error messages are helpful, not technical
332
+ - [ ] Demo repo is public
333
+ - [ ] README has clear instructions
334
+ - [ ] Video demo recorded (optional)
335
+
336
+ **1 Hour Before Submission:**
337
+ - [ ] Test one final time
338
+ - [ ] Check all links in application
339
+ - [ ] Verify analytics are tracking
340
+ - [ ] Monitor dashboard is green
341
+
342
+ **After Submission:**
343
+ - [ ] Post to Twitter about demo
344
+ - [ ] Post to relevant subreddits (r/programming, r/webdev)
345
+ - [ ] Email to beta users: "We applied to YC, try our demo"
346
+ - [ ] Monitor usage 24/7 for first 48 hours
347
+
348
+ ---
349
+
350
+ ## 📞 Support
351
+
352
+ If YC partner has issues:
353
+
354
+ **Email template ready:**
355
+ ```
356
+ Subject: ZeroCarbon API Demo - Emergency Support
357
+
358
+ We're monitoring our demo 24/7 during YC application review.
359
+
360
+ If you experience any issues:
361
+ 1. Email: yc@zerocarbon.codes (monitored every 15 minutes)
362
+ 2. Text: [Your Number] (for urgent issues)
363
+ 3. Backup demo: https://backup-demo.zerocarbon.codes
364
+
365
+ Our API uptime: 99.9%
366
+ Average response time: <300ms
367
+ Currently responding to all support requests within 15 minutes.
368
+
369
+ Thank you for testing our demo!
370
+ ```
371
+
372
+ ---
373
+
374
+ ## 🎬 Deployment Timeline
375
+
376
+ **Week -2:**
377
+ - Build all demos
378
+ - Test thoroughly
379
+ - Get 5 beta users to test
380
+
381
+ **Week -1:**
382
+ - Deploy to production
383
+ - Set up monitoring
384
+ - Create backups
385
+
386
+ **Day -3:**
387
+ - Final testing from different locations
388
+ - Write support email templates
389
+ - Set up 24/7 monitoring rotation
390
+
391
+ **Day -1:**
392
+ - Test one more time
393
+ - Check all links
394
+ - Sleep well
395
+
396
+ **Day 0 (Submission):**
397
+ - Submit application
398
+ - Monitor demo usage
399
+ - Respond to any issues within 15min
400
+
401
+ **Days 1-7:**
402
+ - Monitor daily usage
403
+ - Fix any issues immediately
404
+ - Track conversion metrics
405
+
406
+ ---
407
+
408
+ ## 💡 Pro Tips
409
+
410
+ 1. **Make it impossible to fail:**
411
+ - Add fallback to mock data
412
+ - Cache common calculations
413
+ - Have backup API endpoint
414
+
415
+ 2. **Impress with speed:**
416
+ - Aim for <200ms API responses
417
+ - Preload common calculations
418
+ - Use CDN for demo page
419
+
420
+ 3. **Track everything:**
421
+ - Log every demo run
422
+ - Track user flow
423
+ - Know exactly what YC partners see
424
+
425
+ 4. **Be available:**
426
+ - Check email every 30min
427
+ - Have phone ready
428
+ - Monitor demo 24/7
429
+
430
+ 5. **Iterate fast:**
431
+ - If partners report issues, fix in <1 hour
432
+ - Deploy fixes immediately
433
+ - Send follow-up email: "We fixed it"
434
+
435
+ ---
436
+
437
+ **Ready to deploy?** Start with Step 1 above ⬆️
package/README.md ADDED
@@ -0,0 +1,228 @@
1
+ # ZeroCarbon API - 5 Minute Quickstart
2
+
3
+ Get your first carbon footprint calculation in **under 5 minutes**. No signup required for testing.
4
+
5
+ ## 🚀 One-Line Demos
6
+
7
+ ### Option 1: Node.js (Fastest)
8
+ ```bash
9
+ npx zerocarbon-quickstart
10
+ ```
11
+
12
+ ### Option 2: Python
13
+ ```bash
14
+ pip install zerocarbon && python -m zerocarbon.quickstart
15
+ ```
16
+
17
+ ### Option 3: cURL (Zero Installation)
18
+ ```bash
19
+ curl -X POST https://api.zerocarbon.codes/v1/emissions/calculate \
20
+ -H "Content-Type: application/json" \
21
+ -d '{"source":"electricity","value":1000,"unit":"kWh","country":"US"}'
22
+ ```
23
+
24
+ ---
25
+
26
+ ## 🎮 Interactive Demos
27
+
28
+ ### Try on Replit
29
+ [![Run on Replit](https://replit.com/badge/github/zerocarbon/quickstart)](https://replit.com/@zerocarbon/quickstart)
30
+
31
+ ### Try on CodeSandbox
32
+ [![Open in CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/zerocarbon/quickstart)
33
+
34
+ ---
35
+
36
+ ## 📖 5-Minute Tutorial
37
+
38
+ ### Step 1: Calculate Emissions (No Auth Needed)
39
+
40
+ **Node.js**
41
+ ```javascript
42
+ const axios = require('axios');
43
+
44
+ const response = await axios.post('https://api.zerocarbon.codes/v1/emissions/calculate', {
45
+ source: 'electricity',
46
+ value: 1000,
47
+ unit: 'kWh',
48
+ country: 'US'
49
+ });
50
+
51
+ console.log(`Your emissions: ${response.data.emissions_kg_co2e} kg CO2e`);
52
+ // Output: Your emissions: 386.5 kg CO2e
53
+ ```
54
+
55
+ **Python**
56
+ ```python
57
+ import requests
58
+
59
+ response = requests.post('https://api.zerocarbon.codes/v1/emissions/calculate',
60
+ json={
61
+ 'source': 'electricity',
62
+ 'value': 1000,
63
+ 'unit': 'kWh',
64
+ 'country': 'US'
65
+ }
66
+ )
67
+
68
+ print(f"Your emissions: {response.json()['emissions_kg_co2e']} kg CO2e")
69
+ # Output: Your emissions: 386.5 kg CO2e
70
+ ```
71
+
72
+ ### Step 2: Calculate Real-World Scenarios
73
+
74
+ **Flight Emissions**
75
+ ```bash
76
+ curl -X POST https://api.zerocarbon.codes/v1/calculate/flight \
77
+ -H "Content-Type: application/json" \
78
+ -d '{
79
+ "from": "SFO",
80
+ "to": "JFK",
81
+ "passengers": 1,
82
+ "class": "economy"
83
+ }'
84
+ ```
85
+
86
+ **Vehicle Emissions**
87
+ ```javascript
88
+ const emissions = await fetch('https://api.zerocarbon.codes/v1/calculate/fuel', {
89
+ method: 'POST',
90
+ headers: { 'Content-Type': 'application/json' },
91
+ body: JSON.stringify({
92
+ fuel_type: 'gasoline',
93
+ distance: 100,
94
+ unit: 'miles'
95
+ })
96
+ });
97
+ ```
98
+
99
+ ### Step 3: Get Free API Key (30 seconds)
100
+
101
+ For persistent tracking and dashboard access:
102
+
103
+ ```bash
104
+ # Sign up via API (no email verification needed)
105
+ curl -X POST https://api.zerocarbon.codes/v1/demo-request \
106
+ -H "Content-Type: application/json" \
107
+ -d '{
108
+ "name": "Your Name",
109
+ "email": "you@company.com",
110
+ "company": "Your Company"
111
+ }'
112
+
113
+ # Instant API key in response:
114
+ # { "api_key": "zc_xxxxx", "dashboard_url": "https://app.zerocarbon.codes" }
115
+ ```
116
+
117
+ ---
118
+
119
+ ## 🏗️ Complete Example Apps
120
+
121
+ ### Express.js Server (3 minutes)
122
+ ```bash
123
+ git clone https://github.com/zerocarbon/examples
124
+ cd examples/nodejs-express
125
+ npm install && npm start
126
+ ```
127
+
128
+ ### Flask API (3 minutes)
129
+ ```bash
130
+ git clone https://github.com/zerocarbon/examples
131
+ cd examples/python-flask
132
+ pip install -r requirements.txt && python app.py
133
+ ```
134
+
135
+ ### Next.js Dashboard (5 minutes)
136
+ ```bash
137
+ git clone https://github.com/zerocarbon/examples
138
+ cd examples/nextjs-dashboard
139
+ npm install && npm run dev
140
+ ```
141
+
142
+ ---
143
+
144
+ ## 🎯 Common Use Cases
145
+
146
+ ### Scenario 1: E-commerce Carbon Labels
147
+ ```javascript
148
+ // Add carbon footprint to product pages
149
+ const getShippingEmissions = async (weight, distance) => {
150
+ const res = await fetch('https://api.zerocarbon.codes/v1/calculate/shipping', {
151
+ method: 'POST',
152
+ body: JSON.stringify({ weight_kg: weight, distance_km: distance })
153
+ });
154
+ return res.json();
155
+ };
156
+
157
+ // Display: "This shipment produces 2.3 kg CO2e"
158
+ ```
159
+
160
+ ### Scenario 2: SaaS Carbon Dashboard
161
+ ```javascript
162
+ // Track your infrastructure emissions
163
+ const trackCloudEmissions = async () => {
164
+ const emissions = await zerocarbon.calculate({
165
+ source: 'aws_compute',
166
+ instance_hours: 730,
167
+ region: 'us-east-1'
168
+ });
169
+
170
+ await zerocarbon.emissions.save({
171
+ category: 'cloud_infrastructure',
172
+ value: emissions.kg_co2e
173
+ });
174
+ };
175
+ ```
176
+
177
+ ### Scenario 3: Travel Booking Carbon Offset
178
+ ```javascript
179
+ // Offer carbon offsets at checkout
180
+ const flight = await zerocarbon.calculate.flight({
181
+ from: 'LAX',
182
+ to: 'LHR',
183
+ passengers: 2
184
+ });
185
+
186
+ const offsetCost = flight.emissions_kg_co2e * 0.015; // $15 per tonne
187
+ // Show: "Add carbon offset for $22.50?"
188
+ ```
189
+
190
+ ---
191
+
192
+ ## 📊 What You Get
193
+
194
+ - **Instant calculations** - No rate limits for testing
195
+ - **200+ emission factors** - Electricity, fuel, flights, shipping, etc.
196
+ - **Global coverage** - Country-specific emission factors
197
+ - **GHG Protocol compliant** - Scope 1, 2, 3 classifications
198
+ - **Auto-generated reports** - BRSR, SEC, TCFD, CDP formats
199
+
200
+ ---
201
+
202
+ ## 💡 Why Developers Love It
203
+
204
+ ✅ **No authentication** for quick testing
205
+ ✅ **RESTful API** with predictable endpoints
206
+ ✅ **JSON in, JSON out** - No XML, no SOAP
207
+ ✅ **Native SDKs** for Node.js, Python, Go, Ruby
208
+ ✅ **Webhook support** for async calculations
209
+ ✅ **OpenAPI spec** for auto-generating clients
210
+
211
+ ---
212
+
213
+ ## 🔗 Next Steps
214
+
215
+ - [Full API Documentation](https://docs.zerocarbon.codes)
216
+ - [Interactive API Explorer](https://api.zerocarbon.codes/playground)
217
+ - [Example Applications](https://github.com/zerocarbon/examples)
218
+ - [Get Production API Key](https://app.zerocarbon.codes/signup)
219
+
220
+ ---
221
+
222
+ ## 💬 Questions?
223
+
224
+ - Discord: [discord.gg/zerocarbon](https://discord.gg/zerocarbon)
225
+ - Email: developers@zerocarbon.codes
226
+ - Docs: [docs.zerocarbon.codes](https://docs.zerocarbon.codes)
227
+
228
+ **Try it now:** `npx zerocarbon-quickstart`