anthropic-fonts 1.1.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,622 @@
1
+ # 🚀 Deployment Guide
2
+
3
+ Complete step-by-step instructions for deploying Anthropic Fonts CDN to production.
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [GitHub Pages + jsDelivr (Free & Fast)](#github-pages--jsdelivr)
8
+ 2. [Cloudflare R2 (Affordable & Fast)](#cloudflare-r2)
9
+ 3. [AWS S3 + CloudFront (Enterprise)](#aws-s3--cloudfront)
10
+ 4. [Self-hosted (NGINX/Apache)](#self-hosted)
11
+ 5. [Vercel/Netlify (Static Hosting)](#vercelnetlify)
12
+
13
+ ---
14
+
15
+ ## GitHub Pages + jsDelivr
16
+
17
+ **Best for:** Open-source projects, free CDN with global coverage
18
+
19
+ ### Step 1: Initialize Git Repository
20
+
21
+ ```bash
22
+ cd /path/to/AnthropicFont
23
+ git init
24
+ git add .
25
+ git commit -m "Initial commit: Anthropic Fonts CDN"
26
+ ```
27
+
28
+ ### Step 2: Add Remote & Push
29
+
30
+ ```bash
31
+ git remote add origin https://github.com/devchauhann/fonts.git
32
+ git branch -M main
33
+ git push -u origin main
34
+ ```
35
+
36
+ ### Step 3: Enable GitHub Pages
37
+
38
+ 1. Go to **Settings** → **Pages**
39
+ 2. Set source to `main` branch, `/cdn` folder
40
+ 3. GitHub will provide your Pages URL: `https://devchauhann.github.io/AnthropicFont/`
41
+
42
+ ### Step 4: Use jsDelivr CDN (Recommended)
43
+
44
+ jsDelivr automatically serves your GitHub files with global CDN:
45
+
46
+ ```html
47
+ <!-- Static CSS -->
48
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/devchauhann/fonts@v1.1.0/cdn/v1/css/all.css">
49
+
50
+ <!-- Dynamic CSS API -->
51
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/devchauhann/fonts@v1.1.0/cdn/api/css?family=AnthropicSans&weights=400;700">
52
+
53
+ <!-- Font Files -->
54
+ https://cdn.jsdelivr.net/gh/devchauhann/fonts@v1.1.0/cdn/v1/fonts/AnthropicSans@700.woff2
55
+ ```
56
+
57
+ ### Step 5: Create a Release (Optional but Recommended)
58
+
59
+ ```bash
60
+ git tag v1.0.0
61
+ git push origin v1.0.0
62
+ ```
63
+
64
+ Then use versioned URLs:
65
+
66
+ ```html
67
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/devchauhann/fonts@v1.0.0/cdn/v1/css/all.css">
68
+ ```
69
+
70
+ ### ✅ Pros & Cons
71
+
72
+ **Pros:**
73
+ - Free forever
74
+ - Global CDN (jsDelivr has 300+ servers)
75
+ - No configuration needed
76
+ - Automatic version management via Git tags
77
+ - Perfect for open-source
78
+
79
+ **Cons:**
80
+ - Slightly slower than commercial CDNs
81
+ - Rate limited (but generous)
82
+ - Depends on GitHub uptime
83
+
84
+ ---
85
+
86
+ ## Cloudflare R2
87
+
88
+ **Best for:** Affordable, fast, easy setup, no egress costs
89
+
90
+ ### Step 1: Create Cloudflare Account
91
+
92
+ 1. Sign up at https://dash.cloudflare.com
93
+ 2. Navigate to **R2** → **Create bucket**
94
+ 3. Bucket name: `anthropic-fonts`
95
+
96
+ ### Step 2: Upload Files
97
+
98
+ ```bash
99
+ # Install wrangler CLI
100
+ npm install -g wrangler
101
+
102
+ # Authenticate
103
+ wrangler login
104
+
105
+ # Upload fonts
106
+ wrangler r2 cp cdn/v1/fonts/* r2://anthropic-fonts/fonts/ --recursive
107
+ wrangler r2 cp cdn/v1/css/* r2://anthropic-fonts/css/ --recursive
108
+ wrangler r2 cp cdn/v1/data.json r2://anthropic-fonts/data.json
109
+ ```
110
+
111
+ ### Step 3: Create Public URL
112
+
113
+ 1. In R2 bucket settings, click **Settings**
114
+ 2. Find **Public access** → Create a **Public R2 URL**
115
+ 3. Example: `https://pub-abc123def.r2.dev`
116
+
117
+ ### Step 4: Configure CORS Headers
118
+
119
+ In Bucket → **Settings** → add CORS rule:
120
+
121
+ ```json
122
+ {
123
+ "AllowedOrigins": ["*"],
124
+ "AllowedMethods": ["GET", "HEAD"],
125
+ "AllowedHeaders": ["Content-Type"],
126
+ "MaxAgeSeconds": 31536000
127
+ }
128
+ ```
129
+
130
+ ### Step 5: Use in Production
131
+
132
+ ```html
133
+ <link rel="stylesheet" href="https://pub-abc123def.r2.dev/css/all.css">
134
+
135
+ <!-- Or with custom domain -->
136
+ <link rel="stylesheet" href="https://fonts.example.com/css/all.css">
137
+ ```
138
+
139
+ ### Step 6: Connect Custom Domain (Optional)
140
+
141
+ 1. Add DNS CNAME pointing to R2 bucket
142
+ 2. In Cloudflare, enable **Web3 IPFS gateway** for redundancy
143
+
144
+ ### ✅ Pros & Cons
145
+
146
+ **Pros:**
147
+ - Very affordable ($0.015/GB stored, $0.04/GB downloaded)
148
+ - **No egress fees** (major advantage!)
149
+ - Easy setup
150
+ - Cloudflare's global network
151
+ - 99.99% uptime SLA
152
+
153
+ **Cons:**
154
+ - Requires Cloudflare account
155
+ - Manual sync needed for updates
156
+ - Not ideal for frequently changing files
157
+
158
+ ---
159
+
160
+ ## AWS S3 + CloudFront
161
+
162
+ **Best for:** Enterprise, high-traffic, ultimate control
163
+
164
+ ### Step 1: Create S3 Bucket
165
+
166
+ ```bash
167
+ # Install AWS CLI
168
+ pip install awscli
169
+
170
+ # Configure credentials
171
+ aws configure
172
+
173
+ # Create bucket (use globally unique name)
174
+ aws s3 mb s3://anthropic-fonts-cdn --region us-east-1
175
+ ```
176
+
177
+ ### Step 2: Upload Files
178
+
179
+ ```bash
180
+ # Upload all files
181
+ aws s3 sync cdn/v1/ s3://anthropic-fonts-cdn/v1/ \
182
+ --cache-control "max-age=31536000,immutable" \
183
+ --content-encoding gzip
184
+
185
+ # Or with specific content types
186
+ aws s3 cp cdn/v1/fonts/ s3://anthropic-fonts-cdn/v1/fonts/ \
187
+ --recursive \
188
+ --include "*.woff2" \
189
+ --cache-control "max-age=31536000,immutable"
190
+ ```
191
+
192
+ ### Step 3: Configure S3 Bucket Policy
193
+
194
+ Create bucket policy for public read access:
195
+
196
+ ```json
197
+ {
198
+ "Version": "2012-10-17",
199
+ "Statement": [
200
+ {
201
+ "Sid": "PublicReadGetObject",
202
+ "Effect": "Allow",
203
+ "Principal": "*",
204
+ "Action": "s3:GetObject",
205
+ "Resource": "arn:aws:s3:::anthropic-fonts-cdn/*"
206
+ }
207
+ ]
208
+ }
209
+ ```
210
+
211
+ ### Step 4: Create CloudFront Distribution
212
+
213
+ ```bash
214
+ # Using AWS CLI or console
215
+ aws cloudfront create-distribution --distribution-config file://cloudfront-config.json
216
+ ```
217
+
218
+ **Or via Console:**
219
+
220
+ 1. Go to **CloudFront** → **Create distribution**
221
+ 2. Origin domain: `anthropic-fonts-cdn.s3.amazonaws.com`
222
+ 3. Viewer protocol: HTTPS only
223
+ 4. Cache policy: CachingOptimized (1 year)
224
+ 5. Create distribution
225
+
226
+ ### Step 5: Add Custom Domain
227
+
228
+ 1. In CloudFront, add alternate domain name: `fonts.example.com`
229
+ 2. Request SSL certificate in **AWS Certificate Manager**
230
+ 3. Update DNS CNAME to CloudFront domain
231
+
232
+ ### Example CloudFront Config
233
+
234
+ ```json
235
+ {
236
+ "S3BucketName": "anthropic-fonts-cdn",
237
+ "CacheBehaviors": [
238
+ {
239
+ "PathPattern": "/v1/fonts/*",
240
+ "CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
241
+ "Compress": true,
242
+ "ViewerProtocolPolicy": "https-only"
243
+ }
244
+ ]
245
+ }
246
+ ```
247
+
248
+ ### ✅ Pros & Cons
249
+
250
+ **Pros:**
251
+ - Highly scalable
252
+ - Global CDN with 600+ edge locations
253
+ - Ultimate performance
254
+ - Enterprise SLA (99.99% uptime)
255
+ - Complete control
256
+
257
+ **Cons:**
258
+ - Can be expensive for high traffic
259
+ - Egress charges ($0.085/GB)
260
+ - Complex setup
261
+ - Steeper learning curve
262
+
263
+ ---
264
+
265
+ ## Self-hosted
266
+
267
+ **Best for:** Maximum control, on-premise, private deployments
268
+
269
+ ### Step 1: Server Setup
270
+
271
+ ```bash
272
+ # SSH into your server
273
+ ssh user@your-server.com
274
+
275
+ # Install Node.js
276
+ curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
277
+ sudo apt-get install -y nodejs
278
+
279
+ # Clone repository
280
+ git clone https://github.com/devchauhann/fonts.git
281
+ cd AnthropicFont
282
+ npm install
283
+ ```
284
+
285
+ ### Step 2: Configure NGINX Reverse Proxy
286
+
287
+ ```nginx
288
+ server {
289
+ listen 443 ssl http2;
290
+ server_name fonts.example.com;
291
+
292
+ ssl_certificate /etc/letsencrypt/live/fonts.example.com/fullchain.pem;
293
+ ssl_certificate_key /etc/letsencrypt/live/fonts.example.com/privkey.pem;
294
+
295
+ # Enable gzip compression
296
+ gzip on;
297
+ gzip_types text/css application/font-woff2 font/woff2;
298
+ gzip_min_length 1000;
299
+
300
+ # Caching headers for fonts
301
+ location /v1/fonts/ {
302
+ proxy_pass http://localhost:3000;
303
+ add_header Cache-Control "public, max-age=31536000, immutable";
304
+ add_header Access-Control-Allow-Origin "*";
305
+ expires 1y;
306
+ }
307
+
308
+ location /v1/css/ {
309
+ proxy_pass http://localhost:3000;
310
+ add_header Cache-Control "public, max-age=31536000, immutable";
311
+ expires 1y;
312
+ }
313
+
314
+ location /api/ {
315
+ proxy_pass http://localhost:3000;
316
+ add_header Cache-Control "public, max-age=86400";
317
+ }
318
+
319
+ # CORS headers
320
+ add_header Access-Control-Allow-Origin "*";
321
+ add_header Access-Control-Allow-Methods "GET, OPTIONS";
322
+ add_header Access-Control-Allow-Headers "Content-Type";
323
+ }
324
+
325
+ # Redirect HTTP to HTTPS
326
+ server {
327
+ listen 80;
328
+ server_name fonts.example.com;
329
+ return 301 https://$server_name$request_uri;
330
+ }
331
+ ```
332
+
333
+ ### Step 3: Setup SSL Certificate
334
+
335
+ ```bash
336
+ # Using Let's Encrypt
337
+ sudo apt-get install certbot python3-certbot-nginx
338
+ sudo certbot certonly --nginx -d fonts.example.com
339
+ ```
340
+
341
+ ### Step 4: Run as Service
342
+
343
+ Create systemd service file:
344
+
345
+ ```bash
346
+ # /etc/systemd/system/anthropic-fonts.service
347
+ [Unit]
348
+ Description=Anthropic Fonts CDN
349
+ After=network.target
350
+
351
+ [Service]
352
+ Type=simple
353
+ User=www-data
354
+ WorkingDirectory=/home/www-data/AnthropicFont
355
+ ExecStart=/usr/bin/node api/server.js
356
+ Restart=always
357
+ RestartSec=10
358
+ Environment="NODE_ENV=production"
359
+ Environment="PORT=3000"
360
+
361
+ [Install]
362
+ WantedBy=multi-user.target
363
+ ```
364
+
365
+ ```bash
366
+ # Enable and start
367
+ sudo systemctl daemon-reload
368
+ sudo systemctl enable anthropic-fonts
369
+ sudo systemctl start anthropic-fonts
370
+ ```
371
+
372
+ ### Step 5: Monitoring & Updates
373
+
374
+ ```bash
375
+ # Check status
376
+ sudo systemctl status anthropic-fonts
377
+
378
+ # View logs
379
+ sudo journalctl -u anthropic-fonts -f
380
+
381
+ # Update fonts
382
+ cd /home/www-data/AnthropicFont
383
+ git pull origin main
384
+ npm run build
385
+ sudo systemctl restart anthropic-fonts
386
+ ```
387
+
388
+ ### ✅ Pros & Cons
389
+
390
+ **Pros:**
391
+ - Maximum control
392
+ - No vendor lock-in
393
+ - Can be cheaper for high traffic
394
+ - Private/on-premise option
395
+
396
+ **Cons:**
397
+ - Requires server maintenance
398
+ - No global CDN (unless you add one)
399
+ - SSL certificate management
400
+ - Uptime responsibility
401
+
402
+ ---
403
+
404
+ ## Vercel/Netlify
405
+
406
+ **Best for:** Easiest deployment, jamstack projects
407
+
408
+ ### Vercel Deployment
409
+
410
+ ```bash
411
+ # Install Vercel CLI
412
+ npm i -g vercel
413
+
414
+ # Deploy
415
+ vercel --prod
416
+ ```
417
+
418
+ **Or connect Git:**
419
+
420
+ 1. Go to https://vercel.com
421
+ 2. Import Git repository
422
+ 3. Select `cdn` as root directory
423
+ 4. Deploy
424
+
425
+ ### Netlify Deployment
426
+
427
+ ```bash
428
+ # Install Netlify CLI
429
+ npm install -g netlify-cli
430
+
431
+ # Deploy
432
+ netlify deploy --prod --dir=cdn
433
+ ```
434
+
435
+ **Or drag & drop:** Simply drag `cdn` folder to Netlify.
436
+
437
+ ### Configure Headers (netlify.toml)
438
+
439
+ ```toml
440
+ [[headers]]
441
+ for = "/v1/fonts/*"
442
+ [headers.values]
443
+ Cache-Control = "public, max-age=31536000, immutable"
444
+ Access-Control-Allow-Origin = "*"
445
+
446
+ [[headers]]
447
+ for = "/v1/css/*"
448
+ [headers.values]
449
+ Cache-Control = "public, max-age=31536000, immutable"
450
+ ```
451
+
452
+ ### ✅ Pros & Cons
453
+
454
+ **Pros:**
455
+ - Simplest deployment
456
+ - Free tier available
457
+ - Global CDN included
458
+ - Automatic HTTPS
459
+ - Easy rollbacks
460
+
461
+ **Cons:**
462
+ - Limited to serverless/static
463
+ - API endpoint needs adjustment
464
+ - Cold starts on function calls
465
+
466
+ ---
467
+
468
+ ## 📊 Comparison Table
469
+
470
+ | Feature | jsDelivr | Cloudflare R2 | AWS | Self-hosted | Vercel |
471
+ |---------|----------|---------------|-----|-------------|--------|
472
+ | **Cost** | Free | $0.015/GB | $$$ | $$ | $$ |
473
+ | **Setup Time** | 5 min | 15 min | 1 hour | 2 hours | 2 min |
474
+ | **Speed** | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ |
475
+ | **Uptime SLA** | 99.9% | 99.99% | 99.99% | Custom | 99.95% |
476
+ | **Best For** | Open-source | Affordable | Enterprise | Control | Quick |
477
+
478
+ ---
479
+
480
+ ## 🔄 Continuous Deployment
481
+
482
+ ### Automatic Updates on Git Push
483
+
484
+ **GitHub Actions Example:**
485
+
486
+ Create `.github/workflows/deploy.yml`:
487
+
488
+ ```yaml
489
+ name: Deploy to CDN
490
+
491
+ on:
492
+ push:
493
+ branches: [main]
494
+ paths:
495
+ - 'cdn/**'
496
+
497
+ jobs:
498
+ deploy:
499
+ runs-on: ubuntu-latest
500
+ steps:
501
+ - uses: actions/checkout@v3
502
+
503
+ - name: Deploy to jsDelivr (via purge)
504
+ run: |
505
+ curl https://purge.jsdelivr.net/gh/devchauhann/fonts@v1.1.0/cdn/v1/css/all.css
506
+
507
+ - name: Deploy to Cloudflare R2
508
+ env:
509
+ AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY }}
510
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_SECRET_KEY }}
511
+ run: |
512
+ aws s3 sync cdn/v1/ s3://anthropic-fonts/ \
513
+ --endpoint-url https://${{ secrets.CF_ACCOUNT_ID }}.r2.cloudflareclient.com \
514
+ --cache-control "max-age=31536000,immutable"
515
+ ```
516
+
517
+ ---
518
+
519
+ ## 🎯 Recommended Setup for Production
520
+
521
+ **For most users:** GitHub + jsDelivr
522
+
523
+ ```html
524
+ <!-- Ultra-reliable, free, global CDN -->
525
+ <link rel="preconnect" href="https://cdn.jsdelivr.net">
526
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/devchauhann/fonts@v1.1.0/cdn/v1/css/all.css">
527
+ ```
528
+
529
+ **For high-traffic sites:** AWS S3 + CloudFront
530
+
531
+ ```html
532
+ <!-- Maximum performance, enterprise SLA -->
533
+ <link rel="preconnect" href="https://d123xyz.cloudfront.net">
534
+ <link rel="stylesheet" href="https://fonts.example.com/v1/css/all.css">
535
+ ```
536
+
537
+ **For cost-conscious:** Cloudflare R2 + custom domain
538
+
539
+ ```html
540
+ <!-- Cheap, fast, no egress fees -->
541
+ <link rel="preconnect" href="https://fonts.example.com">
542
+ <link rel="stylesheet" href="https://fonts.example.com/css/all.css">
543
+ ```
544
+
545
+ ---
546
+
547
+ ## 📝 Monitoring & Analytics
548
+
549
+ ### Track CDN Usage
550
+
551
+ **jsDelivr:**
552
+ - Stats automatically available at `https://www.jsdelivr.com/package/gh/devchauhann/fonts`
553
+
554
+ **Cloudflare R2:**
555
+ - Bucket → **Analytics** tab shows bandwidth and requests
556
+
557
+ **AWS CloudFront:**
558
+ - CloudFront → **Monitoring** → View request, bytes, cache stats
559
+
560
+ **Self-hosted:**
561
+ ```bash
562
+ # NGINX logs
563
+ tail -f /var/log/nginx/access.log | grep fonts
564
+
565
+ # Monitor Node.js
566
+ npm install -g pm2
567
+ pm2 monit
568
+ ```
569
+
570
+ ---
571
+
572
+ ## 🔒 Security Best Practices
573
+
574
+ 1. **Enable HTTPS only** (all modern CDNs do this)
575
+ 2. **Set CORS headers** for cross-origin requests
576
+ 3. **Configure cache headers** to prevent stale files
577
+ 4. **Monitor for unauthorized usage**
578
+ 5. **Rate limiting** (if self-hosted)
579
+ 6. **Version your releases** for easy rollbacks
580
+
581
+ ---
582
+
583
+ ## 🚨 Troubleshooting
584
+
585
+ ### Fonts Not Loading
586
+
587
+ ```bash
588
+ # Check CORS headers
589
+ curl -I https://cdn.example.com/v1/fonts/AnthropicSans@400.woff2
590
+
591
+ # Should include:
592
+ # Access-Control-Allow-Origin: *
593
+ ```
594
+
595
+ ### Cache Issues
596
+
597
+ ```bash
598
+ # Purge jsDelivr cache
599
+ curl https://purge.jsdelivr.net/gh/devchauhann/fonts@v1.1.0/cdn/v1/css/all.css
600
+
601
+ # Purge Cloudflare R2
602
+ wrangler r2 cp cdn/v1/ r2://anthropic-fonts/v1/ --recursive --force
603
+ ```
604
+
605
+ ### Slow Performance
606
+
607
+ 1. Enable gzip compression
608
+ 2. Set aggressive caching headers
609
+ 3. Use geographically closest CDN
610
+ 4. Monitor real user metrics (RUM)
611
+
612
+ ---
613
+
614
+ ## 📚 Next Steps
615
+
616
+ 1. Choose your deployment platform
617
+ 2. Follow the step-by-step guide above
618
+ 3. Test font loading: `npm run dev` locally first
619
+ 4. Monitor performance in production
620
+ 5. Set up automatic updates via GitHub Actions
621
+
622
+ **Questions?** Check the main [README.md](../README.md) or [USAGE.md](./USAGE.md)