Edge Client Integration Documentation¶
Last Updated: November 14, 2025 Status: Active - Critical updates available
๐จ Start Here: Critical Updates (November 2025)¶
If you're implementing the edge client, read these first:
๐ด URGENT: WebSocket Connection Fix (November 15, 2025)¶
If your WebSocket is failing to connect:
- WEBSOCKET_QUICK_FIX.md (archived) โฑ๏ธ 2 minutes
- CRITICAL: Add
Authorizationheader to WebSocket - Quick code fix
-
Get connected in 2 minutes
-
WEBSOCKET_SETUP_GUIDE.md โฑ๏ธ 15 minutes
- Complete WebSocket protocol documentation
- Message types and examples
- Error troubleshooting
- Reconnection logic
๐ก HTTP Authentication (November 14, 2025)¶
- EDGE_CLIENT_QUICK_START.md โฑ๏ธ 5 minutes
- Critical breaking changes
- Authentication requirement
- Quick implementation checklist
-
Action Required: Add Bearer token authentication
-
EDGE_CLIENT_UPDATES_NOV_2025.md โฑ๏ธ 20 minutes
- Complete details on all backend changes
- Photo processing integration guide
- Rate limiting handling
- Migration checklist
- Example code updates
- Testing instructions
๐ Core Edge Agent Documentation¶
After reading the critical updates, review these foundational documents:
- /docs/edge/EDGE_AGENT_SPEC.md โฑ๏ธ 30 minutes
- Edge agent architecture overview
- Communication protocol specification
- Command and event types
- Security considerations
-
โ ๏ธ Now includes November 2025 updates banner
-
/docs/edge/MAC_MINI_IMPLEMENTATION.md โฑ๏ธ 60 minutes
- Complete implementation guide
- Technology stack recommendations
- Phase-by-phase development plan
- Code examples
- Deployment instructions
- โ ๏ธ Now includes November 2025 updates banner
๐ Implementation Priority¶
Phase 1: Critical (Week 1) ๐ด¶
Must complete before production:
- โ Read EDGE_CLIENT_QUICK_START.md
- โ Add Bearer token authentication
- โ Test authentication with dev backend
- โ Add 401 error handling
- โ Add 429 rate limit handling
Estimated Time: 2-4 hours
Phase 2: Foundation (Week 1-2) ๐ก¶
Core relay functionality:
- โ Implement iMessage monitoring
- โ Implement iMessage sending
- โ Connect to orchestrator endpoint (with auth)
- โ Handle basic message flow
- โ Test end-to-end message delivery
Estimated Time: 1-2 weeks
Phase 3: Features (Week 3-4) ๐ข¶
Enhanced capabilities:
- โณ Photo upload and processing
- โณ Local message scheduling
- โณ Message filtering
- โณ Rule engine
Estimated Time: 2-3 weeks
Phase 4: Production Hardening (Week 5-6) โช¶
Production readiness:
- โณ HMAC signature validation (when backend activates)
- โณ Error recovery and retry logic
- โณ Monitoring and health checks
- โณ Backup and recovery
Estimated Time: 1-2 weeks
๐ Environment Configuration¶
Required Environment Variables:
# Backend connection
BACKEND_URL=https://archety-backend-prod.up.railway.app
# Authentication (CRITICAL - Required for production)
RELAY_WEBHOOK_SECRET=your-shared-secret-here
# User identification
USER_PHONE=+15551234567
# Optional: iMessage configuration
MESSAGES_DB_PATH=~/Library/Messages/chat.db
How to Get RELAY_WEBHOOK_SECRET:
- Generate a secret:
openssl rand -hex 32 - Share with backend engineer to configure on Railway
- Add to your edge client
.envfile
๐ Backend Endpoints Reference¶
Authentication Required (Bearer Token)¶
All these endpoints require Authorization: Bearer {RELAY_WEBHOOK_SECRET}:
| Endpoint | Method | Purpose | Rate Limit |
|---|---|---|---|
/orchestrator/message |
POST | Process incoming messages | 60/min per user |
/orchestrator/heartbeat |
POST | Relay health check | 10/min |
/photos/upload |
POST | Upload photos for analysis | 20/min |
Edge Agent Endpoints (HMAC Token)¶
These use edge agent authentication (different from relay):
| Endpoint | Method | Purpose | Rate Limit |
|---|---|---|---|
/edge/register |
POST | Register edge agent | 1/hour |
/edge/sync |
POST | Sync commands/events | 100/min |
/edge/message |
POST | Send filtered messages | 100/min |
/edge/command/ack |
POST | Acknowledge commands | 100/min |
๐งช Testing Checklist¶
Before deploying to production:
- Authentication works with valid token
- Authentication fails with invalid token
- Authentication fails with missing token
- Rate limiting triggers at 61st message
- Retry-After header is respected
- 401 errors are handled gracefully
- 429 errors are handled gracefully
- Messages are delivered end-to-end
- Photo upload works (if implemented)
- Error logs are clear and actionable
๐ Additional Resources¶
Backend Documentation¶
- API Docs: https://archety-backend-prod.up.railway.app/docs
- GitHub: https://github.com/rawrjustin/archety
- Development Log:
/CLAUDE.md
Related Documentation¶
- Supabase Integration:
/docs/integration/MAC_MINI_EDGE_CLIENT_SUPABASE.md - Deployment Guide:
/docs/backend/DEPLOYMENT.md - Architecture Overview:
/docs/architecture/
๐ Troubleshooting¶
Common Issues¶
401 Unauthorized:
Cause: RELAY_WEBHOOK_SECRET doesn't match between client and backend
Fix: Verify secret matches on both sides
Test: curl with -H "Authorization: Bearer $SECRET"
429 Too Many Requests:
Cause: More than 60 messages/minute from same user
Fix: Implement retry logic with Retry-After header
Test: Send 61 messages rapidly
Connection Refused:
Cause: Backend URL incorrect or backend is down
Fix: Check BACKEND_URL environment variable
Test: curl https://archety-backend-prod.up.railway.app/health
Photo Upload Fails:
Cause: Missing authentication or invalid file format
Fix: Verify Bearer token and file is valid image
Test: curl with -F file=@photo.jpg
๐ฌ Support¶
Questions about:
- Authentication: See EDGE_CLIENT_QUICK_START.md
- Photo Processing: See EDGE_CLIENT_UPDATES_NOV_2025.md Section 2
- Rate Limiting: See EDGE_CLIENT_UPDATES_NOV_2025.md Section 3
- HMAC Signatures: See EDGE_CLIENT_UPDATES_NOV_2025.md Section 8
- Backend API: https://archety-backend-prod.up.railway.app/docs
- Edge Architecture: /docs/edge/EDGE_AGENT_SPEC.md
Contact: - Backend Engineer: Engineer 2 - Backend Repository: https://github.com/rawrjustin/archety
๐ Document Status¶
| Document | Status | Last Updated | Action Required |
|---|---|---|---|
| EDGE_CLIENT_QUICK_START.md | โ Active | Nov 14, 2025 | READ FIRST |
| EDGE_CLIENT_UPDATES_NOV_2025.md | โ Active | Nov 14, 2025 | IMPLEMENT |
| EDGE_AGENT_SPEC.md | โ Updated | Nov 14, 2025 | Reference |
| MAC_MINI_IMPLEMENTATION.md | โ Updated | Nov 14, 2025 | Guide |
| MAC_MINI_EDGE_CLIENT_SUPABASE.md | โน๏ธ Info | Earlier | Optional |
Total Reading Time: ~2 hours Implementation Time: 4-8 weeks (phased) Critical Items: Authentication (2-4 hours)
Last Updated: November 14, 2025 Maintained By: Backend Engineering Team