How qnity001/github-query works
High-Level Architectural Overview
• Two main logical blocks:
a. Frontend (app.py)
b. Backend (main.py + src/ modules)
Main Components and Data Flow
1) Frontend Block (app.py)
• Input Module
• Responsibility: read user input (e.g., repo path), validate it, and hand off to the backend.
• Maps to: return_path.py
• Output Renderer
2) Backend Block (main.py orchestrator)
• Tree Generator
• Modules: src/tree/create_tree_json.py, src/tree/repo_tree.py
• Responsibility: traverse the file system under the repo path, build a JSON representation of the project structure.
• Code Parser & Formatter
• Module: src/tree/display_tree.py (optional view), src/tree/create_mermaid.py
• Chunking Pipeline
• Controller: src/chunking/controller.py
• Processor: src/chunking/processor.py
• Queries: src/chunking/queries/python_queries.py
• Responsibility: walk each source file, extract logical “chunks” (functions, classes, blocks).
• Embedding Service
• Module: src/embedding/embedding.py
• Responsibility: embed each code chunk into vector representations (via a configured embedding model).
• Retrieval Engine
• Modules: src/retrieving/retriever.py, src/retrieving/llm_classifier.py, src/retrieving/intents.joblib
• Responsibility: given a user query, classify intent, find relevant chunk embeddings, rank them.
• LLM Query Module
• Module: src/llm_query/chatbot.py
• Responsibility: formulate prompts combining retrieved chunks and user questions, send to LLM, receive response.
• Module: src/tree/create_mermaid.py
Relationships and Interactions (Data Flow Steps)
1) User invokes app.py
→ Input Module (return_path.py) obtains repo path.
2) app.py calls main.py with the path
→ main.py triggers Tree Generator → produces a JSON tree.
4) main.py invokes Chunking Controller
→ reads each file via python_queries → yields code chunks.
5) Each chunk is passed to Embedding Service → vector store.
6) Retrieval Engine consumes the vector store + user query → returns top‐N relevant chunks.
7) LLM Query Module crafts a prompt from retrieved chunks & user query → sends to LLM → gets answer.
Architectural Patterns and Principles
• Modular Pipeline: each step (tree generation, chunking, embedding, retrieval, querying, rendering) is a distinct module.
• Single Responsibility: controllers/orchestrators call specific services (processor, embedding, retriever, chatbot).
• Dependency Injection (via config.py): centralize model/API keys and parameters.
• Separation of Concerns: I/O (frontend), business logic (backend orchestrator), and specialized services (chunking, embedding).