How bhargavi1045/repolens works
Purpose and Entry Points
RepoLens is a full-stack GitHub repository analysis product. Users authenticate, submit repositories, and request RAG-grounded explanations, architecture/workflow outputs, test suggestions, improvements, and static health analysis. Backend startup is backend/server.ts, which composes Express from backend/src/app.ts; the frontend is a Next.js application rooted at frontend/app/layout.tsx and frontend/app/page.tsx.
Client Application
The Next.js frontend provides landing/authentication and an authenticated analysis workspace. The dashboard combines repository navigation, source viewing, and AI output panels, calling the backend through a centralized client API layer.
• frontend/app/dashboard/page.tsx
• frontend/components/dashboard/FileTree.tsx
• frontend/components/dashboard/AiPanel.tsx
• frontend/lib/api.ts
HTTP API and Request Boundary
Express routes separate authentication, repository lifecycle, and analysis features. Controllers implement request orchestration; middleware applies JWT protection, ingestion preconditions, validation, rate limiting, and centralized error handling. This is the primary boundary between browser state and backend processing.
• backend/src/api/routes/index.ts
• backend/src/api/controllers/repo.controller.ts
• backend/src/api/controllers/analysis.controller.ts
• backend/src/api/middleware/auth.middleware.ts
• backend/src/api/middleware/ensureIngested.ts
Repository Ingestion Pipeline
Repository ingestion fetches GitHub content, parses files, splits source into retrievable chunks, creates embeddings, and persists indexing state. AST-aware chunking is an architectural differentiator: it preserves function/class boundaries versus fixed-size chunks. Ingestion bridges GitHub’s external API and Pinecone’s vector index.
• backend/src/services/ingest.service.ts
• backend/src/services/github.service.ts
• backend/src/services/astChunking.service.ts
• backend/src/services/embedding.service.ts
• backend/src/services/pinecone.service.ts
RAG and LLM Analysis Engine
Feature requests retrieve semantically similar indexed chunks, build feature-specific prompts, then ask Groq-backed LLM services for structured results. Supported outputs include file explanation, architecture diagrams, workflows, unit tests, and improvement recommendations. Mermaid output is extracted/sanitized before reaching the UI.
• backend/src/services/rag.service.ts
• backend/src/services/askRepo.service.ts
• backend/src/services/llm.service.ts
• backend/src/prompts/architecture.prompt.ts
• backend/src/utils/extractMermaidDiagram.ts
Persistence, Identity, and Caching
MongoDB stores users, repositories, chunks/metadata, analyses, evaluations, and cached results. JWT issuance and verification support protected backend endpoints; the frontend has route handlers for cookie management and middleware for access control. Cache persistence reduces repeated AI/retrieval work.
• backend/src/config/db.ts
• backend/src/models/User.model.ts
• backend/src/models/Repo.model.ts
• backend/src/models/Cache.model.ts
• backend/src/utils/jwt.ts
Static Analysis and Evaluation
A second insight path runs ESLint-based quality analysis and converts findings into health-oriented results. The evaluation subsystem benchmarks retrieval/chunking and LLM faithfulness, enabling comparison between fixed and AST chunking strategies independently of interactive UI requests.
• backend/src/services/analysis.service.ts
• backend/src/services/eslint.service.ts
• backend/src/services/evaluation.service.ts
• backend/src/services/evaluationRunner.service.ts
• backend/src/eval/testDataset.ts
Runtime and External Infrastructure
The system runs a Node.js/Express TypeScript backend and Next.js/Tailwind TypeScript frontend. Material managed dependencies are GitHub for repository source, Cohere for embeddings, Pinecone for vector similarity search, Groq for generation, MongoDB Atlas for operational data, and email delivery through backend/src/services/email.service.ts. Deployment targets are Vercel (frontend) and Render (backend).
Main entry points: page.tsx Analysis dashboard · analysis.controller.ts Analysis controller · auth.middleware.ts Request guards · repo.controller.ts Repository controller
Components 21
Client application
- Next.js app · Landing, authentication, and protected workspace.
frontend/app/layout.tsx - Analysis dashboard · Combines repository navigation, source viewing, and AI outputs.
frontend/app/dashboard/page.tsx - Repository navigator
frontend/components/dashboard/FileTree.tsx - AI output panel
frontend/components/dashboard/AiPanel.tsx - Backend API client
frontend/lib/api.ts
Backend API
- Express application · Composed by the server entry point.
backend/src/app.ts - API routes · Separates authentication, repository, and analysis endpoints.
backend/src/api/routes/index.ts - Request guards · JWT protection and ingestion preconditions.
backend/src/api/middleware/auth.middleware.ts - Repository controller
backend/src/api/controllers/repo.controller.ts - Analysis controller
backend/src/api/controllers/analysis.controller.ts
Ingestion and AI
- Repository ingestion · Fetches, chunks, embeds, and indexes repository content.
backend/src/services/ingest.service.ts - AST-aware chunking · Preserves function and class boundaries.
backend/src/services/astChunking.service.ts - Embedding service · Uses Cohere embeddings.
backend/src/services/embedding.service.ts - RAG retrieval · Retrieves indexed chunks and builds grounded context.
backend/src/services/rag.service.ts - LLM analysis engine · Produces explanations, diagrams, workflows, tests, and recommendations.
backend/src/services/llm.service.ts - Static health analysis · Runs ESLint-based repository health analysis.
backend/src/services/analysis.service.ts - Evaluation runner · Compares chunking, retrieval, and LLM faithfulness.
backend/src/services/evaluationRunner.service.ts
Data and external services
- GitHub source API
backend/src/services/github.service.ts - Pinecone vector index
backend/src/services/pinecone.service.ts - MongoDB Atlas · Stores users, repositories, analyses, evaluations, and caches.
backend/src/config/db.ts - Groq
Connections 23
- Next.js app → Analysis dashboard: renders
- Analysis dashboard → Repository navigator: shows
- Analysis dashboard → AI output panel: shows
- Analysis dashboard → Backend API client: requests
- Backend API client → Express application: HTTP
- Express application → API routes: mounts
- API routes → Request guards: applies
- Request guards → Repository controller: authorizes
- Request guards → Analysis controller: authorizes
- Repository controller → Repository ingestion: ingests repository
- Analysis controller → RAG retrieval: requests grounded analysis
- Analysis controller → Static health analysis: requests health analysis
- Repository ingestion → GitHub source API: fetches files
- Repository ingestion → AST-aware chunking: chunks source
- AST-aware chunking → Embedding service: chunks
- Embedding service → Pinecone vector index: indexes vectors
- RAG retrieval → Pinecone vector index: retrieves similar chunks
- RAG retrieval → LLM analysis engine: supplies context
- LLM analysis engine → Groq: generates via
- Repository controller → MongoDB Atlas: persists repository state
- Analysis controller → MongoDB Atlas: reads and caches results
- Evaluation runner → AST-aware chunking: compares against fixed chunking
- Evaluation runner → LLM analysis engine: measures faithfulness