Skip to content

Snack-JPG/Playbook

Repository files navigation

📖 Playbook

AI-powered SOP knowledge base. Ask questions about your company procedures and get step-by-step answers from your documentation.

Stack

  • Next.js 15 (App Router)
  • Supabase (Postgres + pgvector)
  • OpenAI (embeddings + chat via Vercel AI SDK)
  • shadcn/ui + Tailwind CSS

Setup

1. Supabase

Create a Supabase project, then run the migration:

# Via Supabase dashboard: SQL Editor → paste contents of supabase/migrations/001_initial_schema.sql
# Or via CLI:
supabase db push

Note the id of the inserted "Demo Company" client — you'll need it for DEFAULT_CLIENT_ID.

2. Environment Variables

cp .env.example .env.local

Fill in:

  • NEXT_PUBLIC_SUPABASE_URL — from Supabase project settings
  • NEXT_PUBLIC_SUPABASE_ANON_KEY — from Supabase project settings
  • SUPABASE_SERVICE_ROLE_KEY — from Supabase project settings (service role, not anon)
  • OPENAI_API_KEY — from OpenAI dashboard
  • DEFAULT_CLIENT_ID — UUID of the demo client row

3. Install & Run

npm install
npm run dev

4. Seed Data

With the dev server running:

npx tsx seed/seed.ts

This creates 3 sample SOPs (Client Onboarding, Invoice Processing, New Employee Setup) with embedded chunks.

5. Use

  • / — Chat interface. Ask questions like "How do I onboard a new client?"
  • /admin — Manage SOPs and view analytics

Architecture

  • SOPs are split into ~400-token chunks at ## heading boundaries
  • Each chunk is embedded via OpenAI text-embedding-ada-002
  • Chat queries are embedded and matched via pgvector cosine similarity
  • Matched chunks are injected as context for GPT-4o-mini to answer
  • Query logs track usage, confidence, and feedback for analytics

About

AI-powered knowledge base for manufacturing teams. RAG + pgvector + OpenAI embeddings. Upload SOPs, search with natural language.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors