Passport Architecture: Foundation as Sole Issuer
Overview
aethex.foundation is the sole issuer and authority for all user passports/identities in the AeThex ecosystem. All other platforms (aethex.dev, future platforms) are OAuth clients that consume Foundation-issued identities.
This document defines the passport architecture and data flow.
Core Principle
Foundation = Single Source of Truth (SSOT) for identity
Each Platform = Read-only cache of Foundation passport dataArchitecture
1. Foundation (aethex.foundation)
Owner of passport data
Issues and maintains all user identities
Provides OAuth endpoints for authentication
Provides passport API endpoints for clients to fetch user data
Single authority for all identity mutations (updates, deletions)
2. Client Platforms (aethex.dev, etc.)
Consumers of Foundation identities
Cache Foundation passport data locally for performance
Use cached data for reads (lookups, profile queries)
Forward any profile updates to Foundation's API
Validate passport integrity on each login
Data Flow
User Login Flow
Profile Update Flow
Profile Read Flow
Key Rules
✅ ALLOWED Operations on aethex.dev
Read from local cache - Fast lookups of passport data
Sync from Foundation - One-way data import during login/refresh
Validate against cache - Use cached data for access control
Forward to Foundation - Route update requests to Foundation API
Cache invalidation - Clear stale cache on logout or explicit refresh
❌ FORBIDDEN Operations on aethex.dev
Direct writes to passport data - All identity mutations must go through Foundation
Creating new passports - Only Foundation can issue identities
Modifying cached data - Cache is read-only except during sync
Trusting unvalidated data - Always verify data came from Foundation
Database Schema (aethex.dev)
Sync Mechanism
Initial Sync (On Login)
User authenticates with Foundation
aethex.dev receives
access_tokenand basic user infoaethex.dev calls Foundation's
/api/oauth/userinfoendpointAll user data from Foundation gets UPSERTED to local cache
foundation_synced_attimestamp is updated
Periodic Sync (Background)
Cache Expiration
Error Handling
What if Foundation is unavailable?
During Login:
�� Cannot proceed - user must authenticate through Foundation
Return error: "Identity service unavailable"
For existing users (cache valid):
✅ Can use cached data temporarily
Continue serving from cache
Log warning about Foundation unavailability
Retry sync in background
For profile updates:
❌ Cannot proceed - updates must go through Foundation
Queue update locally, retry when Foundation is available
Or fail gracefully: "Identity service unavailable, please try again"
Validation Rules
On Every Auth Request
On Every Profile Update Request
Migration from Old Model
Old Model: aethex.dev wrote directly to passport table New Model: aethex.dev only syncs FROM Foundation
Migration Steps
✅ Remove Foundation arm from aethex.dev UI (DONE)
✅ Clarify that aethex.dev is an OAuth client of Foundation (DONE)
Make profile endpoints read-only, forward writes to Foundation
Add cache validation on every auth request
Implement background sync for cache freshness
Monitor logs for any direct write attempts (should be 0)
Deprecate old direct-write endpoints
API Endpoints Reference
Foundation APIs (Used by aethex.dev)
aethex.dev APIs (Now read-only/cache-focused)
Monitoring & Observability
Log these events
Metrics to track
Sync success rate (should be ~100%)
Cache hit rate (should be >95% for logged-in users)
Foundation API latency
Failed sync attempts
Stale cache detections
Future Enhancements
Webhook sync - Foundation notifies clients when passport changes
Event stream - Subscribe to passport update events
Multi-version support - Handle different Foundation versions
Distributed cache - Redis layer for cross-instance consistency
Audit trail - Track all passport mutations at Foundation level
Related Documentation
code/docs/PHASE3-SWITCHOVER-GUIDE.md- OAuth migration guidecode/api/auth/callback.ts- Login sync implementationcode/api/profile/ensure.ts- Profile sync endpoint
Last updated
