Technical documentation for the portfolio app built with Node.js, n8n and Supabase.
Live interaction flow of the chat UI with the current deployed environment.
AI Agent is a general AI portfolio project with a chat interface and an integration-first backend. The app sends user prompts to an n8n webhook flow and returns the response in a simple chat UX. Interactions and execution metadata can be persisted in Supabase for observability.
UI (public/) -> POST /api/agent -> rate-limit middleware -> controller -> service -> n8n webhook
\-> saveInteractionLog -> Supabase
UI (public/) -> GET /api/agent/metrics -> controller -> Supabase aggregate (fallback: runtime)
/api/agentSend a user message to the assistant.
{
"message": "Explain this timeout"
}
text/plain: assistant reply (includes fallback when n8n is unavailable)application/json: invalid inputapplication/json: unexpected internal error/health{ "ok": true }
/api/agent/metricsReturns real-time dashboard metrics from Supabase (or in-memory runtime fallback when unavailable).
{
"ok": true,
"totalExecutions": 12842,
"criticalErrors": 12,
"avgResponseTimeMs": 248,
"durationSampleSize": 500,
"source": "supabase"
}
PORT=3000 N8N_WEBHOOK_URL=https://your-n8n-instance/webhook/agent SUPABASE_URL=https://.supabase.co SUPABASE_SERVICE_ROLE_KEY= SUPABASE_TABLE=agent_messages # n8n retry policy (429) N8N_RETRY_MAX=2 N8N_RETRY_BASE_DELAY_MS=800 # API rate limit (per IP) RATE_LIMIT_WINDOW_MS=60000 RATE_LIMIT_MAX_REQUESTS=20 RATE_LIMIT_BLOCK_MS=30000 # Metrics sampling METRICS_SAMPLE_LIMIT=500
npm install.env from .env.examplenpm run devhttp://localhost:3000create table if not exists public.agent_messages ( id bigserial primary key, created_at timestamptz not null default now(), message text, response_body jsonb, ok boolean not null default false, error_message text );
Retry-After.N8N_RETRY_MAX and N8N_RETRY_BASE_DELAY_MS.N8N_WEBHOOK_URL and webhook execution in n8n.SUPABASE_URL and service key).npm start and Node version >= 18.v1.3.1: final UI/docs polish with integrated header, refined About section, demo in docs and version consistency across app/documentation.v1.3.0: dashboard connected to real metrics via /api/agent/metrics.v1.2.1: retry with exponential backoff for n8n 429 responses + API rate limit per IP.v1.2.0: docs and interface reorganized into Chat, Changelog and About Project sections.v1.1.0: interaction persistence migrated to Supabase Postgres.