System Architecture
OpenViking follows a layered architecture pattern separating concerns across Client, Service, Core Modules, and Storage layers:Core Modules
Client Layer
Client Layer
Provides unified entry point for all operations, delegating to the Service layer.
- Exposes all public APIs (find, search, add_resource, session, etc.)
- Handles HTTP/SDK client implementations
- Supports both embedded and remote modes
Service Layer
Service Layer
Implements business logic and decouples from transport layer, enabling reuse across HTTP Server and CLI.
| Service | Responsibility | Key Methods |
|---|---|---|
| FSService | File system operations | ls, mkdir, rm, mv, tree, stat, read, abstract, overview, grep, glob |
| SearchService | Semantic search | search, find |
| SessionService | Session management | session, sessions, commit, delete |
| ResourceService | Resource import | add_resource, add_skill, wait_processed |
| RelationService | Relation management | relations, link, unlink |
| PackService | Import/export | export_ovpack, import_ovpack |
| DebugService | Debug service | observer (ObserverService) |
Retrieve Module
Retrieve Module
Handles context retrieval with intent analysis and hierarchical search.
- IntentAnalyzer: Analyzes query intent, generates 0-5 typed queries
- HierarchicalRetriever: Directory-level recursive search using priority queue
- Rerank: Scalar filtering + model reranking for refined results
Session Module
Session Module
Manages conversation lifecycle and memory extraction.
- Message recording and usage tracking
- Session compression and archiving
- 6-category memory extraction (profile, preferences, entities, events, cases, patterns)
- LLM-based deduplication decisions
Parse Module
Parse Module
Handles document parsing and context extraction.
- Document parsing (PDF/MD/HTML/Code)
- Tree building and directory creation
- Async semantic generation (L0/L1)
- AST-based code skeleton extraction
Compressor Module
Compressor Module
Compresses and extracts memories from sessions.
- 6-category memory extraction
- LLM deduplication decisions
- Conflict resolution (merge/delete/skip)
Storage Layer
Storage Layer
Dual-layer storage separating content from index.
- VikingFS: Virtual filesystem with URI abstraction
- AGFS: Content storage (L0/L1/L2, multimedia files, relations)
- Vector Index: Semantic search (URIs, vectors, metadata)
Data Flow
Adding Context
Retrieving Context
Session Commit
Deployment Modes
Embedded Mode
For local development and single-process applications
- Auto-starts AGFS subprocess
- Uses local vector index
- Singleton pattern
HTTP Mode
For team sharing, production deployment, and cross-language integration
- Server runs as standalone process
- Clients connect via HTTP API
- Supports any language
Design Principles
OpenViking follows these core design principles to ensure scalability and maintainability:
| Principle | Description |
|---|---|
| Pure Storage Layer | Storage only handles AGFS operations and basic vector search; Rerank is in retrieval layer |
| Three-Layer Information | L0/L1/L2 enables progressive detail loading, saving token consumption |
| Two-Stage Retrieval | Vector search recalls candidates + Rerank improves accuracy |
| Single Data Source | All content read from AGFS; vector index only stores references |
Code Example: Client Initialization
Related Concepts
Context Types
Learn about Resource, Memory, and Skill types
Context Layers
Understand L0/L1/L2 progressive loading
Viking URI
Unified resource identifier system
Storage
Dual-layer storage architecture
