A production-ready, AI-powered e-commerce support chatbot built with:
- Vercel AI SDK (streaming, tools, edge-ready)
- Google Gemini (LLM)
- Prisma + Neon DB (type-safe, serverless Postgres)
- Zod (robust schema validation)
- Next.js (modern frontend, App Router)
- Conversational AI: Natural support for orders, products, support tickets, and more.
- Database integration: Type-safe queries and mutations via Prisma and Neon DB.
- Streaming LLM responses: Fast, real-time answers powered by Google Gemini and Vercel AI SDK.
- Input validation: All API and LLM-tool inputs validated with Zod.
- Modern UI: Responsive React/Next.js chat interface with Markdown rendering and animated UX.
- Extensible: Add tools, business logic, validation, or third-party API integrations easily.
- Frontend: Next.js, React, Tailwind CSS, framer-motion, react-markdown
- Backend: Vercel AI SDK, Google Gemini, Prisma, Neon DB, Zod, nanoid
git clone https://github.com/Aparnap2/vercel-ai-sdk.git
cd vercel-ai-sdk
npm install
-
Google Gemini API Key:
Get your key from Google AI Studio
Add to.env.local
:GOOGLE_GENERATIVE_AI_API_KEY=your-google-api-key
-
Neon DB (Postgres) connection:
Get your connection string from neon.tech
Add also to.env.local
:DATABASE_URL=postgresql://USER:PASSWORD@HOST:PORT/DB
npx prisma db push
npx prisma generate
# (Optional) seed your DB if you have a script
npm run dev
Open http://localhost:3000 and chat!
├── app/
│ ├── api/
│ │ └── chat/
│ │ ├── route.js # API endpoint (Vercel AI SDK + tools)
│ │ └── system-prompt.js # System prompt for LLM
│ └── page.jsx # Main chat UI
├── lib/
│ ├── ai/
│ │ └── google.js # Google Gemini config
│ └── tools/
│ └── database.js # DB query tool with Zod validation
├── prisma/
│ └── schema.prisma # Prisma models
├── public/
│ └── images/ # Project images
├── .env.local # API keys and DB URL
├── package.json
└── README.md
- Frontend: Users chat with the bot via a Next.js interface. Messages are sent to
/api/chat
. - API Route:
- Handles simple greetings directly.
- For all other queries, uses
generateText
from Vercel AI SDK with Google Gemini, and exposes a customdb_query
tool (validated by Zod and powered by Prisma). - Returns Markdown-formatted, streaming responses.
- Database: All queries are validated (Zod) and run with Prisma on Neon DB, returning only safe, allowed data.
- All tool inputs are validated with Zod before touching the DB.
- Edge runtime ready: Fast, scalable, serverless deployment.
- No sensitive data returned by default (customize tool output as needed).
- Easy to extend:
- Add new tools (APIs, actions, etc.)
- Expand the Prisma schema
- Customize system prompt/business logic
- Change the System Prompt:
Editapp/api/chat/system-prompt.js
- Modify data models:
Editprisma/schema.prisma
and runnpx prisma db push
- Add/modify tools:
Seelib/tools/database.js
- UI tweaks:
Editapp/page.jsx
and Tailwind classes
MIT