A modern, production-ready AI chatbot interface built with Svelte 5, SvelteKit, and Vercel AI SDK. Features streaming responses, conversation history, markdown rendering, and a beautiful responsive UI.
git clone <your-repo-url>
cd svelte-ai-chatbot-ui
npm install
Create a .env file in the root directory:
OPENAI_API_KEY=your_openai_api_key_here
If you don't provide an API key, the app will use mock responses for development.
npm run dev
Open http://localhost:5173 in your browser.
svelte-ai-chatbot-ui-1/
āāā src/
ā āāā lib/
ā ā āāā components/
ā ā ā āāā ui/ # UI components (Button, Input, Card, etc.)
ā ā ā āāā chat/ # Chat components (MessageBubble, ChatInput, etc.)
ā ā āāā stores/ # Svelte stores (chatStore)
ā ā āāā types.ts # TypeScript types
ā ā āāā utils.ts # Utility functions
ā āāā routes/
ā ā āāā api/
ā ā ā āāā chat/
ā ā ā āāā +server.ts # AI streaming API route
ā ā āāā +page.svelte # Main chat page
ā āāā app.css # Global styles
ā āāā app.d.ts # TypeScript declarations
ā āāā app.html # HTML template
āāā static/ # Static assets
āāā README.md # This file
The app uses Vercel AI SDK's streamText to stream AI responses token by token, providing a smooth user experience. The frontend reads the stream and updates the message in real-time.
All conversations are stored in localStorage using Svelte stores. The chat history sidebar allows you to switch between conversations and create new ones.
AI responses are rendered as markdown using the marked library, supporting code blocks, lists, bold text, and more.
The app supports both light and dark themes with system preference detection. The theme preference is persisted in localStorage.