How amit2003dh/spikeai works
Purpose and API Entry Point
This is a Node.js marketing-analysis backend that answers natural-language B2B questions using GA4 analytics, Screaming Frog SEO export data, and an LLM. The HTTP boundary is an Express server exposing POST /query on port 8080.
• src/app.js
• src/ui.html
Request Control Plane
The API receives a user query plus GA4 property context, then delegates interpretation and execution to a central orchestrator. Agents do not coordinate directly; the orchestrator selects analytics, SEO, or combined processing and owns the final response path.
• src/app.js
• src/orchestrator.js
LLM Interpretation and Response Generation
The LLM adapter is the semantic boundary for converting natural language into structured GA4-report intent, classifying/routing queries, and producing user-facing answers. It connects through the OpenAI SDK to a LiteLLM proxy, with credentials expected from environment/configuration.
• src/llm.js
• src/orchestrator.js
GA4 Analytics Agent
The GA4 agent translates analytics requests into a constrained Google Analytics Data API runReport shape before querying a supplied property ID. This protects the external API from ambiguous terms such as “traffic,” and should return a graceful no-data result rather than failing for empty properties.
• src/agents/ga4Agent.js
• src/llm.js
SEO Audit Agent and Data Ingestion
The SEO agent analyzes Screaming Frog-style audit rows, especially URL/address and title-tag fields. Its data boundary is CSV loading/parsing rather than the Google Sheets API; data is converted into in-memory records for deterministic filtering such as title-length conditions.
• src/agents/seoAgent.js
• src/utils/dataLoader.js
Multi-Agent Fusion
For mixed questions, the orchestrator invokes GA4 and SEO work concurrently, then provides bounded raw result sets to the LLM for a semantic join. This allows fuzzy URL correspondence between GA4 paths and full audit URLs, trading token use for flexibility; inputs are limited to roughly the top 50 rows to control prompt size.
• src/orchestrator.js
• src/agents/ga4Agent.js
• src/agents/seoAgent.js
Runtime and External Dependencies
The service targets Node.js 18+ and Express. Material integrations are Google Analytics Data API via @google-analytics/data, CSV processing via csv-parse, and an OpenAI-compatible LiteLLM endpoint. Google service-account credentials are expected at deployment/runtime, and the deployment script installs dependencies and starts the server.
• package.json
• deploy.sh
• .env
Main entry points: orchestrator.js Orchestrator · llm.js LLM Adapter · app.js Express API · ga4Agent.js GA4 Agent
Components 12
Node.js Service
- Express API · Exposes POST /query on port 8080.
src/app.js - Orchestrator · Selects analytics, SEO, or combined processing and owns the response.
src/orchestrator.js - LLM Adapter · Builds report intent, classifies queries, and generates answers.
src/llm.js
Analysis Agents
- GA4 Agent · Constrains requests to GA4 runReport shapes and handles empty data.
src/agents/ga4Agent.js - SEO Agent · Filters Screaming Frog audit records including title-tag conditions.
src/agents/seoAgent.js - CSV Loader · Parses audit CSV into in-memory records.
src/utils/dataLoader.js
Data & AI Services
- Google Analytics Data API
- Screaming Frog CSV
- LiteLLM Proxy
Other components
- Query UI
src/ui.html - Runtime Credentials · Supplies LiteLLM and Google service-account credentials.
.env - Deployment Script · Installs dependencies and starts the Node.js service.
deploy.sh
Connections 14
- Query UI → Express API: POST /query
- Express API → Orchestrator: delegate query
- Orchestrator → LLM Adapter: classify and answer
- Orchestrator → GA4 Agent: analytics work
- Orchestrator → SEO Agent: SEO work
- Orchestrator → LLM Adapter: fuse bounded results · Combined results are limited to roughly 50 rows.
- LLM Adapter → GA4 Agent: structured report intent
- LLM Adapter → LiteLLM Proxy: OpenAI SDK
- GA4 Agent → Google Analytics Data API: runReport
- SEO Agent → CSV Loader: load audit rows
- CSV Loader → Screaming Frog CSV: parse CSV
- Runtime Credentials → LLM Adapter: proxy credentials
- Runtime Credentials → Google Analytics Data API: service account
- Deployment Script → Express API: start service