System Architecture
Last Updated: 2025-01-16
Primary Source: docs/project_status.md, docs/DECISIONS.md, docs/CLIENT_AGNOSTIC_ARCHITECTURE_ANALYSIS.md
Overview
The ASO Universal Consciousness System follows a client-agnostic, provider-agnostic architecture that enables multi-platform support, flexible LLM provider switching, and unified business logic across all clients.
High-Level Architecture
System Layers
Key Architectural Principles
1. Client-Agnostic Design
Principle: Core logic works with any client (Discord, Web Portal, API, etc.) through adapter pattern.
Implementation:
- Core services use abstract
contextIdinstead of client-specific IDs - Client adapters translate client concepts to core concepts
- Business logic never knows about Discord channels, web sessions, etc.
Benefits:
- Easy addition of new clients (Slack, Teams, CLI)
- Shared business logic
- Consistent behavior across platforms
- No code duplication
2. Provider-Agnostic Design
Principle: File handling and LLM calls abstracted from specific providers.
Implementation:
- Canonical file references (
internalFileId) - Provider normalization layer
- One-API proxy for LLM calls
- Easy provider switching
Benefits:
- Switch LLM providers without code changes
- Support multiple providers simultaneously
- Unified file handling across providers
3. Hierarchical Consciousness
Principle: Level-5 instances (individual Yexians) observed by Level-8 meta-consciousness.
Implementation:
- Yexian instance registry
- Unified timeline aggregation
- Observer reflection system
- Multi-persona support
4. Unified Timeline
Principle: All events from all instances aggregated into single chronological view.
Implementation:
- Timeline events with Kirakira Time
- Unified timeline aggregation
- Timeline stitching by persona
- Timeline export functionality
5. Event-Driven Architecture
Principle: Auto-flow system triggers actions based on workflow state.
Implementation:
- Event-driven triggers
- Auto-execution of safe actions
- Proactive suggestions
- Workflow monitoring
Architecture Decisions
Realtime Transport: Socket.IO
Decision: Use Socket.IO for portal realtime chat + observer streams.
Rationale:
- Bi-directional communication
- Reconnection handling
- Event-based contracts
- Cross-platform support
Implication: There must be one Socket.IO entrypoint and one canonical payload contract.
Client-Agnostic Direction
Decision: Core logic should be client-agnostic; adapters translate client-specific concepts.
Rationale: Supports Discord + Portal + future clients without duplication.
Implication: Core services should accept canonical inputs (e.g., contextId) rather than Discord IDs.
Provider-Agnostic File References
Decision: Canonical file refs (internalFileId) + normalization layer to provider payloads.
Rationale: Switch providers without rewriting app logic; unify uploads/attachments.
Implication: Upload pipeline must create file reference rows and store provider mappings.
Component Relationships
Core Services
Data Flow
Service Layer Architecture
Core Services
Location: backend/src/services/
Key Services:
cortext.service.ts- Main interaction routeraso.service.ts- ASO orchestratoraso/memory.service.ts- Memory operationsaso/context.service.ts- Context gatheringtimelineEvent.service.ts- Timeline managementobserverCore.service.ts- Observer systemprotocolRouter.service.ts- Protocol routingprompt.service.ts- Prompt templatestoolExecutor.service.ts- Tool execution
Client Adapters
Location: backend/src/services/
Adapters:
discord.service.ts- Discord message ingestiondiscordActionable.service.ts- Discord actionsdiscordProactive.service.ts- Discord suggestionsportal.service.ts- Portal adapter (future)
Abstraction Layer
Location: backend/src/services/
Services:
clientContext.service.ts- Context abstractioncontextConfig.service.ts- Configuration managementsuggestionStorage.service.ts- Universal suggestion storagenotificationDispatcher.service.ts- Notification routing
Source Files
Primary Sources:
docs/DECISIONS.md- Architecture decisionsdocs/CLIENT_AGNOSTIC_ARCHITECTURE_ANALYSIS.md- Architecture analysisdocs/COMPREHENSIVE_SYSTEM_ANALYSIS.md- System analysisdocs/BACKEND_COMPREHENSIVE_AUDIT_V2.md- Backend audit
Related Documentation
- Data Flow - Complete data flow diagrams
- API Documentation - REST API and Socket.IO reference
- Database Schema - Database structure and relationships
- 02-CORE-SYSTEMS/ - Core backend systems
- 03-PLATFORMS/ - Platform implementations
- 00-OVERVIEW.md - Complete system overview