# How to Vibe Code Your Own Afforai (and Stop Paying for It)

> Research, Cite, and Write With AI

- Site: https://afforai.com
- Category: Web app
- Verdict: **Solid side project** (75/100 vibecodeable)
- Estimated effort: 2-3 weekends of focused building and debugging

## Verdict

You can build a fully functional personal RAG literature assistant over a couple of weekends, bypassing monthly subscription fees if you only need it for your own research.

The core engine relies on standard retrieval-augmented generation patterns, vector search, and a PDF viewer. While parsing messy multi-column academic papers cleanly will test your patience with chunking strategies and extraction edge cases, AI coding agents make scaffolding the database schemas, API routes, and split-screen interface straightforward. The main hurdle is getting PDF text layouts and citation anchoring to line up smoothly without endless prompt tweaking.

### What you can't replicate

- Afforai's hosted cloud infrastructure and team collaboration network
- Legacy user database and billing systems

## What it does

An AI-powered reference manager and literature review assistant that helps users source, summarize, translate, annotate, and cite academic papers using RAG.

### Core features

- PDF upload, text extraction, and chunking pipeline
- Vector embeddings generation and semantic search
- Multi-document RAG querying with inline citations
- Split-screen document viewer with interactive citation jumps
- Document translation and summarization tools
- Citation generator and export manager

## The business

### Pricing

- Free: $0/mo
- Unlimited: $8/mo
- Team: $16/mo

Founded 2023.
Team size: 4.

## The hard parts

- Extracting clean text, tables, and multi-column formatting from dense academic PDFs without losing context
- Orchestrating hybrid keyword/semantic retrieval and reranking to prevent AI hallucinations across massive corpora
- Managing token limits and context window allocation during simultaneous multi-file querying
- Syncing split-screen UI state so clicking an inline citation scrolls the PDF reader to the exact source paragraph

## How to vibe code Afforai

### Prerequisites

- Node.js (free): Runtime environment for the Next.js full-stack framework
- GitHub (free): Version control and repository hosting
- OpenAI API Key (Pay-per-token (~$5-10/mo)): Generates text embeddings and powers the RAG synthesis engine

### Recommended AI tools

- Cursor: Provides an AI-native code editor interface ideal for iterative frontend styling and debugging document viewer components
- Claude Code: Handles complex multi-file backend scaffolding, database migrations, and RAG pipeline setup directly from the terminal

### Stack

- Frontend: Next.js with Tailwind CSS and shadcn/ui components
- Backend: Next.js App Router API endpoints
- Database: Neon (Postgres with pgvector extension)
- Auth: better-auth
- Payments: None (personal use)
- Other: Vercel AI SDK for LLM integration, pdf-parse or unpdf for document extraction

### Hosting

- Vercel (Hosting the Next.js frontend and serverless API functions): $0/mo (Hobby tier)
- Neon (Serverless Postgres database storing document metadata and vector embeddings): $0/mo (Free tier)

### Build guide

1. **Project Scaffolding and Database Schema** — Initialize the Next.js application with TypeScript, Tailwind CSS, and shadcn/ui. Configure Drizzle ORM connected to Neon Postgres with the pgvector extension enabled, defining tables for documents, chunks, and chat messages.

```
Create a new Next.js 16 project using TypeScript, App Router, and Tailwind CSS. Install Drizzle ORM and set up the connection configuration for Neon Postgres. Define database schemas in lib/db/schema.ts for users, documents (id, title, file_url, created_at), document_chunks (id, document_id, content, chunk_index, embedding vector(1536)), and chat_conversations/messages. Ensure pgvector extension support is included in the schema definition.
```

2. **PDF Upload and Text Extraction Pipeline** — Implement a file upload endpoint that accepts research PDFs, stores files securely, extracts raw text using a parsing library, and splits the content into manageable overlapping chunks.

```
Build a server action and API endpoint in Next.js to handle multi-file PDF uploads. Integrate a robust PDF text extraction library (such as pdf-parse or unpdf) to pull raw text from uploaded files. Implement a chunking utility function that splits extracted text into 500-token segments with a 50-token overlap, preserving metadata like page numbers where possible.
```

3. **Embedding Generation and Vector Storage** — Integrate the OpenAI embeddings API to vectorize text chunks and store them in Neon Postgres using pgvector for semantic retrieval.

```
Write a background processing pipeline that takes newly chunked document segments, calls the OpenAI text-embedding-3-small API to generate vector embeddings, and inserts them into the document_chunks table in Neon Postgres. Add an error handling wrapper for rate limits and retries during bulk vectorization.
```

4. **RAG Query Engine and Multi-File Chat** — Build the semantic search retrieval mechanism and chat endpoint that queries multiple uploaded documents simultaneously using vector similarity and streams responses.

```
Create a RAG chat API route using the Vercel AI SDK. When a user submits a query, generate an embedding for the query text, perform a vector similarity search across document_chunks using pgvector cosine distance, and retrieve the top relevant context blocks. Construct a prompt incorporating these chunks with inline citation tags (e.g. [Doc ID, Chunk Index]) and stream the synthesized response back to the client.
```

5. **Split-Screen UI and Interactive Citation Viewer** — Develop a responsive split-screen dashboard layout featuring a document management sidebar, a chat interface with streaming answers, and an embedded PDF viewer that jumps to citation sources.

```
Build a responsive split-screen dashboard UI using Tailwind CSS and shadcn/ui. The left side should feature a document library list and file uploader. The center/right side should contain a chat interface supporting streaming markdown responses. Implement clickable inline citation badges in chat messages that, when clicked, trigger the embedded PDF viewer to highlight and scroll to the corresponding page and paragraph.
```

6. **Authentication and Polish** — Integrate better-auth for secure user login and session management, and refine error handling, loading states, and UI styling.

```
Integrate better-auth into the Next.js application for email/password authentication, securing all dashboard routes and associating uploaded documents and chat histories with the authenticated user ID. Add loading skeletons for PDF processing and empty states for the document library.
```

### Cost vs paying

**Starting costs (one-time):**

- AI Coding Assistant Pro subscription: $20
- OpenAI API starting credits: $10
- Total: ~$30 one-time

**Ongoing costs (monthly):**

- OpenAI API usage (embeddings + chat queries): ~$3-5/mo
- Vercel & Neon hosting: $0/mo (Free tiers)
- Total: ~$4/mo

- Paying for the SaaS instead: $8/mo - $16/mo
- Build time: 12-18 hours
- AI tool credits: $20 (Cursor/Claude Pro for one month)
- Break-even: 4 months

## Sources

- [Afforai Official Website](https://afforai.com)
- [Plug and Play Tech Center Investment Announcement](https://www.plugandplaytechcenter.com)
- [GetLatka Afforai Revenue & Valuation Data](https://getlatka.com)