🏗️ Architecture
/docs/architecture--modules/architecture
Domain-Driven Design with bounded contexts, clean architecture, and measured performance across all topologies.
V3 Module Structure
| Module | Purpose | Key Features |
|---|---|---|
@claude-flow/hooks | Event-driven lifecycle | ReasoningBank, 27 hooks, pattern learning |
@claude-flow/memory | Unified vector storage | AgentDB, RVF binary format, HnswLite, RvfMigrator, SONA persistence, LearningBridge, MemoryGraph |
@claude-flow/security | CVE remediation | Input validation, path security, AIDefence |
@claude-flow/swarm | Multi-agent coordination | 6 topologies, Byzantine consensus, auto-scaling |
@claude-flow/plugins | WASM extensions | RuVector plugins, semantic search, intent routing |
@claude-flow/cli | Command interface | 26 commands, 140+ subcommands, shell completions |
@claude-flow/neural | Self-learning | SONA, 9 RL algorithms, EWC++ memory preservation |
@claude-flow/testing | Quality assurance | London School TDD, Vitest, fixtures, mocks |
@claude-flow/deployment | Release automation | Versioning, changelogs, NPM publishing |
@claude-flow/shared | Common utilities | Types, validation schemas, RvfEventLog, constants |
@claude-flow/browser | Browser automation | 59 MCP tools, element refs, trajectory learning |
Architecture Principles
| Principle | Implementation | Benefit |
|---|---|---|
| Bounded Contexts | Each module owns its domain | No cross-module coupling |
| Dependency Injection | Constructor-based DI | Testable, mockable components |
| Event Sourcing | All state changes as events | Full audit trail, replay capability |
| CQRS | Separate read/write paths | Optimized queries, scalable writes |
| Clean Architecture | Domain → Application → Infrastructure | Business logic isolation |
Performance Benchmarks
Benchmarks measured on Node.js 20+ with local SQLite. Results vary by hardware and workload.
| Category | Metric | Target | Status |
|---|---|---|---|
| Startup | CLI cold start | <500ms | ✅ Met |
| Startup | MCP server init | <400ms | ✅ Met |
| Memory | HNSW search | <1ms | ✅ Sub-ms |
| Memory | Pattern retrieval | <10ms | ✅ Met |
| Swarm | Agent spawn | <200ms | ✅ Met |
| Swarm | Consensus latency | <100ms | ✅ Met |
| Neural | SONA adaptation | <0.05ms | ⚡ Benchmarked |
| Graph | Build (1k nodes) | <200ms | ✅ Met |
| Graph | PageRank (1k nodes) | <100ms | ✅ Met |
| Learning | Insight recording | <5ms | ✅ Met |
| Learning | Consolidation | <500ms | ✅ Met |
| Task | Success rate | 95%+ | ✅ Met |
Topology Performance
| Topology | Agents | Execution | Memory | Best For |
|---|---|---|---|---|
| Centralized | 2-3 | 0.14-0.20s | 180-256 MB | Simple tasks, single coordinator |
| Distributed | 4-5 | 0.10-0.12s | 128-160 MB | Parallel processing, speed |
| Hierarchical | 6+ | 0.20s | 256 MB | Complex tasks, clear authority |
| Mesh | 4+ | 0.15s | 192 MB | Collaborative, fault-tolerant |
| Hybrid | 7+ | 0.18s | 320 MB | Multi-domain, mixed workloads |
| Adaptive | 2+ | Variable | Dynamic | Auto-scaling, unpredictable load |