AI-powered CRM JavaScript code review assistant using LLMs and RAG.
Automatically detects CRM-specific antipatterns in JavaScript customizations by retrieving relevant documentation and generating reviews, replacing manual expert reviews.
INDEXING (offline, once)
========================
knowledge_base/*.md → DirectoryLoader → RecursiveCharacterTextSplitter
│
▼
HuggingFaceEmbeddings
(all-MiniLM-L6-v2)
│
▼
ChromaDB
QUERY (online, per review)
===========================
Developer submits code ──→ Embed ──→ similarity_search (ChromaDB)
│
│ top-K relevant antipattern chunks
▼
ChatPromptTemplate
(system + context + code)
│
▼
ChatGroq (LLaMA 3.1, temp=0)
│
▼
Code review output
| Component | Tool | Role |
|---|---|---|
| Framework | LangChain | Wires the pipeline — loaders, splitters, prompts, LLM |
| Embedding Model | HuggingFace all-MiniLM-L6-v2 | Converts text → vectors (runs locally) |
| Vector Store | ChromaDB | Stores and searches document vectors |
| Chat Model | Groq (LLaMA 3.1 8B) | Generates code reviews |
| Knowledge Base | Markdown files | CRM antipattern documentation |
- Document Loaders — Load antipattern documentation from markdown files using LangChain's
DirectoryLoader - Text Splitters — Chunk documents into ~500 char pieces with overlap using
RecursiveCharacterTextSplitter, so each chunk is small enough for precise retrieval - Embeddings — Each chunk is converted into a 384-dimensional vector using a local HuggingFace model. Semantically similar text produces similar vectors
- Vector Store — Chunks and vectors are stored in ChromaDB. At query time, the developer's code is embedded and the closest document chunks are retrieved via similarity search
- Prompt Template — Retrieved chunks are injected into a structured prompt alongside the code. The system prompt constrains the LLM to only flag issues found in the provided documentation
- LLM — Groq serves LLaMA 3.1 at temperature=0 for deterministic, consistent reviews
uv pip install -r requirements.txtCreate .env:
GROQ_API_KEY=gsk_your_key_here
Run:
python3 main.pyInput (bad code):
var el = document.getElementById('account-name');
el.style.display = 'none';Output:
Antipattern: Direct DOM Manipulation
Line:
document.getElementById('account-name')CRM UI may re-render at any time, breaking direct DOM references. Bypasses the CRM SDK event system. Use
formContext.getControl('account-name').setVisible(false)instead.
Input (clean code):
function hideField(executionContext) {
var formContext = executionContext.getFormContext();
formContext.getControl('account-name').setVisible(false);
}Output:
No antipatterns detected.