Skip to content

mridubhatnagar/prepwise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PrepIt

A RAG-powered technical interview prep assistant. Ask questions about system design, databases, DSA, and AI — get precise answers with citations, suggested follow-ups, and conversational context.

Invite-only. Sign in with Google.


Features

  • RAG-powered answers — hybrid search (BM25 + semantic) over a curated knowledgebase; returns structured answers with source citations
  • Adaptive responses — classifies the question type (concept, specific aspect, deeper reasoning, system design) and adjusts response depth in a single LLM call
  • Cited sources — every answer includes citation chips linking back to the source document and section
  • Follow-up suggestions — each response includes 2–3 suggested follow-up questions rendered as clickable pills
  • Conversation continuity — last 10 messages passed as context to the LLM for multi-turn conversations
  • Context limit enforcement — conversation is capped; banner prompts the user to clear and continue
  • Message feedback — thumbs up/down on each AI response; ratings sent to Arize Phoenix for analysis
  • Prompt injection defense — input blocklist before LLM call; output guardrail strips hallucinated citations
  • Spend tracking — every OpenAI API call logged with cost; daily crossing-point email alert fires once when threshold is exceeded
  • Rate limiting — per-user limit on chat, per-IP limit on auth initiation
  • Observability — full RAG trace (query → retrieval → prompt → response) in self-hosted Arize Phoenix
  • Session management — single active session per user; Clear Chat deactivates and creates a new one; messages retained in DB
  • Invite-only access — Google OAuth with an allowlist; unauthorized attempts are logged

Tech Stack

Concern Choice
Backend FastAPI
Frontend Alpine.js + Bootstrap 5
Auth Google OAuth 2.0 + JWT (HttpOnly cookie)
LLM OpenAI GPT-4o
Embeddings OpenAI text-embedding-3-small
Vector DB Weaviate (self-hosted)
Relational DB PostgreSQL + SQLAlchemy + Alembic
Observability Arize Phoenix (self-hosted)

Prerequisites

  • Docker + Docker Compose
  • Python 3.11+
  • A Google OAuth 2.0 app (Client ID + Secret)
  • An OpenAI API key

Setup

1. Clone and install dependencies

git clone https://github.com/<your-username>/prepwise.git
cd prepwise
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

2. Configure environment

cp .env.example .env.local

Fill in all values in .env.local. See .env.example for the full list of required keys.

3. Run database migrations

alembic upgrade head

4. Ingest knowledge base documents

python scripts/ingest.py

5. Start the app

docker compose up -d

Visit http://localhost:8000.


Allowlist

Access is invite-only. Add a user's email to the allowed_users table before they can sign in.


Observability

Phoenix UI is available at http://localhost:6006. All OpenAI calls (embeddings + LLM) are traced automatically.


Environment Variables

See .env.example for the full list. Key variables:

Variable Description
GOOGLE_CLIENT_ID Google OAuth client ID
GOOGLE_CLIENT_SECRET Google OAuth client secret
GOOGLE_REDIRECT_URI OAuth callback URL
OPENAI_API_KEY OpenAI API key
DATABASE_URL PostgreSQL connection string
JWT_SECRET Secret for signing JWT tokens
SPEND_ALERT_THRESHOLD Daily spend limit in USD before email alert

Project Structure

prepwise/
├── app.py              # FastAPI entry point
├── config.py           # Centralised config (reads from .env)
├── constants.py        # Business constants
├── auth/               # Google OAuth, JWT, allowlist
├── chat/               # Sessions, message history, context limits
├── rag/                # Retrieval, confidence check, LLM response
├── spend/              # Cost logging and spend alerts
├── feedback/           # Thumbs up/down on AI responses
├── documents/          # KB document listing
├── infra/              # PostgreSQL + Weaviate client setup
├── scripts/            # ingest.py — one-time KB ingestion
├── docs/               # Raw knowledge base documents (Markdown)
├── templates/          # landing.html, chat.html
└── static/             # Alpine.js, CSS, images

About

AI powered study partner to help you revise your technical fundamentals.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors