This is a submission for the Gemma 4 Challenge: Build with Gemma 4
What I Built
GemmaLens — an AI-powered repository understanding and architectural memory engine that lets you drop in any GitHub URL and walk away actually understanding the codebase.
Most developers know the pain: you inherit a repo, join a new team, or revisit old code — and you're stuck archaeologically digging through folders, grepping for entry points, manually tracing imports. GemmaLens eliminates that cold-start problem entirely.
Here's what happens when you paste a GitHub URL:
- Real cloning — the backend clones the repo via GitPython (no scraping, no fake data)
-
Deep scanning — detects languages (20+), frameworks, package managers, and parses actual dependencies from
package.json,requirements.txt,Cargo.toml,pom.xml, andcomposer.json - Architecture graph — traces Python and JS/TS imports across the codebase, builds a NetworkX directed graph, and renders it live with React Flow
- Gemma AI summary — the full context (file tree, imports, key file contents, dependency list) is passed to Gemma 4, which produces a grounded, non-hallucinated architectural summary
- GemmaChat — ask anything: "explain the authentication flow", "what services depend on the database?", "where is the API defined?" — all answers are grounded in the real scanned context
- Documentation generation — one click produces full markdown docs from the actual analysis
- LensContext export — a structured JSON file you can paste into Claude, Cursor, ChatGPT, or any AI tool to give it instant repo awareness
Tech stack:
- Frontend: Next.js + Tailwind CSS + React Flow (@xyflow/react) + react-markdown
- Backend: FastAPI + GitPython + NetworkX + httpx
- AI: Gemma 4 31B Dense via OpenRouter
Demo
🚧 Deployment in progress — video walkthrough coming shortly.
Example flow on a real repo (https://github.com/fastapi/fastapi):
- Overview tab: Gemma's summary correctly identifies the ASGI framework, Starlette dependency, Pydantic integration, and test structure — all from scanned files
-
Architecture Graph: nodes for
fastapi/,tests/,docs_src/with real import edges between modules - GemmaChat: asking "how does dependency injection work here?" returns an accurate answer citing actual files
- Export: a JSON blob ready to paste into any AI assistant for instant context
📁 GitHub Repository: github.com/HarshaBM-25/gemmalens
Code
Full source on GitHub: https://github.com/HarshaBM-25/gemmalens
Project structure:
gemmalens/
├── backend/
│ ├── app/
│ │ ├── main.py # FastAPI app + CORS
│ │ ├── models/ # Pydantic request models
│ │ ├── routes/
│ │ │ ├── analyze.py # Clone + scan endpoint
│ │ │ ├── chat.py # GemmaChat endpoint
│ │ │ ├── docs.py # Documentation generation
│ │ │ └── export.py # LensContext JSON export
│ │ └── services/
│ │ ├── analyzer.py # GitPython, file scanning, NetworkX graph
│ │ └── gemma.py # OpenRouter / Gemma 4 integration
│ └── requirements.txt
└── frontend/
├── app/
│ ├── page.tsx # Homepage with repo input
│ └── analyze/[repoId]/
│ └── page.tsx # 5-tab analysis dashboard
└── components/
└── GraphView.tsx # React Flow architecture graph
To run locally:
# Backend
cd backend
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
export OPENROUTER_API_KEY=your_key_here
uvicorn app.main:app --reload --port 8000
# Frontend
cd frontend
npm install
npm run dev
# Open http://localhost:3000
How I Used Gemma 4
I chose Gemma 4 31B Dense via OpenRouter, and the reasoning was specific — not arbitrary.
Why 31B Dense over E2B or E4B?
The core challenge in repository understanding isn't code generation — it's coherent reasoning across a large, heterogeneous context. A single repository analysis call sends Gemma:
- The full file tree (up to 200 files)
- Detected languages, frameworks, and all dependencies
- Module-to-module import relationships
- Key file contents (README, entrypoints, config files) — up to ~20,000 tokens of real code
Smaller models struggle to maintain coherence when the context mixes directory trees, JSON dependency lists, Python imports, and raw source code simultaneously. The 31B Dense architecture handles this without losing the thread — it correctly identifies which file is the entrypoint, how modules relate, and what design patterns are in use.
The E2B and E4B MoE variants, while efficient, trade depth for speed in ways that matter here. When a user asks "explain how authentication is implemented", the answer needs to correctly synthesize information from potentially 5–8 different files. That requires the full model capacity of 31B Dense.
Where Gemma 4 runs in GemmaLens
Gemma 4 powers four distinct features, each with a purpose-built system prompt:
1. Repository Summarization
After the backend scans the repo, Gemma receives the full context and produces a structured architectural summary — identifying purpose, key design decisions, module relationships, and entry points. The system prompt explicitly instructs it to ground every claim in the provided data and flag anything it cannot verify.
2. GemmaChat Q&A
Every chat message is sent with the full repository context prepended. Gemma answers questions like "where is the database connection configured?" by reasoning over the real file tree and import map — not hallucinating. The system prompt holds it accountable: "if it's not in the data, say so."
3. Documentation Generation
Gemma generates a full markdown README — Overview, Architecture, Directory Structure, Dependencies, Getting Started, Key Modules — from the real scanned data. No template filling; actual synthesis.
4. Architecture Explanation
When users ask about specific modules in GemmaChat, Gemma explains the module's role, its dependents, and its dependencies using the real NetworkX graph data passed as context.
The key design decision
I deliberately did not pre-summarize or compress the context before sending it to Gemma. The raw file tree, raw dependency list, raw import relationships — all of it goes in. This is where Gemma 4 31B Dense earns its place: it handles the noise, finds the signal, and produces answers that are genuinely useful rather than generically plausible.
The result is an AI that actually knows the repository — not one that performs knowing it.
Built for the Gemma 4 Challenge. No mock data, no fake dashboards, no hardcoded outputs — everything you see comes from real repository analysis.
Top comments (0)