A modern mini-chat application built with SvelteKit, TypeScript, TailwindCSS, and integration with Supabase and OpenAI. The project showcases a clean interface, global navigation, and a lightweight API to interact with a language model.
/api/chat route using the chat.completions API.src/
ββ lib/
β ββ assets/ β favicon & static assets
β ββ server/
β ββ api_llm/openai.ts β OpenAI client (chat completions)
β ββ supabase/client.ts β Supabase client and functions
ββ routes/
β ββ +layout.svelte β Navigation bar, light/dark theme
β ββ +layout.ts β Loads shared data (e.g. current path, user, settings)
β ββ +page.svelte β Home page
β ββ speak-with-llm/
β β ββ +page.svelte β Chat interface & form actions
β β ββ +page.server.ts β Load messages & save to DB actions
β ββ api/chat/+server.ts β POST endpoint to relay messages to LLM
ββ app.css / app.html β Global styles & SvelteKit shell
npm install
Create a .env file at the root with the available keys:
OPENAI_API_KEY="sk-..."
OPENAI_API_MODEL="gpt-4o-mini"
PUBLIC_SUPABASE_URL="https://xxxx.supabase.co"
PUBLIC_SUPABASE_ANON_KEY="public-anon-key"
Get PUBLIC_SUPABASE_URL and PUBLIC_SUPABASE_ANON_KEY after bdd created
npm run dev -- --open
The SvelteKit development server runs by default on http://localhost:5173.
npm run build
npm run preview
Then, deploy to the hosting provider of your choice (requires the appropriate SvelteKit adapter for the target).
/api/chat Route: Receives the message, calls OpenAI, and returns the JSON response.localStorage.