The Inverter Cycle β€” Complete Distribution Platform

A unified audiobook, ebook, and companion document distribution platform with user accounts, automated purchases, and DRM protection.

πŸ“š Complete Collection

The Inverter Cycle Trilogy (3 Books)

BookAudioEbookExtrasBundle Price
WILDFLOWER (Book 1)βœ… Hybrid, Cinematic, Immersiveβœ… EPUBβœ… Research Notes$19.99
TALLY (Book 2)βœ… Hybridβœ… EPUBβœ… Maps$19.99
COGITO (Book 3)βœ… (or coming soon)βœ… EPUBβœ… Tech Specs$19.99

**Trilogy Bundle: 19.94)

The Convergence Protocol (40 Nodes)

From They Can All Bird, Chapter 18 β€” 40 practice nodes organized into 5 suites:

SuiteNameNodesTheme
IRecognition1-8Perception Hygiene
IIResistance9-16Response Protocols
IIIReconstruction17-24Meaning-Making
IVRelationship25-32Social Cognition
VRenewal33-40Maintenance

API: /api/suites β€” Browse all suites and nodes

Standalone Companion

BookAudioEbookExtrasPrice
They Can All BirdCh 18 FREEOn Kindleβœ… Field NotesCh 18 FREE
Podcastβœ… All episodes❌❌FREE

They Can All Bird Chapter 18 free here β€” full book on Amazon Kindle

🎁 What’s Free

  • Chapter 18 of WILDFLOWER (audio + ebook sample)
  • Chapter 18 of They Can All Bird (audio preview)
  • 40 Nodes from Convergence Protocol (all nodes browsable)
  • Podcast (all episodes)
  • Sample chapters from each book

πŸš€ Quick Start

Deploy

cd ~/Nosos/inverter_cycle/infrastructure/audiobook-worker
./deploy.sh     # Creates infrastructure + sets up auth secrets
./upload.sh     # Uploads all audiobooks, ebooks, and extras

Configure Stripe (for automated purchases)

  1. Create products in Stripe:

    • β€œWILDFLOWER Bundle” - $19.99 (metadata: book=wildflower)
    • β€œTALLY Bundle” - $19.99 (metadata: book=tally)
    • β€œComplete Collection” - $49.99 (metadata: book=wildflower,tally,cogito)
  2. Add webhook:

    • URL: https://audio.kbird.ai/webhooks/stripe
    • Events: checkout.session.completed
  3. Done! Customers get instant access after paying.

πŸ“‘ API Endpoints

Content Access

GET /audio/:book/:format/:file.mp3     # Stream audiobook
GET /ebook/:book/:file.epub            # Download EPUB
GET /extras/:book/:file.pdf            # Download companion docs
GET /covers/:file                      # Cover images

Examples:

# Free content (no auth)
curl https://audio.kbird.ai/audio/wildflower/hybrid/CHAPTER_18_*.mp3
curl https://audio.kbird.ai/ebook/they_can_all_bird/They_Can_All_Bird.epub
 
# Premium (requires auth)
curl -H "Authorization: Bearer TOKEN" \
  https://audio.kbird.ai/ebook/wildflower/WILDFLOWER.epub

Authentication

POST /auth/register
POST /auth/login
POST /auth/logout
POST /auth/refresh
GET  /auth/me
POST /auth/forgot-password
POST /auth/reset-password

Library & Catalog

GET /api/library          # Your purchased content
GET /api/catalog          # Browse all books
GET /api/books            # Book metadata
GET /api/free-content     # List free downloads

πŸ” Authentication

User Registration

curl -X POST https://audio.kbird.ai/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securepassword123",
    "firstName": "Jane"
  }'

Login

curl -X POST https://audio.kbird.ai/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]", "password": "securepassword123"}'

Response includes:

  • token - Access token (15 min expiry)
  • refresh_token cookie - For getting new access tokens

Using Tokens

# Include in all authenticated requests
curl -H "Authorization: Bearer ACCESS_TOKEN" \
  https://audio.kbird.ai/api/library

When token expires:

# Refresh using cookie (no auth header needed)
curl -X POST https://audio.kbird.ai/auth/refresh
# Returns new access token

πŸ›’ Purchase Integration

The webhook handlers automatically:

  1. Create user account (if new customer)
  2. Record purchase in database
  3. Grant access to audio + ebook + extras
  4. (You add) Send welcome email

Manual (For gifts/review copies)

