GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - auraCodesKM/brdAgentBackend: Graph-RAG backend that drafts Business Requirements Documents from emails and notes on local models: LightRAG knowledge graph + Redis BM25, RRF fusion and cross-encoder reranking, Qwen 7B/32B routing via Ollama, and per-section WebSocket streaming. FastAPI.

BranchesTags
Open more actions menu

Latest commit

 

History

50 Commits
50 Commits

Folders and files

NameName
Last commit message
Last commit date
.gsd
.gsd
 
 
app
app
 
 
cache
cache
 
 
models
models
 
 
pipeline
pipeline
 
 
screenshots
screenshots
 
 
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
WINDOWS_SETUP.md
WINDOWS_SETUP.md
 
 
audit_brd.md
audit_brd.md
 
 
audit_context.md
audit_context.md
 
 
background_ingest.py
background_ingest.py
 
 
brd_research_prompt_results.md
brd_research_prompt_results.md
 
 
download_models.py
download_models.py
 
 
executive_summary_verification.md
executive_summary_verification.md
 
 
export_context.py
export_context.py
 
 
full_audit_results.md
full_audit_results.md
 
 
generate_full_audit.py
generate_full_audit.py
 
 
generation_results.md
generation_results.md
 
 
main.py
main.py
 
 
raw_ingested_data.md
raw_ingested_data.md
 
 
requirements.txt
requirements.txt
 
 
test_graph.py
test_graph.py
 
 
test_ingest.py
test_ingest.py
 
 
test_websocket.py
test_websocket.py
 
 
timeline_verification.md
timeline_verification.md
 
 
whisper_engine.py
whisper_engine.py
 
 

Repository files navigation

BRD Agent: Backend

Turns scattered emails and meeting notes into a structured, eight-section Business Requirements Document, using graph-based retrieval and local LLMs, streamed section by section to the UI.

frontend: Vercel HackFest: 2.0 · GDG Cloud New Delhi

Python: 3 FastAPI: WebSockets LightRAG: Graph RAG Ollama: Qwen 2.5 7B · 32B BGE: M3 + reranker Redis: BM25

Built in a team at HackFest 2.0 (GDG Cloud New Delhi). This repository is the Python backend; the Next.js frontend is deployed at brd-agent-cmka.vercel.app. All LLM inference, embeddings and reranking run on local models.

The problem

Requirements are scattered across emails, meeting notes and chat threads. Writing a Business Requirements Document (BRD) means finding who asked for what, noticing where two stakeholders contradict each other, and attributing every requirement to a source. Plain "retrieve and summarise" loses who said what.

What it does

  • Graph-based retrieval (Graph RAG). Ingested text becomes a LightRAG knowledge graph of people, systems, decisions and their relationships, extracted by qwen2.5:32b and embedded with BGE-M3 (1024-d). The same chunks are indexed for BM25 keyword search in Redis.
  • Hybrid fusion and reranking. Each query hits the graph and the keyword index in parallel; results are fused with Reciprocal Rank Fusion (k = 60) and reranked by the BGE-reranker-large cross-encoder. The top 5 become the context.
  • Eight-section BRD generation. Executive summary, business objectives, stakeholder analysis, functional and non-functional requirements, assumptions, success metrics and timeline, each with its own prompt, token budget (1,200–2,000) and stop sequences.
  • Model routing by section. Narrative sections run on qwen2.5:7b for speed; table-heavy sections (functional and non-functional requirements, timeline) run on qwen2.5:32b for structure. Up to three sections generate concurrently.
  • Live streaming. Every section streams token by token over its own WebSocket, with progress states (queued → retrieving → writing).
  • Long-context prompting. The core instruction is placed before and after the retrieved context in every prompt, following Lost in the Middle (Liu et al., 2023) and Prompt Repetition Improves Non-Reasoning LLMs (Leviathan et al., 2025).
  • Conflict and traceability analysis. GET /conflicts returns stakeholder conflicts as JSON; GET /traceability returns a requirement → source → owner matrix.
  • Ingestion and editing. Upload files (POST /api/ingest, MinerU parsing for PDFs when installed) or raw emails (POST /ingest/email, sender and subject kept as the source), and rewrite any section from a natural-language request (POST /api/generate/edit).

Screenshots

The Next.js frontend driving this backend: ingestion, live section streaming and the finished document.

Landing page

Landing Page (Light Mode) Landing Page (Dark Mode)

Dashboard

Overview of the workspace, with links to data ingestion and BRD generation.

Dashboard Overview (Light Mode) Dashboard Overview (Dark Mode)

Architecture and components page

Architecture Components

Data ingestion

Uploading unstructured documents into the graph and keyword indexes.

Data Ingestion Hub

Generation flow

The three steps: select sources, run generation, review the document.

Generation Flow (Dark Mode) Generation Flow (Light Mode)

Live generation

Sections stream over parallel WebSockets, with the backend's status lines (Queueing, Retrieving corporate context, Synthesizing) shown before the text arrives.

Generator Interface Overview (Light Mode) Generator Interface Overview (Dark Mode) Real-Time Executive Summary Generation Real-Time Executive Summary Streaming Real-Time Non-Functional Generation

Generated document

