Nova (ΩΩΨ§) is a production-grade, Persian-first Retrieval-Augmented Generation (RAG) assistant for e-commerce, built with Next.js 16 (App Router + Turbopack), the Vercel AI SDK, Google Gemini 2.5, and Supabase pgvector. It answers customer inquiries about shipping, returns, warranties, sizing, and policies strictly from store documentation, executing tool-driven semantic search and citing authoritative sources on every response.
β‘ Portfolio-Level AI Project β Showcasing senior-level work in RAG pipeline design, embedding chunking strategies, Persian RTL interface architecture, agentic tool calling, and evaluation harnesses.
- π§ Agentic RAG Pipeline β Gemini autonomously invokes
search_knowledge,list_sources, andread_documenttools with up to 6 iterative steps to retrieve context before generating an answer - π Strict Grounding & Hallucination Defense β Answers strictly adhere to ingested markdown documents (
data/*.md); queries outside the knowledge base receive an explicit, honest "information not found" response - π Interactive Source Citations β Inline citation chips
[Ϋ±]dynamically resolve to document chips under each answer, rendering exact source references - π¨ Persian-First RTL Design System β Custom warm palette, optical text balancing, self-hosted Vazirmatn font, and zero-flash dark mode (default)
- β‘ Real-Time Streaming β Token-by-token streaming UI with animated thinking indicator and live tool execution chips
- π Auto-Follow Smart Scroll β Automatically sticks to the latest streaming token when at the bottom; gracefully pauses when the user scrolls up to review history
- π‘οΈ Production-Grade Rate Limiting β Dual sliding-window IP rate limiting (10 req/min + 50 req/day) backed by Upstash Redis, failing open gracefully if Redis is unconfigured
- π Zero-Flash Dark / Light Theme β Pre-paint inline script applies theme before hydration, with dark mode as the default experience
- π§ͺ Automated Evaluation Suite β Built-in test harness (
evals/run.ts) executing multi-step factual assertions and pacing requests to prevent rate limits - π± Responsive & Mobile Ready β Verified responsive layout down to 390px viewports with touch-friendly controls and sticky composer
Full conversation view showing user message, agent reply, interactive citation chips, and active assistant status.
Empty state with suggested quick-prompt cards, NOVA brand mark, and clean RTL typography.
Close-up of tool execution chips (Ψ¬Ψ³ΨͺβΩΨ¬Ω Ψ―Ψ± Ψ§Ψ³ΩΨ§Ψ―) and resolved source chips under the assistant answer.
Responsive 390px layout with adaptive brand header, compact action buttons, and touch-optimized composer.
| Path | Description |
|---|---|
src/app/api/chat/route.ts |
Edge-ready streaming chat endpoint orchestrating rate-limiting, message trimming, and Gemini stream |
src/app/globals.css |
Complete Tailwind v4 design system, color tokens, RTL resets, animations, and typography rules |
src/app/layout.tsx |
Root layout with pre-hydration dark-theme script, metadata, and viewport configuration |
src/app/page.tsx |
Main page wrapping the Chat client component in a Suspense boundary |
src/components/Chat |
Core chat UI component handling stream lifecycle, smart scroll, Markdown, and theme toggling |
src/lib/chunk.ts |
Paragraph-aware markdown text chunker with configurable overlap |
src/lib/embed.ts |
Google gemini-embedding-001 client with 768-dim vectors and batching |
src/lib/model.ts |
Gemini model configuration and dynamic thinking budget control |
src/lib/prompt.ts |
Grounded system instructions enforcing tone, boundaries, and citation format |
src/lib/rag.ts |
Supabase RPC vector match query runner (match_chunks) |
src/lib/ratelimit.ts |
Upstash Redis sliding-window rate limiters with graceful fallback |
src/lib/supabase.ts |
Supabase client singleton |
src/lib/tools.ts |
Vercel AI SDK tool definitions for agent document search and retrieval |
data/*.md |
Knowledge base documents (company, shipping, returns, sizing, warranty, payment, FAQ) |
scripts/ingest.ts |
CLI script to chunk, embed, and upsert markdown docs into Supabase pgvector |
evals/run.ts |
Automated accuracy and hallucination benchmark suite |
public/brand |
Brand masks, wordmark, monogram, and persona avatar assets |
βββββββββββββββββββ ββββββββββββββββββββββββββ ββββββββββββββββββββββββ
β User Question β ββββ> β Next.js /api/chat β ββββ> β Gemini Agent Loop β
βββββββββββββββββββ ββββββββββββββββββββββββββ ββββββββββββ¬ββββββββββββ
β
βββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββ
β Tool Call: search_knowledge(query) β
βΌ βΌ
βββββββββββββββββββββββββ βββββββββββββββββββββββββ
β gemini-embedding-001 β β Supabase pgvector β
β (768-dim query vec) β βββββββββββββββββββββββββ> β match_chunks RPC β
βββββββββββββββββββββββββ ββββββββββββ¬βββββββββββββ
β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββ
β Stream Markdown + β ββββ> Client UI (Auto-Scroll & Citations)
β Source Citations β
βββββββββββββββββββββββββ
- Ingestion (
scripts/ingest.ts) β Reads markdown files fromdata/, splits text with paragraph preservation and overlap, generates 768-dimensional embeddings via Googlegemini-embedding-001, and upserts into Supabasechunks. - User Request (
/api/chat) β Enforces Upstash sliding-window rate limits, trims conversational history, and initiates an agentic loop with Gemini. - Agent Loop (
src/lib/tools.ts) β Gemini analyzes the inquiry, determines whether document retrieval is required, callssearch_knowledge, and inspects cosine similarity scores. - Streaming Response β Answer streams to the client with
useChat, rendering sanitized Markdown, code copy buttons, interactive citation badges[Ϋ±], and resolved source chips.
- Node.js 20+ and npm
- Google Gemini API Key (via Google AI Studio)
- Supabase project with the
pgvectorextension enabled - (Optional) Upstash Redis for production rate limiting
git clone https://github.com/condev-dev/nova-agent.git
cd nova-agent
npm installCreate .env.local based on .env.example:
cp .env.example .env.localFill in the required keys:
GOOGLE_GENERATIVE_AI_API_KEY=your_gemini_api_key
MODEL_ID=gemini-2.5-flash
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
UPSTASH_REDIS_REST_URL=https://your-redis.upstash.io
UPSTASH_REDIS_REST_TOKEN=your_redis_tokenRun the following SQL in your Supabase SQL Editor:
create extension if not exists vector;
create table documents (
id uuid primary key default gen_random_uuid(),
source text not null unique,
title text not null,
created_at timestamptz default now()
);
create table chunks (
id uuid primary key default gen_random_uuid(),
document_id uuid references documents(id) on delete cascade,
source text not null,
chunk_index int not null,
content text not null,
embedding vector(768) not null
);
create index on chunks using ivfflat (embedding vector_cosine_ops) with (lists = 100);
create or replace function match_chunks(
query_embedding vector(768),
match_count int default 5,
similarity_threshold float default 0.4
)
returns table (
id uuid,
document_id uuid,
source text,
chunk_index int,
content text,
similarity float
)
language sql stable
as $$
select
chunks.id,
chunks.document_id,
chunks.source,
chunks.chunk_index,
chunks.content,
1 - (chunks.embedding <=> query_embedding) as similarity
from chunks
where 1 - (chunks.embedding <=> query_embedding) > similarity_threshold
order by chunks.embedding <=> query_embedding
limit match_count;
$$;npm run ingestnpm run devOpen http://localhost:3000 in your browser.
npm run evalΒ© ConDev β All rights reserved.


