Skip to main content

Personal AI Chatbot for $0

Updated 3 min readMarkdown
Personal AI Chatbot for $0

Around 8–9 months ago, I built a persona-based chatbot that can answer questions about me using a controlled set of facts (skills, projects, background). It’s not “random AI memory” — it’s intentionally grounded in a persona profile so responses stay consistent.

The fun part: I deployed the whole thing on free tiers and it’s still running.

Stack

  • 🌐 Frontend: Netlify

  • ⚙️ Backend API: FastAPI on Render

  • 🗄️ Database: Supabase (Postgres)

  • 🤖 LLM: Gemini via Google AI Studio API key


What “persona-based” means here

This chatbot is designed to respond with facts about me that I control.

So if someone asks:

  • “What do you work on?”

  • “What’s your tech stack?”

  • “What projects have you built?”

…the assistant answers based on the persona record stored in Supabase, plus the chat history for context.

If the question is outside the persona’s knowledge, the bot should not invent facts. It should either say it doesn’t know or ask for clarification.


Architecture overview

Request flow:

  1. User opens the UI on Netlify (https://zaidzz.netlify.app)

  2. UI calls the backend on Render

  3. Backend:

    • loads chat context from Supabase (messages)

    • calls Gemini using the Google AI Studio API key

    • stores the new messages back into Supabase

  4. UI renders the response

A simple mental model:

Netlify (UI) → Render (FastAPI) → Supabase (data) + Gemini (responses) → back to UI


How the Gemini prompt stays grounded

On each /chat request, the backend builds a prompt like:

  • System: “You are responding as this persona. Only use these facts.”

  • Persona facts: pulled from personas

  • Conversation history: recent messages pulled from messages

  • User question: the new message

Then it calls Gemini and returns the result.

This pattern is simple but powerful:

  • ✅ consistent answers

  • ✅ less hallucination about personal details

  • ✅ easy persona updates (edit DB row, done)


Deployment setup

1) Deploy frontend to Netlify

  • Connect repo

  • Set your build command and publish directory

  • Add env var pointing to the Render API, something like:

    • VITE_API_BASE_URL = https://<your-render-service>.onrender.com

2) Deploy backend to Render (FastAPI)

Render runs the FastAPI server with a command like:

uvicorn main:app --host 0.0.0.0 --port $PORT

Backend environment variables (Render)

  • GEMINI_API_KEY (from Google AI Studio)

  • SUPABASE_URL

  • SUPABASE_KEY (anon or service role depending on your setup)

  • Any other secret keys you use

Important: keep Gemini key only on the backend. Never in the frontend.

3) Create tables in Supabase

  • Create messages

Free-tier gotchas (real talk)

Cold starts on Render 🥶

On free tier, your service may sleep, so the first request can be slow.
I handled this by running a Github Action workflow.

Quotas / limits on Gemini 📉

The key is free, and usage is free within quota. If you exceed it:

  • return a friendly error message

  • reduce message history sent per request

  • set max output tokens

  • keep persona facts concise

Don’t let the bot “invent” personal facts 🧠

If the question is not covered by persona facts, force the bot to say it doesn’t know. That’s the whole point of a persona-based system.


Open source

Backend repo: https://github.com/St-Neo/persona-based-chatbot

No comments yet. Be the first to comment.