@@ -56,66 +56,117 @@ AI coding agents are becoming ubiquitous in software development, but organizati
5656
5757## Architecture Overview
5858
59+ ** Architecture Decision** : ** TypeScript + Go Hybrid** (finalized based on [ performance analysis] ( ./ai-agent-observability-performance-analysis.md ) )
60+
61+ ** Rationale** :
62+ - ** TypeScript** : Fast MVP development, MCP ecosystem, web UI (2 months to market)
63+ - ** Go** : High-performance backend services (50-120K events/sec), efficient resource usage
64+ - ** Benefits** : Best of both worlds - rapid iteration + production scalability
65+ - ** Cost** : $335K (6 months) vs $278K (TS-only) - delivers 5-10x better performance
66+
5967### High-Level Architecture
6068
6169```
6270┌─────────────────────────────────────────────────────────────────┐
63- │ AI Coding Agents │
64- │ (Copilot, Claude, Cursor, Gemini, Cline, Aider, etc.) │
65- └────────────────────────┬────────────────────────────────────────┘
66- │
67- │ MCP Protocol / Agent SDKs
68- │
69- ┌────────────────────────▼────────────────────────────────────────┐
70- │ Agent Activity Collection Layer │
71- │ • Event capture • Log aggregation • Real-time streaming │
72- └────────────────────────┬────────────────────────────────────────┘
73- │
74- ▼
75- ┌─────────────────────────────────────────────────────────────────┐
76- │ Processing & Analysis Engine │
77- │ • Event parsing • Metric calculation • Pattern detection │
78- └────────────────────────┬────────────────────────────────────────┘
79- │
80- ▼
71+ │ Developer Machine (Client) │
72+ │ ┌────────────────────────────────────────────────────────────┐ │
73+ │ │ AI Coding Agents (Copilot, Claude, Cursor, etc.) │ │
74+ │ └────────────────────┬───────────────────────────────────────┘ │
75+ │ │ Logs │
76+ │ ┌────────────────────▼───────────────────────────────────────┐ │
77+ │ │ Go Collector (~10-20MB binary) │ │
78+ │ │ • Log watcher • Event parser • Local buffer (SQLite) │ │
79+ │ │ • Batching (100 events/5s) • Offline support │ │
80+ │ └────────────────────┬───────────────────────────────────────┘ │
81+ └───────────────────────┼─────────────────────────────────────────┘
82+ │ HTTP/gRPC
83+ ▼
8184┌─────────────────────────────────────────────────────────────────┐
82- │ Storage & Indexing │
83- │ • Time-series events • Metrics aggregation • Full-text search │
84- └────────────────────────┬────────────────────────────────────────┘
85- │
86- ▼
87- ┌─────────────────────────────────────────────────────────────────┐
88- │ Visualization & Analytics Layer │
89- │ • Dashboards • Timeline views • Reports • Alerts │
85+ │ TypeScript API Gateway Layer │
86+ │ • Next.js API routes • MCP Server • Auth & session mgmt │
87+ │ • API orchestration (thin layer: 5-20ms latency) │
88+ └────────────┬───────────────────────────┬────────────────────────┘
89+ │ gRPC/REST │ gRPC/REST
90+ ┌────────────▼────────────┐ ┌──────────▼──────────────────────┐
91+ │ Go Event Processor │ │ TypeScript Services │
92+ │ • 50-120K events/sec │ │ • User management │
93+ │ • Adapter registry │ │ • Project management │
94+ │ • Transformation │ │ • Devlog CRUD │
95+ │ • Batching & buffering │ │ • Business logic │
96+ └────────────┬────────────┘ └──────────┬──────────────────────┘
97+ │ │
98+ ┌────────────▼───────────────────────────▼────────────────────────┐
99+ │ Go Real-time Stream Engine │
100+ │ • WebSocket server • Event broadcasting • Session monitoring │
101+ └────────────┬────────────────────────────────────────────────────┘
102+ │
103+ ┌────────────▼────────────────────────────────────────────────────┐
104+ │ Go Analytics Engine │
105+ │ • Metrics aggregation • Pattern detection • Quality analysis │
106+ └────────────┬────────────────────────────────────────────────────┘
107+ │
108+ ┌────────────▼────────────────────────────────────────────────────┐
109+ │ PostgreSQL + TimescaleDB │
110+ │ • agent_events (hypertable) • agent_sessions • Aggregations │
90111└─────────────────────────────────────────────────────────────────┘
91112```
92113
93114### Component Architecture
94115
95116```
96117packages/
97- ├── core/ # Enhanced core with agent observability
118+ ├── collector-go/ # NEW: Go client-side collector
119+ │ ├── cmd/collector/ # Main collector binary
120+ │ ├── internal/
121+ │ │ ├── adapters/ # Agent-specific log parsers
122+ │ │ ├── buffer/ # SQLite offline buffer
123+ │ │ ├── config/ # Configuration management
124+ │ │ └── watcher/ # File system watcher
125+ │ └── pkg/client/ # Backend HTTP/gRPC client
126+ │
127+ ├── services-go/ # NEW: Go backend services
128+ │ ├── event-processor/ # Event processing service (50-120K/sec)
129+ │ ├── stream-engine/ # Real-time WebSocket streaming
130+ │ ├── analytics-engine/ # Metrics aggregation & pattern detection
131+ │ └── shared/ # Shared Go libraries & utilities
132+ │
133+ ├── core/ # Enhanced core with agent observability (TypeScript)
98134│ ├── agent-events/ # NEW: Agent event types and schemas
99135│ ├── agent-collection/ # NEW: Event collection and ingestion
100136│ ├── agent-analytics/ # NEW: Metrics and analysis engine
101137│ └── services/ # Existing services + new agent services
102138│
103- ├── mcp/ # MCP server with observability tools
139+ ├── mcp/ # MCP server with observability tools (TypeScript)
104140│ ├── tools/ # Existing + new agent monitoring tools
105- │ └── collectors/ # NEW: Event collectors for different agents
141+ │ └── collectors/ # NEW: Collector control tools
106142│
107- ├── ai/ # AI analysis for agent behavior
143+ ├── ai/ # AI analysis for agent behavior (TypeScript)
108144│ ├── pattern-detection/ # NEW: Identify patterns in agent behavior
109145│ ├── quality-analysis/ # NEW: Code quality assessment
110146│ └── recommendation-engine/ # NEW: Suggest improvements
111147│
112- └── web/ # Enhanced UI for observability
148+ └── web/ # Enhanced UI for observability (TypeScript/Next.js)
113149 ├── dashboards/ # NEW: Agent activity dashboards
114150 ├── timelines/ # NEW: Visual agent action timelines
115151 ├── analytics/ # NEW: Performance and quality analytics
116152 └── reports/ # NEW: Custom reporting interface
117153```
118154
155+ ### Technology Stack Summary
156+
157+ | Component | Language | Rationale |
158+ | -----------| ----------| -----------|
159+ | ** Client Collector** | Go | Small binary (~ 10-20MB), cross-platform, efficient |
160+ | ** Event Processing** | Go | High throughput (50-120K events/sec), low latency |
161+ | ** Real-time Streaming** | Go | Efficient WebSocket handling, 50K+ connections |
162+ | ** Analytics Engine** | Go | Fast aggregations, pattern detection performance |
163+ | ** API Gateway** | TypeScript | MCP integration, rapid development, Next.js |
164+ | ** Business Logic** | TypeScript | Fast iteration, existing codebase integration |
165+ | ** Web UI** | TypeScript/Next.js | React ecosystem, server components |
166+ | ** Database** | PostgreSQL + TimescaleDB | Time-series optimization, mature ecosystem |
167+
168+ ```
169+
119170## Core Features
120171
121172### Phase 1: Agent Activity Collection & Storage (Foundation)
0 commit comments