# Setup Guide — Handbook Generator (Streamlit + Supabase + Gemini)
## Prerequisites
- Python 3.10+ installed
- A Google Gemini API key
- A Supabase project (Postgres) with pgvector enabled
---
## 1) Clone repo + create virtual environment
```bash
git clone
cd handbook-generator
python -m venv venv
# Windows:
venv\Scripts\activate
# Mac/Linux:
# source venv/bin/activatepip install -r requirements.txtCreate a project in Supabase, then copy:
- Project URL
- anon public key (from: Project Settings → API)
In Supabase → SQL Editor, run:
create extension if not exists vector;(Embedding dimension is 3072 for gemini-embedding-001)
create table if not exists documents (
id bigserial primary key,
content text not null,
metadata jsonb,
embedding vector(3072)
);create or replace function match_documents(
query_embedding vector(3072),
match_count int default 5
)
returns table(id bigint, content text, similarity float)
language sql stable
as $$
select
documents.id,
documents.content,
1 - (documents.embedding <=> query_embedding) as similarity
from documents
order by documents.embedding <=> query_embedding
limit match_count;
$$;setx GEMINI_API_KEY "YOUR_GEMINI_KEY"
setx SUPABASE_URL "YOUR_SUPABASE_PROJECT_URL"
setx SUPABASE_ANON_KEY "YOUR_SUPABASE_ANON_KEY"Close and re-open your terminal after running setx.
export GEMINI_API_KEY="YOUR_GEMINI_KEY"
export SUPABASE_URL="YOUR_SUPABASE_PROJECT_URL"
export SUPABASE_ANON_KEY="YOUR_SUPABASE_ANON_KEY"streamlit run app.pyOpen the local URL Streamlit prints (usually http://localhost:8501).
- Upload a PDF
- Click Index this PDF in Supabase
- Ask a question in the chat input → verify contextual answer
- Enter a handbook topic → click Generate Handbook → verify output reaches 20,000+ words
- Download the generated
handbook.md
- If Gemini model name fails: use
gemini-2.5-flashfor generation. - If search returns nothing: make sure you indexed at least one PDF and the SQL function exists.
- If Supabase insert fails: verify
vectorextension is enabled and embedding dimension is3072.
If you want, paste your current `requirements.txt` here and I’ll clean it up (remove extras) so your setup guide matches exactly.