git-wiki
git-wiki-project
On this page
- AI Code Assistant Architecture
- Chapter 0: Project Foundation
- Chapter 1: Express Server & Job Store
- Chapter 2: Why Inngest Background Jobs?
- Chapter 2: Inngest Event System
- Chapter 3: Fetching & Chunking Code
- Chapter 3: Saving Vectors to Pinecone
- Chapter 3: Indexing Flow & Polling
- Chapter 4: Smart Code Search (RAG)
- Chapter 4: Chat API & Inngest Runner
- Master Build Roadmap
AI Code Assistant Architecture
01
Notes
Let users chat with any GitHub codebase like asking questions on ChatGPT.
Express handles instant API requests so the app never freezes.
Inngest processes heavy file indexing in the background.
Pinecone stores code snippets as vectors for quick semantic search.
Chapter 0: Project Foundation
02
Notes
Initialize modern Node.js using 'type: module' for clean ES imports.
Use 'dotenv' to protect API keys (OpenAI, Pinecone, GitHub) like your UPI PIN.
Add 'nodemon' so the server restarts automatically whenever code changes.
Verify setup by starting the server and checking console output.
Chapter 1: Express Server & Job Store
03
Notes
Set up Express with CORS and JSON body parsers.
Create a /health check route to confirm the server is running.
Use an in-memory jobStore to track task states: queued, running, completed.
Works like a digital token counter at Haldiram's while your order is prepared.
Chapter 2: Why Inngest Background Jobs?
04
Notes
Reading hundreds of code files takes minutes; HTTP requests would time out.
Like ordering on Zepto: you get instant order confirmation instead of waiting at the warehouse.
Express returns '202 Accepted' with a jobId immediately.
Inngest handles the long-running task and retries automatically on errors.
Chapter 2: Inngest Event System
05
Notes
Express emits an event like 'repo/index.requested'.
Inngest Dev Server catches the event and triggers registered step functions.
Each 'step.run()' saves progress — if step 3 fails, steps 1 and 2 won't re-run.
Connects locally via webhook at /api/inngest.
Chapter 3: Fetching & Chunking Code
06
Notes
Octokit scans the GitHub repo tree and downloads up to 200 code files.
Skips junk like node_modules and keeps relevant files (.js, .py, .md).
LangChain splits big files into 1000-character chunks.
150-character overlap prevents code logic from being cut in half mid-function.
Chapter 3: Saving Vectors to Pinecone
07
Notes
Converts code chunks into 1536-dimension embeddings using OpenAI.
Upserts vectors into Pinecone under dedicated repo namespaces.
Namespace isolation ensures 'swiggy/cart' code never mixes with 'zomato/cart'.
Once saved, updates jobStore status to 'completed'.
Chapter 3: Indexing Flow & Polling
08
Notes
POST /api/index triggers the indexing workflow and returns a jobId.
Client polls GET /api/index/:jobId just like checking IRCTC Tatkal PNR status.
Job status transitions from 'queued' to 'running' to 'completed'.
Returns total file count and chunk count upon completion.
Chapter 4: Smart Code Search (RAG)
09
Notes
User asks: 'How does payment checkout work in this repo?'.
Pinecone performs similarity search and fetches top 5 relevant code snippets.
GPT-4o-mini receives only these 5 snippets as context.
LLM provides a concise answer along with exact source file paths.
Chapter 4: Chat API & Inngest Runner
10
Notes
POST /api/chat triggers 'chat/question.requested' in Inngest.
Returns a jobId immediately so the UI stays super responsive.
Client polls GET /api/chat/:jobId to receive the final answer and sources.
Note: The repo must be indexed first, or search context will be empty.
Master Build Roadmap
11
Notes
Step 1: Express setup + /health route check.
Step 2: Connect Inngest dev server & test hello-world event.
Step 3: Build GitHub fetch, chunking, and Pinecone vector indexing.
Step 4: Build RAG chat pipeline with OpenAI and source tracking.