Rendered sections: functional specifications, acceptance criteria tables, conflicts.

System Features 1 System Features 2 System Features 3 System Features 4 System Features 5 System Features 6 System Features 7 System Features 8

Presentation diagram

Project Diagrams

Architecture

Dashed boxes are planned extensions (see the roadmap).

graph TD
    subgraph Ingestion["Index time"]
        A["Email / text upload"] -->|"MinerU if installed, else UTF-8 text"| B["Clean text"]
        B -->|"512-word window, 64 overlap"| C["Text chunks"]
        B -->|"LightRAG entity extraction (Qwen 32B)"| D["Knowledge graph nodes/edges"]
        D --> H[("LightRAG graph + BGE-M3 vectors")]
        C --> K[("Redis BM25 index")]
        C -.-> F[("FAISS dense index (planned)")]
    end

    subgraph Generation["Query time"]
        I["Section request via WebSocket / REST"] --> M["Parallel fetch"]
        M -->|"hybrid graph query"| H
        M -->|"keyword"| K
        M -.-> F
        H & K --> N["Reciprocal Rank Fusion"]
        N -->|"BGE-reranker-large"| O["Top 5 chunks"]
        O -->|"instruction before + after context"| R{"Section type"}
        R -->|"narrative"| R7["Ollama: Qwen 2.5 7B"]
        R -->|"tables"| R32["Ollama: Qwen 2.5 32B"]
        R7 & R32 -->|"token stream"| S["Frontend UI"]
    end
Loading

Tech stack

Component Used
API FastAPI, Uvicorn, WebSockets
LLM inference Ollama (OpenAI-compatible API): qwen2.5:32b, qwen2.5:7b
Knowledge graph LightRAG (lightrag-hku)
Embeddings BAAI/BGE-M3 (FlagEmbedding)
Reranking BAAI/bge-reranker-large cross-encoder
Keyword search Redis with RediSearch (local Redis or Upstash, set in .env)
Hardware Developed on a 24 GB RTX 4090 under Windows

Quickstart

Needs Python, a GPU that can serve qwen2.5:32b through Ollama, and Redis with the search module.

git clone https://github.com/auraCodesKM/brdAgentBackend.git
cd brdAgentBackend
python -m venv venv
source venv/bin/activate            # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env                # Redis URL, HF cache, Ollama URL
python download_models.py           # BGE-M3, reranker and other Hugging Face checkpoints

ollama pull qwen2.5:32b
ollama pull qwen2.5:7b

python -m uvicorn main:app --host 0.0.0.0 --port 8000 --workers 1

Then:

curl http://localhost:8000/health
python test_ingest.py               # posts 10 sample emails (the helper scripts target port 8001)
curl http://localhost:8000/conflicts
curl http://localhost:8000/traceability

Windows notes: WINDOWS_SETUP.md.

Sample data and outputs

test_ingest.py posts 10 short demo emails, written with Enron executives' names, that contain deliberate contradictions on deadline, SSO, mobile scope and performance targets. background_ingest.py streams up to 50 keyword-matched emails from a local Enron email export. Outputs from hackathon runs are committed: raw_ingested_data.md (graph context), audit_brd.md and full_audit_results.md (full BRDs), and per-section checks such as timeline_verification.md.

Project structure

main.py                 FastAPI app: ingest, WebSocket/REST generation, edit, conflicts, traceability, health
pipeline/
  ingestion.py          parse → chunk → LightRAG insert → BM25 index
  rag_engine.py         LightRAG setup (Ollama, BGE-M3, reranker)
  retrieval.py          parallel graph + keyword fetch, RRF fusion, cross-encoder rerank
  generator.py          section prompts, 7B/32B routing, streaming, edit
  conflict.py           conflict report (JSON)
  traceability.py       requirement → source matrix (JSON)
models/                 Ollama client, BGE-M3 embedder, BGE reranker
cache/                  Redis BM25 index and semantic cache
test_*.py               scripts that drive a running server (ingest, WebSocket generation, graph inspection)

Design choices and roadmap

  • Local models end to end. LLM inference, embeddings and reranking run on the machine through Ollama and FlagEmbedding, so documents are never sent to a hosted LLM API.
  • Two model sizes, routed by section. The 7B model writes narrative sections fast; the 32B model handles sections whose tables and numbered requirements need stricter structure. A three-slot semaphore caps concurrent generation on a single GPU.
  • Graph plus keyword retrieval. The graph captures who said what and how entities relate; BM25 catches exact terms (dates, figures, system names). RRF fuses them without score calibration.
  • Roadmap: planned retrieval extensions with hooks already in the pipeline: CRAG query reformulation, HyDE, RAPTOR summary trees, a semantic answer cache and a dense FAISS index. Also Whisper transcription for meeting recordings and per-requirement checks against the cited source chunk.

About

Graph-RAG backend that drafts Business Requirements Documents from emails and notes on local models: LightRAG knowledge graph + Redis BM25, RRF fusion and cross-encoder reranking, Qwen 7B/32B routing via Ollama, and per-section WebSocket streaming. FastAPI.

brd-agent-cmka.vercel.app

Topics

fastapigraph-ragknowledge-graphlightragllmollamaqwenragrerankingwebsockets

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.