Back to Projects

Applied AI & Developer Tools2026

Casestudy 01

Monocle

AI-Powered GitHub Intelligence & Codebase RAG

Next.js 16TypeScriptpgvectorBullMQGemini 2.5 FlashtRPC

The Vision & Architecture

Semantically index repositories & chat with codebases with zero-waste streaming RAG.

Monocle transforms GitHub repositories into conversational, live-indexed knowledge engines. Powered by a custom zero-waste RAG pipeline, Neon Serverless Postgres with pgvector, and Google Gemini 2.5 Flash, developers can query complex multi-file architectures with sub-second streamed answers, exact line numbers, and verified file citations.

768-dimVector Embeddings
<800msTime-To-First-Token
0 QuotaIngest Gen Burn
100%Type-Safe RPC Boundaries

Core Capabilities

  • Zero-Waste RAG Pipeline

    Extracts AST and code chunks, directly embedding them with gemini-embedding-001 (768-dim vectors) into Neon pgvector, consuming zero text-generation quota during repository indexing.

  • Sub-Second Streaming Code Chat

    Delivers rapid Time-To-First-Token via @ai-sdk/google and Vercel AI SDK, injecting global repository file tree maps alongside vector matches for full architectural context.

  • Decoupled Background Ingestion

    BullMQ job dispatcher over Upstash Redis deduplicates concurrent indexing requests using deterministic job IDs (repo-index-${projectId}) with exponential backoff.

  • Automated Commit Diff Tracking

    Polls real-time commit diffs via Octokit REST with semantic heuristic fallbacks and dynamic contextual questions tailored uniquely to the codebase.

  • Live Idempotent Credit System

    Stripe webhook-verified credit allocations with real-time balance synchronization across topbar, sidebar, and dashboard metric grids via tRPC cache invalidation.

Technology Stack

Next.js 16 App RouterTurbopack & UI Shell
Neon Serverless Postgrespgvector Hybrid Search
Google Gemini 2.5 FlashStreaming Inference
BullMQ + Upstash RedisAsync Queue Dispatcher
tRPC v11End-to-End Type Safety
Clerk & StripeAuth & Credit Billing

Architectural Decisions

  • Direct AST embedding over LLM-based chunk summarization

    Embedding raw AST chunks directly saves API generation quota and eliminates summarization hallucinations during repository ingestion.

  • BullMQ queue decoupling over synchronous API handlers

    Large repository ingestion spans minutes; decoupling work to asynchronous background queues avoids serverless gateway timeouts.