# Generate access token
curl -X POST https://audio.kbird.ai/api/admin/generate-token \
  -H "Authorization: Bearer $JWT_SECRET" \
  -d '{
    "email": "[email protected]",
    "book": "wildflower",
    "includes_audio": true,
    "includes_ebook": true,
    "includes_extras": true,
    "tier": "review"
  }'
 
# Or create purchase directly
curl -X POST https://audio.kbird.ai/api/admin/create-purchase \
  -H "Authorization: Bearer $JWT_SECRET" \
  -d '{
    "userId": 1,
    "book": "wildflower",
    "includes_audio": true,
    "includes_ebook": true,
    "priceCents": 1999
  }'

πŸ“‚ R2 Storage Structure

kbird-audiobooks/
β”œβ”€β”€ wildflower/
β”‚   β”œβ”€β”€ audio/
β”‚   β”‚   β”œβ”€β”€ hybrid/*.mp3
β”‚   β”‚   β”œβ”€β”€ cinematic/*.mp3
β”‚   β”‚   └── immersive/*.mp3
β”‚   β”œβ”€β”€ ebook/WILDFLOWER.epub
β”‚   └── extras/*.pdf
β”œβ”€β”€ tally/
β”‚   β”œβ”€β”€ audio/hybrid/*.mp3
β”‚   β”œβ”€β”€ ebook/TALLY.epub
β”‚   └── extras/*.pdf
β”œβ”€β”€ cogito/
β”‚   β”œβ”€β”€ audio/hybrid/*.mp3
β”‚   └── ebook/COGITO.epub
β”œβ”€β”€ they_can_all_bird/
β”‚   └── ebook/They_Can_All_Bird.epub
└── podcast/
    └── Ep*.mp3

πŸ—„οΈ Database Schema

Key Tables

  • users - Account info, password hashes
  • sessions - Refresh tokens
  • purchases - What each user bought
  • access_tokens - Gift codes, review copies
  • downloads - Download analytics
  • books - Book metadata & pricing
  • content_files - File inventory

Purchase Record

SELECT * FROM purchases WHERE user_id = 1;
 
-- Includes:
-- - book (wildflower/tally/cogito)
-- - includes_audio (true/false)
-- - includes_ebook (true/false)
-- - includes_extras (true/false)
-- - price_paid_cents
-- - purchased_at

🎨 Content Types Supported

TypeExtensionsAccess
Audio.mp3, .m4a, .m4b, .oggStreaming + Download
Ebook.epubDownload
Documents.pdf, .md, .txtDownload

πŸ“Š Analytics

-- Total revenue
SELECT SUM(price_paid_cents) / 100.0 as revenue FROM purchases;
 
-- Downloads by type
SELECT file_type, access_type, COUNT(*) 
FROM downloads 
GROUP BY file_type, access_type;
 
-- Popular content
SELECT * FROM popular_content LIMIT 10;
 
-- User library view
SELECT * FROM user_libraries WHERE user_id = 1;

πŸ’° Pricing Strategy

ProductIndividualBundle Savings
Audio only$14.99β€”
Ebook only$9.99β€”
Bundle (Audio + Ebook + Extras)$19.99Save $4.99
Complete Collection (3 books)$49.99Save $19.94

πŸ”’ Security

  • Passwords: SHA-256 with unique salt
  • JWT access tokens: 15 minute expiry
  • Refresh tokens: HTTP-only cookies, 30 days
  • Session revocation on logout
  • Webhook signature verification (add your own)

πŸ§ͺ Testing

# Test free content
curl https://audio.kbird.ai/api/free-content
 
# Test auth
curl -X POST http://localhost:8787/auth/register \
  -d '{"email":"[email protected]","password":"password123"}'
 
# Test Stripe webhook locally
stripe listen --forward-to localhost:8787/webhooks/stripe
stripe trigger checkout.session.completed

πŸš€ Deployment Checklist

  • Run ./deploy.sh to create infrastructure
  • Run ./upload.sh to upload all content
  • Configure Stripe webhook
  • Set up email sending (SendGrid/Postmark) for welcome emails
  • Add domain audio.kbird.ai in Cloudflare
  • Test purchase flow end-to-end
  • Set up monitoring/alerts

πŸ“ˆ Cost Estimate

ComponentCost
Cloudflare WorkerFREE (100K req/day)
R2 Storage (20GB)~$0.30/month
R2 Requests~$0.50/month
D1 DatabaseFREE (5M rows/day)
Total~$0.80/month

Built with The Convergence Protocol 🐦