Transform any GitHub repository into comprehensive, AI-powered documentation with semantic code search.
Built with advanced RAG (Retrieval-Augmented Generation) pipeline, knowledge graph for code relationships, multi-agent system, and vector search for intelligent code discovery.
- π Wiki Generation - Analyzes GitHub repos and generates feature-focused documentation
- π§ Knowledge Graph - Discovers complete features by following function calls
- π Semantic Search - Natural language search across all indexed codebases
- π€ AI Agents - 4 specialized agents analyze tech stack, features, and architecture
- π GitHub Integration - Direct links to source code with line numbers
- Fetches code from any public GitHub repository
- Builds knowledge graph from function calls (discovers code relationships)
- Analyzes tech stack and architecture patterns
- Identifies user-facing features with complete code flows
- Generates MDX documentation with code examples
- Stores wikis in Vercel Blob for instant access
- Natural language queries ("user authentication", "database queries")
- AI-powered vector embeddings for semantic understanding
- Search across all generated wikis
- View code snippets with GitHub source links
- Fast results with Upstash Vector
- Recon Agent - Identifies tech stack, languages, frameworks, and architecture
- Features Agent - Detects user-facing features using knowledge graph (follows function calls to discover complete features)
- Architecture Agent - Analyzes architectural patterns and design
- Docs Generator - Creates comprehensive documentation with code citations
- Extracts function calls from code using AST parsing (all languages supported)
- Builds graph:
function Aβ calls βfunction Bβ calls βfunction C - Discovers complete features by finding entry points and traversing the graph
- Example:
login()β discoversvalidateInput(),findUser(),generateToken()(complete auth flow)
# 1. Clone and install
git clone <your-repo>
cd wiki-generator
npm install
# 2. Set up environment variables
cp .env.local.example .env.local
# Edit .env.local and add:
# - OPENAI_API_KEY
# - UPSTASH_VECTOR_REST_URL
# - UPSTASH_VECTOR_REST_TOKEN
# 3. Run development server
npm run dev
# 4. Visit http://localhost:3000wiki-generator/
βββ app/
β βββ api/
β β βββ generate-wiki/ # Wiki generation endpoint
β β βββ search/ # Semantic search endpoint
β β βββ workflow-status/ # Workflow status polling
β βββ generate/ # Wiki generation UI
β βββ search/ # Search UI
β βββ wiki/ # Wiki display pages
β βββ page.tsx # Home page
β
βββ lib/
β βββ agents/ # AI Agent System (4 agents)
β β βββ recon/ # Tech stack analysis
β β βββ features/ # Feature detection
β β βββ architecture/ # Pattern analysis
β β βββ docs-generator/ # Documentation generation
β β βββ shared/ # Agent factory & utilities
β βββ rag/ # RAG Pipeline
β β βββ chunker.ts # Code chunking with tree-sitter
β β βββ embedder.ts # OpenAI embeddings
β β βββ index.ts # RAG orchestration
β β βββ vector-search.ts # Vector similarity search
β βββ github/
β β βββ fetcher.ts # GitHub API client
β βββ vector-storage.ts # Upstash Vector integration
β βββ blob-storage.ts # Vercel Blob wiki storage
β βββ wiki.ts # Wiki loading utilities
β
βββ workflows/
β βββ wikiGeneration/ # Main workflow
β βββ index.ts # Orchestration (parallel execution)
β βββ steps/ # Individual steps
β βββ fetchRepo.ts
β βββ buildIndex.ts # Includes vector storage
β βββ runRecon.ts
β βββ runFeatures.ts
β βββ runArchitecture.ts
β βββ generateDocs.ts
β βββ saveToBlob.ts
β
βββ components/ # UI components (shadcn/ui)
- Next.js 15 (App Router)
- React 19
- TypeScript (strict mode)
- Tailwind CSS + shadcn/ui
- Vercel AI SDK (generateObject)
- OpenAI GPT-5-mini (agents)
- OpenAI text-embedding-3-small (1536 dimensions)
- Upstash Vector (semantic search, ~2KB/chunk)
- Vercel Blob (wiki storage, MDX files)
- Vercel Workflow (orchestration, retries)
- tree-sitter (AST parsing for JS/TS/Python/Go/Rust)
- Knowledge Graph (in-memory graph for code relationships)
- Octokit (GitHub API)
Create a .env.local file:
# Required: OpenAI API
OPENAI_API_KEY=sk-...
# Required: Upstash Vector (for search)
UPSTASH_VECTOR_REST_URL=https://...
UPSTASH_VECTOR_REST_TOKEN=...
# Optional: GitHub API (higher rate limits)
GITHUB_TOKEN=ghp_...
# Auto-added by Vercel (for Blob storage)
BLOB_READ_WRITE_TOKEN=...-
OpenAI API Key: https://platform.openai.com/api-keys
-
Upstash Vector:
- Go to https://console.upstash.com/vector
- Create new index:
- Model: None (we provide embeddings)
- Dimensions: 1536
- Metric: COSINE
- Copy REST URL and token
-
GitHub Token (optional):
- https://github.com/settings/tokens
- Select:
public_reposcope
User enters GitHub URL (e.g., "sindresorhus/is")
β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 1: Fetch Repository β
β β’ Clone file tree via GitHub API β
β β’ Filter out tests, node_modules, build artifacts β
β β’ Fetch up to 300 source files β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββ
β Step 2a: Build RAG Index β Step 2b: Run Recon Agent β
β (PARALLEL) β (PARALLEL) β
ββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββ€
β β’ Parse top 150 chunks β β’ Analyze README β
β β’ Generate embeddings β β’ Detect tech stack β
β β’ Truncate code to 3KB β β’ Identify patterns β
β β’ Save to Upstash Vector β β’ Map directory structure β
ββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββ
β Step 3a: Features Agent β Step 3b: Architecture Agentβ
β (PARALLEL) β (PARALLEL) β
ββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββ€
β β’ Top 50 chunks (3KB max) β β’ Top 30 chunks (3KB max) β
β β’ Detect user features β β’ Identify patterns β
β β’ Rate importance (1-10) β β’ Explain data flow β
ββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 4: Generate Documentation (Important Features) β
β β’ Filter features: importance >= 4 only (focus quality)β
β β’ For each feature: find relevant code chunks β
β β’ Docs Generator creates MDX with examples (3K tokens) β
β β’ Include code citations (file:line) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 5: Save Wiki to Vercel Blob β
β β’ Generate index.mdx (overview) β
β β’ Generate feature pages (feature-name.mdx) β
β β’ Store as public blobs β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β Wiki ready at /wiki/repo-name
β Searchable via semantic search
Duration: ~1.5-2 minutes for typical repo (300 files)
- Parallel Execution: Recon + Index building run concurrently (saves 9s)
- Limited Embeddings: Only top 150 chunks embedded (70% faster, 70% cheaper)
- Chunk Truncation: 3KB max per chunk for agents (prevents context overflow)
- Parallel Agents: Features + Architecture run concurrently (saves 30s)
- Feature Filtering: Only document important features (importance β₯ 4)
- Increased Parallelism:
- GitHub fetching: 50 files/batch (was 20)
- Embeddings: 10 concurrent batches (was 3)
User types: "user authentication"
β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. Generate Query Embedding β
β β’ OpenAI text-embedding-3-small β
β β’ 1536-dimensional vector β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 2. Vector Similarity Search β
β β’ Query Upstash Vector with embedding β
β β’ Cosine similarity ranking β
β β’ Returns top 20 matches β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 3. Display Results β
β β’ Code snippet (500 chars) β
β β’ File path + line numbers β
β β’ Similarity score (% match) β
β β’ "View on GitHub" link β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Response time: < 1 second
- KISS - Simple, direct implementations (no over-engineering)
- DRY - Reuse through utilities and shared patterns
- Type Safety - Strict TypeScript, no
anytypes - User-Focused - Document features, not technical layers
- Quality - All code passes lint + type checks
- β Simple, fast, accurate for semantic queries
- β Handles typos and synonyms ("auth" finds "authentication")
- β No complex fusion algorithms needed
- β Removed BM25 hybrid search (added complexity, minimal benefit)
- β Removed reranking (128K context makes it unnecessary)
- β Speed: Instant vs 60s for AI compression (100x faster)
- β Coverage: 50 chunks Γ 3KB = 150KB (vs 20 chunks Γ 2KB = 40KB compressed)
- β Quality: First 3KB captures function signatures, logic, JSDoc
- β Cost: Free vs API calls for each chunk
- β Compression was too slow (code-summarizer agent took 60s for 20 chunks)
- β Agents need breadth (many examples) > depth (complete implementations)
- π Trade-off: Agents see truncated code, but full code still in Vector for search
- β Upstash Vector has 48KB metadata limit
- β Full code (10KB+) exceeds limit
- β 500-char snippets sufficient for preview
- β "View on GitHub" provides full context
- π Future: Hybrid storage (Vector + Blob) for full code on-demand
- β Focus on implementation code
- β Faster processing (skip 30-40% of files)
- β Better feature detection (tests don't represent features)
- β Reduced API costs
GitHub API: Free (60 req/hour w/o token, 5000/hour with)
Embeddings: 150 chunks Γ $0.00002 = $0.003 (70% reduction!)
Agent calls: ~6 calls Γ $0.15 = $0.90
Total per wiki: ~$0.90
Monthly costs (10 wikis/month):
OpenAI: ~$9/month
Upstash Vector: Free tier (up to 10K vectors)
Vercel Blob: ~$0.15/month (1GB storage)
Total: ~$9.15/month
Performance: 3.5 min β 1.5 min (57% faster)
- No Incremental Updates - Must regenerate entire wiki for changes
- Snippet-Only Search - 500-char limit (full code on GitHub)
- Truncated Code for Agents - Chunks limited to 3KB to fit context windows
- Trade-off: Speed & reliability > complete code visibility
- First 3KB captures signatures, logic, JSDoc (usually sufficient)
- Important Features Only - Only generates docs for importance β₯ 4
- Trade-off: Quality & speed > comprehensive coverage
- No Authentication - All wikis are public
- No Rate Limiting - Can be abused
- No Caching - Same repo re-analyzed costs same amount
- Single Model - No fallback if OpenAI is down
- Incremental updates with Merkle trees (90% cost reduction)
- Full code storage (Blob + Vector hybrid)
- Authentication & user workspaces
- Caching layer (Redis) for embeddings and agents
- Model fallbacks (Anthropic, Gemini)
- Private repo support (user GitHub tokens)
- Smart code completion for truncated chunks
- Current: Hard truncate at 3KB (fast, predictable)
- Future: Intelligent truncation at semantic boundaries (end of function/class)
- Or: Dynamic chunk sizing based on available context budget
# Development
npm run dev # Start dev server (http://localhost:3000)
npm run build # Production build
npm run start # Start production server
# Quality checks (must pass before commit)
npm run lint # ESLint (0 errors allowed)
npx tsc --noEmit # TypeScript checking
# Testing
npm run test:rag # Test RAG pipeline
npm run test:github # Test GitHub fetcher
npm run test:docs # Test docs generation- β All code passes ESLint (0 errors, 0 warnings)
- β All code passes TypeScript type checking
- β
No
anytypes (useunknownor specific types) - β Proper error handling with try/catch
- β Clear, concise comments
Each agent follows strict 4-file structure:
lib/agents/[agent-name]/
βββ schema.ts # Zod validation schema
βββ types.ts # Input/Output TypeScript types
βββ prompt.ts # System + User message builders
βββ index.ts # Agent definition with defineAgent()
Example:
// schema.ts
export const myAgentSchema = z.object({
result: z.string(),
confidence: z.number(),
});
// types.ts
export type MyAgentOutput = z.infer<typeof myAgentSchema>;
export interface MyAgentInput { context: RepoContext; }
// prompt.ts
export const SYSTEM_MESSAGE = `You are an expert...`;
export function buildUserMessage(input: MyAgentInput): string { ... }
// index.ts
export const myAgent = defineAgent({
name: 'my-agent',
schema: myAgentSchema,
systemMessage: SYSTEM_MESSAGE,
buildUserMessage,
});# Install Vercel CLI
npm i -g vercel
# Deploy
vercel
# Set environment variables in dashboard:
# - OPENAI_API_KEY
# - UPSTASH_VECTOR_REST_URL
# - UPSTASH_VECTOR_REST_TOKEN
# - GITHUB_TOKEN (optional)Requires:
- Node.js 20+
- Support for Vercel Workflow (or alternative orchestration)
- Environment variables configured
MIT
Built with β€οΈ using AI-powered development