An intelligent platform for analyzing SRS documents and automatically extracting features and generating test cases using AI
Features β’ Tech Stack β’ Architecture β’ AI & RAG β’ Installation β’ Usage β’ Documentation
- Overview
- Features
- Tech Stack
- Architecture
- How RAG System Works
- Installation
- Usage
- Documentation
- Performance Metrics
- Security
- Testing
- Contributing
- License
QBrain is an intelligent platform that leverages RAG (Retrieval Augmented Generation) and AI technologies to analyze SRS (Software Requirements Specification) documents and automatically extract features and generate test cases.
- Manual SRS analysis is time-consuming and error-prone
- Feature extraction from SRS documents is complex and expensive
- Manual test case creation is slow and inconsistent
- Tracking coverage and maintaining consistency is challenging
- β Automated SRS analysis using AI
- β Automatic feature extraction with intelligent classification
- β AI-powered test case generation based on features
- β Comprehensive coverage analysis and section tracking
- β Smart chatbot for answering SRS-related questions
- β Automatic Feature Extraction from SRS using GPT-4o-mini
- β Comprehensive RAG System with 8 parallel queries for complete coverage
- β Intelligent Test Case Generation based on feature types (FUNCTIONAL, DATA, REPORT, etc.)
- β Section Coverage Analysis to ensure completeness
- β Smart Chatbot for answering SRS-related questions with context-aware responses
- β Automatic Gherkin Conversion with AI or rule-based fallback
- β Section Matching for feature-to-SRS section correlation
- β Multi-Project Support with isolated workspaces
- β Feature Tracking with metadata, scores, and reasoning
- β Test Case Management with Gherkin conversion
- β Bug Tracking and issue management
- β Performance Metrics and analytics
- β Section Coverage Visualization
- β Semantic Search using OpenAI embeddings (text-embedding-3-small)
- β Multi-Query Retrieval (8 specialized queries covering all feature types)
- β Section-Based Organization of context chunks
- β Adaptive Prompting based on feature types and high-recall mode
- β Vector Storage in Supabase with pgvector for fast similarity search
- β React 18 with TypeScript for type safety
- β Tailwind CSS + shadcn/ui components for beautiful UI
- β Fully Responsive design for all devices
- β Dark Mode support
- β Real-time Updates with TanStack Query
- β Modern Animations with Framer Motion
- β PDF & TXT Support for SRS documents
- β Google Document AI integration for high-quality extraction with OCR support
- β Intelligent Chunking (2000 chars with 300 overlap) for context preservation
- β Batch Embedding Generation for cost efficiency
- β Automatic PDF Splitting for large documents (>15 pages)
| Technology | Purpose | Version |
|---|---|---|
| Node.js | Runtime environment | >= 18.0.0 |
| Express.js | Web framework | 5.1.0 |
| MongoDB | Primary database (Projects, Features, Test Cases, Bugs) | 8.20.1 |
| Mongoose | ODM for MongoDB | 8.20.1 |
| JWT | Authentication & authorization | 9.0.2 |
| bcryptjs | Password hashing | 3.0.3 |
| Multer | File upload handling | 2.0.2 |
| Brevo/Nodemailer | Email service | 3.0.1 / 7.0.10 |
| Technology | Purpose |
|---|---|
| LangChain | LLM framework & chain orchestration |
| OpenAI API | GPT-4o-mini (analysis), text-embedding-3-small (embeddings) |
| Supabase | Vector database (PostgreSQL + pgvector extension) |
| RAG Pattern | Retrieval Augmented Generation for context-aware responses |
| Technology | Purpose |
|---|---|
| React 18 | UI library |
| TypeScript | Type safety |
| Vite | Build tool & dev server |
| Tailwind CSS | Utility-first CSS framework |
| shadcn/ui | High-quality UI components |
| React Router | Client-side routing |
| TanStack Query | Data fetching & caching |
| React Hook Form | Form state management |
| Zod | Schema validation |
| Technology | Purpose |
|---|---|
| Google Document AI | Advanced PDF text extraction with OCR |
| pdf-parse | PDF parsing fallback |
| pdf-lib | PDF manipulation for splitting |
| RecursiveCharacterTextSplitter | Intelligent text chunking |
QBrain/
βββ backend/ # Backend Server (Node.js/Express)
β βββ ai/ # AI & RAG Services
β β βββ chatbot/ # Chatbot functionality
β β β βββ index.js # Main chatbot export
β β β βββ prompts.js # Chatbot prompts
β β β βββ query.js # Chatbot query handler
β β β βββ utils.js # Chatbot utilities
β β βββ config/ # Configuration
β β β βββ llmClient.js # LLM client factory
β β β βββ models.config.js # Model configurations
β β β βββ constants.js # 8 comprehensive SRS queries
β β βββ ingestion/ # Document processing
β β β βββ documentParser.js # PDF/TXT parsing
β β β βββ embeddings.js # Embedding generation (OpenAI)
β β βββ retrieval/ # Context retrieval
β β β βββ retrievalCore.js # RAG context retrieval
β β β βββ retrievalStrategies.js # Retrieval strategies
β β β βββ sectionsCore.js # Section grouping & analysis
β β βββ reasoning/ # AI reasoning & analysis
β β β βββ featureExtraction.js # Feature extraction logic
β β β βββ testCaseGeneration.js # Test case generation
β β β βββ gherkinConversion.js # Gherkin format conversion
β β β βββ sectionMatching.js # Section matching logic
β β β βββ jsonUtils.js # JSON parsing utilities
β β β βββ prompts/ # Prompt templates
β β β βββ index.js # Prompt exports
β β βββ rag/ # Unified entry point
β β βββ index.js # Export all functions
β β βββ query.js # RAG query handler (Chatbot)
β βββ config/ # Configuration files
β β βββ database.js # MongoDB connection
β β βββ nodemailer.config.js # Email service configuration
β βββ controllers/ # Route controllers
β β βββ admin.controller.js # Admin operations
β β βββ aiController.js # AI feature extraction & test generation
β β βββ auth.controller.js # Authentication (login, signup, reset)
β β βββ bugsController.js # Bug CRUD operations
β β βββ chatbotController.js # Chatbot endpoints
β β βββ featuresController.js # Feature CRUD operations
β β βββ projectsController.js # Project CRUD operations
β β βββ testCasesController.js # Test case CRUD operations
β βββ models/ # MongoDB schemas
β β βββ ApiRequestMetric.js # API usage metrics
β β βββ Bug.js # Bug model
β β βββ DailyActiveUser.js # Daily active users tracking
β β βββ Feature.js # Feature model
β β βββ PerformanceMetric.js # Performance metrics
β β βββ Project.js # Project model
β β βββ TestCase.js # Test case model
β β βββ User.js # User model
β βββ routes/ # API route definitions
β β βββ admin.routes.js # Admin routes
β β βββ ai.routes.js # AI routes (feature extraction, test generation)
β β βββ auth.routes.js # Authentication routes
β β βββ bugs.routes.js # Bug routes
β β βββ chatbot.routes.js # Chatbot routes
β β βββ features.routes.js # Feature routes
β β βββ projects.routes.js # Project routes
β β βββ testCases.routes.js # Test case routes
β βββ services/ # Business logic layer
β β βββ bugService.js # Bug business logic
β β βββ documentProcessingValidator.js # Document validation
β β βββ featureService.js # Feature business logic
β β βββ performanceMetricsService.js # Performance tracking
β β βββ projectService.js # Project business logic
β β βββ testCaseService.js # Test case business logic
β βββ middleware/ # Express middleware
β β βββ auth.middleware.js # JWT authentication
β β βββ errorHandler.middleware.js # Error handling
β β βββ usageMetrics.middleware.js # Usage tracking
β βββ utils/ # Helper utilities
β β βββ AppError.js # Custom error class
β β βββ emailService.js # Email sending utilities
β β βββ emailTemplates.js # Email templates
β β βββ textProcessing.js # Text processing helpers
β βββ vector/ # Vector store integration
β β βββ vectorStore.js # Supabase vector store wrapper
β βββ test/ # Test files
β β βββ data/ # Test data
β β βββ unit/ # Unit tests
β β βββ fixtures/ # Test fixtures
β β β βββ chunks.js
β β β βββ factories.js
β β β βββ index.js
β β β βββ llm.js
β β β βββ testCase.js
β β βββ helpers/ # Test helpers
β β β βββ console.js
β β βββ reasoning/ # Reasoning tests
β β β βββ featureExtraction.test.js
β β β βββ gherkinConversion.test.js
β β β βββ testCaseGeneration.test.js
β β βββ retrieval/ # Retrieval tests
β β β βββ retrievalCore.test.js
β β β βββ sectionsCore.test.js
β β βββ utils/ # Utils tests
β β βββ jsonUtils.test.js
β β βββ textProcessing.test.js
β βββ scripts/ # Utility scripts
β β βββ promote-admin.js # Admin promotion script
β βββ uploads/ # Uploaded files directory
β βββ logs/ # Application logs
β βββ server.js # Express server entry point
β βββ package.json # Backend dependencies
β βββ jest.config.mjs # Jest configuration
β
βββ frontend/ # React Frontend
β βββ src/
β β βββ components/ # Reusable UI components
β β β βββ ui/ # shadcn/ui components
β β β β βββ accordion.tsx
β β β β βββ alert-dialog.tsx
β β β β βββ alert.tsx
β β β β βββ avatar.tsx
β β β β βββ badge.tsx
β β β β βββ button.tsx
β β β β βββ card.tsx
β β β β βββ checkbox.tsx
β β β β βββ collapsible.tsx
β β β β βββ dialog.tsx
β β β β βββ dropdown-menu.tsx
β β β β βββ form.tsx
β β β β βββ input.tsx
β β β β βββ label.tsx
β β β β βββ loading-button.tsx # Custom loading button
β β β β βββ loading-spinner.tsx # Custom loading spinner
β β β β βββ page-loading.tsx # Page loading component
β β β β βββ progress.tsx
β β β β βββ scroll-area.tsx
β β β β βββ select.tsx
β β β β βββ separator.tsx
β β β β βββ skeleton.tsx
β β β β βββ table.tsx
β β β β βββ tabs.tsx
β β β β βββ textarea.tsx
β β β β βββ ... (more shadcn/ui components)
β β β βββ custom/ # Custom components
β β β β βββ DotGrid.tsx # Background grid component
β β β β βββ Orb.tsx # Orb animation component
β β β βββ ProjectChatBot/ # Chatbot component
β β β β βββ components/
β β β β β βββ ChatButton.tsx
β β β β β βββ ChatHeader.tsx
β β β β β βββ ChatInput.tsx
β β β β β βββ ChatWindow.tsx
β β β β β βββ MessageList.tsx
β β β β βββ hooks/
β β β β β βββ useChatApi.ts
β β β β β βββ useChatMessages.ts
β β β β βββ constants.ts
β β β β βββ index.tsx
β β β β βββ types.ts
β β β βββ shared/ # Shared components
β β β β βββ PrefetchLink.tsx
β β β β βββ SuspenseFallback.tsx
β β β βββ AdminRoute.tsx # Admin route protection
β β β βββ AppSidebar.tsx # Main sidebar navigation
β β β βββ ErrorBoundary.tsx # Error boundary component
β β β βββ ErrorBoundaryNavigation.tsx
β β β βββ Logo.tsx # Application logo
β β β βββ icons/ # Icon components
β β βββ pages/ # Page components
β β β βββ admin-dashboard/ # Admin dashboard
β β β β βββ components/
β β β β β βββ AdminHeader.tsx
β β β β β βββ DeleteUserDialog.tsx
β β β β β βββ LoadingState.tsx
β β β β β βββ OverviewTab.tsx
β β β β β βββ StatsCards.tsx
β β β β β βββ SystemHealthTab.tsx
β β β β β βββ UserFilters.tsx
β β β β β βββ UserManagementTab.tsx
β β β β β βββ UserTable.tsx
β β β β βββ hooks/
β β β β βββ useAdminData.ts
β β β β βββ useUserActions.ts
β β β β βββ useUserFilters.ts
β β β β βββ useUserSelection.ts
β β β βββ AdminDashboard.tsx # Admin dashboard page
β β β βββ auth/ # Authentication pages
β β β β βββ AuthLayout.tsx # Auth layout wrapper
β β β β βββ ForgotPassword.tsx # Password reset request
β β β β βββ Login.tsx # Login page
β β β β βββ ResetPassword.tsx # Password reset
β β β β βββ Signup.tsx # Registration page
β β β βββ AuthPage.tsx # Auth page wrapper
β β β βββ bug-details/ # Bug details page
β β β β βββ components/
β β β β β βββ BugAttachments.tsx # Bug file attachments
β β β β β βββ BugBadges.tsx
β β β β β βββ BugBasicInfo.tsx
β β β β β βββ BugDeleteDialog.tsx
β β β β β βββ BugEnvironment.tsx
β β β β β βββ BugExpectedActual.tsx
β β β β β βββ BugHeader.tsx
β β β β β βββ BugLabels.tsx
β β β β β βββ BugPeople.tsx
β β β β β βββ BugResolution.tsx
β β β β β βββ BugStepsToReproduce.tsx
β β β β β βββ BugTimeline.tsx
β β β β β βββ ErrorState.tsx
β β β β β βββ LoadingState.tsx
β β βββ BugDetails.tsx # Bug details page
β β β βββ ChatPage.tsx # Chat page
β β β βββ dashboard/ # Dashboard components
β β β β βββ CreateProjectDialog.tsx
β β β β βββ EmptyState.tsx
β β β β βββ ProjectCard.tsx
β β β βββ Dashboard.tsx # Main dashboard page
β β β βββ feature-details/ # Feature details page
β β β β βββ components/
β β β β β βββ FeatureAcceptanceCriteria.tsx
β β β β β βββ FeatureHeader.tsx
β β β β β βββ FeatureHeaderBack.tsx
β β β β β βββ FeatureInfoCard.tsx
β β β β β βββ FeaturePrioritySelector.tsx
β β β β β βββ FeatureTabs.tsx
β β β β β βββ FeatureTechnicalDetails.tsx
β β β β β βββ LoadingState.tsx
β β β β β βββ TestCasesContent.tsx
β β β β β βββ TestCasesToolbar.tsx
β β β β βββ hooks/
β β β β β βββ useFeatureBugs.ts
β β β β β βββ useFeatureData.ts
β β β β β βββ useFeatureDetailsState.ts
β β β β β βββ useTestCaseFilters.ts
β β β β βββ AITestCaseGenerationDialog.tsx
β β β β βββ BugsTab.tsx
β β β β βββ CreateTestCaseDialog.tsx
β β β β βββ EditTestCaseDialog.tsx
β β β β βββ StatsGrid.tsx
β β β β βββ TestCaseCard.tsx
β β β βββ FeatureDetails.tsx # Feature details page
β β β βββ Index.tsx # Landing page
β β β βββ NotFound.tsx # 404 page
β β β βββ profile/ # Profile page components
β β β β βββ AccountInfoCard.tsx
β β β β βββ PersonalInfoTab.tsx
β β β β βββ UserAvatarCard.tsx
β β β βββ Profile.tsx # User profile page
β β β βββ project-details/ # Project details page
β β β β βββ components/
β β β β β βββ FeaturesContent.tsx
β β β β β βββ FeaturesToolbar.tsx
β β β β β βββ LoadingState.tsx
β β β β β βββ ProjectHeader.tsx
β β β β β βββ ProjectTabs.tsx
β β β β βββ hooks/
β β β β β βββ useBugHandlers.ts
β β β β β βββ useFeatureFilters.ts
β β β β β βββ useFeatureFiltersState.ts
β β β β β βββ useProjectData.ts
β β β β βββ AIGenerationDialog.tsx
β β β β βββ BugTab.tsx
β β β β βββ CreateBugDialog.tsx
β β β β βββ CreateFeatureDialog.tsx
β β β β βββ EditBugDialog.tsx
β β β β βββ EditFeatureDialog.tsx
β β β β βββ EmptyState.tsx
β β β β βββ FeatureCard.tsx
β β β β βββ FeaturesTable.tsx
β β β β βββ ShareProjectDialog.tsx
β β β β βββ StatusDropdown.tsx
β β β β βββ TestCasesPage.tsx
β β β βββ ProjectDetails.tsx # Project details page
β β βββ services/ # API service layer
β β β βββ api.ts # Base API configuration & interceptors
β β β βββ api.test.ts # API tests
β β β βββ admin.service.ts # Admin API calls
β β β βββ auth.service.ts # Authentication API calls
β β β βββ bug.service.ts # Bug API calls
β β β βββ feature.service.ts # Feature API calls
β β β βββ project.service.ts # Project API calls
β β β βββ test-case.service.ts # Test case API calls
β β β βββ user.service.ts # User API calls
β β βββ hooks/ # Custom React hooks
β β β βββ use-auth.ts # Authentication hook
β β β βββ use-mobile.tsx # Mobile detection hook
β β β βββ use-toast.ts # Toast notifications hook
β β β βββ useBug.ts # Single bug hook
β β β βββ useBugs.ts # Bugs management hook
β β β βββ useFeatures.ts # Features management hook
β β β βββ useNavigation.ts # Navigation utilities
β β β βββ useProjects.ts # Projects management hook
β β β βββ useProjectTestCases.ts # Project-level test cases hook
β β β βββ useTestCases.ts # Test cases management hook
β β β βββ useUserProfile.ts # User profile hook
β β βββ types/ # TypeScript type definitions
β β β βββ auth.ts # Authentication types
β β β βββ bug.ts # Bug types
β β β βββ feature.ts # Feature types
β β β βββ project.ts # Project types
β β β βββ test-case.ts # Test case types
β β β βββ user.ts # User types
β β βββ utils/ # Utility functions
β β β βββ admin-helpers.ts # Admin utilities
β β β βββ array-helpers.ts # Array manipulation
β β β βββ auth-helpers.ts # Auth utilities
β β β βββ bug-helpers.tsx # Bug utilities
β β β βββ feature-helpers.ts # Feature utilities
β β β βββ logger.ts # Logging utilities
β β β βββ navigation.ts # Navigation helpers
β β β βββ test-case-helpers.ts # Test case utilities
β β β βββ user-helpers.ts # User utilities
β β βββ config/ # Configuration files
β β β βββ routes.tsx # Route definitions
β β βββ layouts/ # Layout components
β β β βββ AppLayout.tsx # Main application layout
β β βββ lib/ # Library utilities
β β β βββ utils.ts # General utility functions (cn, etc.)
β β βββ App.tsx # Root App component
β β βββ main.tsx # Application entry point
β β βββ index.css # Global styles
β β βββ vite-env.d.ts # Vite type definitions
β βββ public/ # Static assets
β βββ package.json # Frontend dependencies
β βββ vite.config.ts # Vite configuration
β
βββ supabase_vector_migration.sql # Supabase vector database schema
The QBrain system is built on 4 core layers that work together to provide intelligent SRS analysis:
- Purpose: Process and prepare documents for AI analysis
- Components:
documentParser.js: Extract text from PDF/TXT files (Google Document AI or pdf-parse)embeddings.js: Convert text chunks to vector embeddings (OpenAI text-embedding-3-small)
- Output: Vector embeddings stored in Supabase
- Purpose: Find relevant context from SRS documents
- Components:
retrievalCore.js: Execute 8 parallel semantic searchessectionsCore.js: Group chunks by SRS sections, analyze coverageretrievalStrategies.js: Advanced retrieval strategies
- Output: Ranked, weighted context chunks organized by sections
- Purpose: AI-powered analysis and generation
- Components:
featureExtraction.js: Extract features from SRS using RAGtestCaseGeneration.js: Generate test cases for featuresgherkinConversion.js: Convert test cases to Gherkin formatsectionMatching.js: Match features to SRS sectionsjsonUtils.js: Parse and validate LLM JSON responses
- Output: Structured features and test cases with metadata
- Purpose: Centralized AI configuration
- Components:
llmClient.js: LLM client factory (OpenAI, etc.)models.config.js: Model configurations (GPT-4o-mini, embeddings)constants.js: 8 comprehensive SRS queries with weights
- Output: Configured AI clients ready for use
QBrain uses RAG (Retrieval Augmented Generation) - a sophisticated AI architecture that combines vector search with LLM reasoning to provide accurate, context-aware responses based on your project's SRS documents.
Instead of relying solely on LLM knowledge, the system retrieves relevant information from your project's SRS documents, augments the prompt with this context, and generates responses using LLM based on the retrieved context.
User Query/Request
β
1. Query Expansion (expand related terms)
β Add synonyms and related terms for better retrieval
β
2. Generate Query Embedding (text-embedding-3-small)
β Convert query text to 1536-dimensional vector
β
3. Vector Similarity Search (Supabase + pgvector)
β Semantic search in vector database
β Using cosine similarity to find similar chunks
β
4. Retrieve Top K Relevant Chunks
β Get the most relevant text chunks from SRS
β
5. Weight & Rank Chunks (by category, priority, relevance)
β Apply category weights and prioritize important chunks
β
6. Build Context from Retrieved Chunks
β Combine chunks into coherent context string
β
7. Create Adaptive Prompt (context + instructions)
β Build prompt with context and task instructions
β
8. Send to LLM (GPT-4o-mini with dynamic temperature)
β Generate response using AI model
β
9. Generate & Return Response
β Return final answer to user
π SRS Document Upload
β
π Text Extraction
- Google Document AI (OCR support)
- OR pdf-parse (fallback)
β
βοΈ Intelligent Chunking
- Size: 2000 characters
- Overlap: 300 characters (preserve context)
- Method: RecursiveCharacterTextSplitter
β
π’ Embedding Generation
- Model: text-embedding-3-small
- Dimensions: 1536
- Normalization: Yes (better similarity)
- Batch processing for efficiency
β
πΎ Vector Storage (Supabase + pgvector)
- Table: project_vectors
- Index: IVFFlat (fast similarity search)
- Metadata: projectId, sectionId, etc.
Key Files:
backend/ai/ingestion/documentParser.js- PDF/TXT parsingbackend/ai/ingestion/embeddings.js- Embedding generationbackend/vector/vectorStore.js- Vector database operations
The Magic of 8 Parallel Queries:
Instead of a single search query, QBrain uses 8 specialized parallel queries that target different semantic areas of the SRS document to ensure comprehensive coverage and maximum feature discovery:
COMPREHENSIVE_SRS_QUERIES = [
{
query: "functional requirement feature shall must system behavior use case",
category: "FUNCTIONAL",
weight: 1.0 // Highest priority
},
{
query: "workflow process step procedure lifecycle state transition",
category: "WORKFLOW",
weight: 0.9
},
{
query: "interface user interface UI API integration",
category: "INTERFACE",
weight: 0.8
},
{
query: "quality performance security usability reliability",
category: "QUALITY",
weight: 0.8
},
{
query: "constraint assumption dependency limitation restriction rule",
category: "CONSTRAINT",
weight: 0.5 // Lower priority
},
{
query: "data dictionary field table column attribute",
category: "DATA",
weight: 0.7
},
{
query: "report document format output statement",
category: "REPORT",
weight: 0.5
},
{
query: "notification alert message communication email SMS",
category: "NOTIFICATION",
weight: 0.85
}
]Retrieval Process:
1. Execute 8 Queries in PARALLEL (Promise.all)
β All queries run simultaneously for maximum efficiency
β
2. For Each Query:
- Expand query terms (add synonyms)
- Convert to embedding vector
- Search vector store (cosine similarity)
- Retrieve top K chunks (default: 5-7 per query)
- Enrich with category & weight metadata
β
3. Merge All Results (8 queries Γ 5 chunks = 40 chunks)
β Combine all retrieved chunks from all queries
β
4. Deduplication
- Hash by first 100 characters
- Remove duplicate chunks
- Keep highest relevance version
β
5. Category-Based Weighting
- FUNCTIONAL: weight 1.0 (highest priority)
- WORKFLOW: weight 0.9
- NOTIFICATION: weight 0.85
- INTERFACE/QUALITY: weight 0.8
- DATA: weight 0.7
- CONSTRAINT/REPORT: weight 0.5 (lower priority)
β
6. Sort by Adjusted Relevance
adjustedRelevance = baseRelevance Γ categoryWeight
β
7. Group by SRS Sections
- Extract section numbers (e.g., "3.2.1")
- Group chunks by section
- Track section coverage
Why 8 Queries?
- Better Coverage: Single query might miss important information
- Semantic Diversity: Each query targets different aspect
- Weighted Results: Priority-based ranking (FUNCTIONAL > CONSTRAINT)
- Section Awareness: Maintains document structure
Key Files:
backend/ai/retrieval/retrievalCore.js- Core retrieval logicbackend/ai/config/constants.js- 8 query definitionsbackend/ai/retrieval/sectionsCore.js- Section grouping
1. Upload SRS Document
β User uploads PDF or TXT file
β
2. Process Document (Ingestion Layer)
β Extract text, chunk, and generate embeddings
β
3. Comprehensive Retrieval (8 parallel queries)
β Execute 8 specialized queries simultaneously
- Gets 40+ chunks (5 per query)
- Deduplicates to ~25-30 unique chunks
β
4. Group Chunks by SRS Sections
β Organize chunks by document structure
- Extract section numbers: "3.2.1", "4.5.2", etc.
- Create section-based context
β
5. Build Context String
β Format chunks into structured context
Format:
[Section 3.2.1]
chunk text...
[Section 4.5.2]
chunk text...
[Other Content]
ungrouped chunks...
β
6. Create Adaptive Prompt (High-Recall Mode)
β Build prompt optimized for comprehensive extraction
- Instructions for comprehensive extraction
- JSON output format
- Feature type classification
- Acceptance criteria generation
β
7. Call LLM (GPT-4o-mini, temperature: 0.3)
β Generate features using AI
- Low temperature for consistent extraction
- JSON mode for structured output
β
8. Parse JSON Response
β Extract and validate feature data
- Extract features array
- Validate structure
β
9. Enhance Features
β Add metadata and scores to features
- Match chunks to features (keyword matching)
- Calculate relevance scores
- Extract matched sections
- Generate reasoning text
- Calculate ranking scores
β
10. Clean & Deduplicate
β Remove duplicates and filter low-quality features
- Remove duplicates (normalize names)
- Filter low-quality features
- Aggregate data fields into data models
- Remove infrastructure-only features
β
11. Section Coverage Analysis
β Analyze which SRS sections were covered
- Calculate coverage percentage
- Identify missing sections
- Generate recommendations
β
12. Save to MongoDB
β Persist features to database
Key Files:
backend/ai/reasoning/featureExtraction.js- Main extraction logicbackend/ai/reasoning/prompts/index.js- Prompt templates
1. Select Feature
β User selects a feature to generate tests for
β
2. Context Retrieval Strategy
β Choose optimal retrieval method based on feature
IF feature has matchedSections:
β Retrieve from specific sections (section-aware)
ELSE IF useComprehensiveRetrieval:
β Use 8-query comprehensive retrieval
ELSE:
β Query by feature description
β
3. Feature-Type-Specific Prompt
β Create prompt optimized for feature type
FUNCTIONAL β Focus on use cases, user actions
DATA β Focus on data validation, CRUD operations
WORKFLOW β Focus on state transitions, steps
QUALITY β Focus on performance, security tests
NOTIFICATION β Focus on delivery, content verification
β
4. Build Context String
β Combine retrieved chunks into context
- Include section references
- Combine all retrieved chunks
β
5. Call LLM (GPT-4o-mini, temperature: 0.3, JSON mode)
β Generate comprehensive test cases
- Generate happy path scenarios
- Generate negative test cases
- Generate edge cases
- Assign priorities (P0, P1, P2, P3)
β
6. Parse & Validate Test Cases
β Extract and validate test case structure
β
7. Enhance Test Cases
β Add metadata and enrich test cases
- Link to feature
- Add section references
- Calculate relevance scores
β
8. Generate Gherkin Format (AI or rule-based)
β Convert to BDD format
- Given-When-Then structure
- Feature, Scenario, Steps
β
9. Save to MongoDB
β Persist test cases to database
β
10. Store in Vector Store (for chatbot)
β Store embeddings for future retrieval
- Embed test case content
- Add metadata (featureId, priority, etc.)
Key Files:
backend/ai/reasoning/testCaseGeneration.js- Test case generationbackend/ai/reasoning/gherkinConversion.js- Gherkin conversion
1. User Question
β User asks a question about the SRS
β
2. Conversation History (Optional)
β Use previous conversation for context
- Last 10 messages
- Maintains context across questions
β
3. Query Expansion & Variations
β Enhance query for better retrieval
- Expand query with synonyms
- Create 3 query variations
- Add category detection
β
4. Multi-Query Retrieval
β Retrieve from multiple query variations
- Execute all 3 variations
- Retrieve nResults Γ 2 chunks (for deduplication)
- Deduplicate by text hash
β
5. Category-Based Weighting
β Apply weights based on question category
- Detect question category
- Apply category weight
- Boost priority-based chunks (High > Medium > Low)
- Boost critical test cases
β
6. Sort & Filter
β Rank and select best chunks
- Sort by adjusted relevance
- Prioritize critical tests
- Take top nResults chunks
β
7. Build Context with Metadata
β Format context with rich metadata
Format:
[Section: 3.2.1 | Feature: Login | Priority: High]
chunk content...
[Section: 4.5.2 | Test Case: Verify Password]
test case content...
β
8. Dynamic Temperature Selection
β Adjust creativity based on question type
- Precise questions β 0.6 (more accurate)
- Explanatory questions β 0.8 (more natural)
- Default β 0.8 (balanced, friendly)
β
9. Build Prompt with History
β Create comprehensive prompt
- System prompt (SRS context rules)
- User prompt (question + history + context)
β
10. Call LLM (GPT-4o-mini)
β Generate conversational response
- Generate natural, conversational response
- Cite section numbers
- Reference specific features/test cases
β
11. Return Response
β Return answer to user
Key Features:
- β Context-Aware: Uses project-specific SRS content
- β History Support: Maintains conversation context
- β Section Citations: References specific SRS sections
- β Category Detection: Optimizes retrieval by question type
- β Weighted Results: Prioritizes important information
Key Files:
backend/ai/chatbot/query.js- Chatbot RAG logicbackend/ai/rag/query.js- Simple RAG query handler
// Similarity Search Process
1. Query Text β Embedding Vector (1536 dimensions)
2. Cosine Similarity Search in PostgreSQL
3. Filter by projectId (project isolation)
4. Return top K most similar chunksWhy Supabase + pgvector?
- β Fast similarity search (IVFFlat index)
- β PostgreSQL reliability
- β Project-scoped filtering
- β Metadata support (JSONB)
- Dimensions: 1536
- Cost: $0.02 per 1M tokens (very cheap!)
- Quality: Excellent for semantic search
- Normalization: Yes (improves cosine similarity)
- For Reasoning: temperature 0.3 (consistent, accurate)
- For Chatbot: temperature 0.6-0.8 (natural, friendly)
- Cost: $0.15 per 1M input tokens
- JSON Mode: Enabled for structured outputs
- Parallel Queries: 8 queries executed simultaneously
- Batch Embeddings: Generate embeddings in batches
- Caching: Vector store caches embeddings
- Deduplication: Prevents duplicate chunks
- Weighted Ranking: Prioritizes important information
- Section Grouping: Organized context structure
Each project has isolated vector storage:
- All chunks tagged with
projectId - Similarity search filtered by
projectId - No cross-project data leakage
- Secure multi-tenant architecture
1. Select Feature
β
2. Retrieve Context:
- From matched sections (if available)
- OR comprehensive retrieval
- OR feature description-based search
β
3. Build Feature-Type-Specific Prompt
β
4. Call LLM (GPT-4o-mini, JSON mode)
β
5. Generate Test Cases
β
6. Enhance & Validate
β
7. Save to MongoDB
β
8. Generate Gherkin (AI or rule-based)
β
9. Store in Vector Store (for chatbot)
- Model:
text-embedding-3-small(1536 dimensions) - Cost: $0.02 per 1M tokens
- Features:
- Text cleaning before embedding
- Vector normalization for better cosine similarity
- Batch processing support
- Retry mechanism with exponential backoff
- 8 Parallel Queries covering all feature types
- Query Expansion for better recall
- Deduplication based on text content
- Section Grouping for organized context
- Retrieves comprehensive context (8 categories)
- Organizes context by sections
- Creates adaptive prompts (high-recall mode)
- Enhances features with metadata and scores
- Analyzes section coverage
- Feature-type-specific prompts
- Section-aware context retrieval
- JSON mode for structured output
- Automatic Gherkin conversion
- Supabase + pgvector for fast similarity search
- Stores embeddings with metadata
- Project-scoped filtering
- Automatic embedding generation for new documents
LangChain provides:
- ChatOpenAI: LLM management and invocation
- OpenAIEmbeddings: Embedding generation
- PromptTemplate: Prompt management and formatting
- RetrievalChain: RAG chain orchestration
- SupabaseVectorStore: Vector store integration
- RecursiveCharacterTextSplitter: Intelligent text chunking
- Node.js >= 18.0.0
- npm >= 9.0.0
- MongoDB (local or Atlas cloud)
- Supabase account (for vector storage)
- OpenAI API key
- Google Cloud account (optional, for Document AI)
git clone https://github.com/yourusername/QBrain.git
cd QBraincd backend
npm install
# Copy environment template
cp .env.example .env
# Edit .env file with your actual API keys:
# - OPENAI_API_KEY (required)
# - SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY (required)
# - MONGO_URI (required)
# - JWT_SECRET (required)
# - GCP credentials (optional, for Document AI)
# - Email service credentials (optional)Quick Setup: If you want to use shared API keys (for development/testing only):
- Open
backend/.env.example - Replace placeholder values with actual API keys
- Copy to
.env:cp .env.example .env - Adjust any settings as needed
.env files.
cd frontend
npm install
# Copy environment template
cp .env.example .env
# Edit .env if needed (default usually works):
# VITE_API_BASE_URL=http://localhost:5000/api# Start MongoDB locally (if using local instance)
mongod
# Or use MongoDB Atlas cloud service
# Update MONGO_URI in .env with your Atlas connection string-
Create a new Supabase project at supabase.com
-
Enable pgvector extension:
CREATE EXTENSION IF NOT EXISTS vector;- Run the migration script (
supabase_vector_migration.sql):
-- Create project_vectors table
CREATE TABLE IF NOT EXISTS project_vectors (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
content TEXT NOT NULL,
embedding vector(1536),
metadata JSONB,
project_id TEXT,
created_at TIMESTAMP DEFAULT NOW()
);
-- Create index for vector similarity search
CREATE INDEX ON project_vectors USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);
-- Create function for similarity search
CREATE OR REPLACE FUNCTION match_project_vectors(
query_embedding vector(1536),
match_threshold float DEFAULT 0.7,
match_count int DEFAULT 10,
filter_project_id TEXT DEFAULT NULL
)
RETURNS TABLE (
id UUID,
content TEXT,
metadata JSONB,
similarity float,
project_id TEXT
)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY
SELECT
project_vectors.id,
project_vectors.content,
project_vectors.metadata,
1 - (project_vectors.embedding <=> query_embedding) as similarity,
project_vectors.project_id
FROM project_vectors
WHERE (filter_project_id IS NULL OR project_vectors.project_id = filter_project_id)
AND 1 - (project_vectors.embedding <=> query_embedding) > match_threshold
ORDER BY project_vectors.embedding <=> query_embedding
LIMIT match_count;
END;
$$;# Terminal 1: Backend
cd backend
npm run dev
# Terminal 2: Frontend
cd frontend
npm run dev# Build frontend
cd frontend
npm run build
# Start backend (with PM2 or similar)
cd backend
npm startThe application will be available at:
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- Navigate to sign-up page
- Enter name, email, and password
- Verify email address (check inbox)
- Log in with credentials
- Click "Create Project" button
- Enter project name and description
- (Optional) Upload SRS document (PDF or TXT)
- Project is created and ready
- Navigate to project details
- Click "Upload SRS" if not uploaded during creation
- Select PDF or TXT file
- Wait for processing (automatic chunking and embedding)
- Status updates to "Processed" when complete
- Click "Generate Features (AI)" button
- Wait for AI processing (30-60 seconds)
- Review extracted features with:
- Feature types (FUNCTIONAL, DATA, REPORT, etc.)
- Priority levels
- Matched SRS sections
- Confidence scores
- Section coverage analysis
- Select a feature
- Click "Generate Test Cases (AI)" button
- Review AI-generated test cases:
- Happy path scenarios
- Negative test cases
- Edge cases
- Priority assignments
- Test cases are automatically saved with Gherkin format
- Navigate to project chatbot
- Ask questions about the SRS
- Get accurate answers based on document context
- Answers reference specific SRS sections
- Navigate to Bugs tab in project
- Create bugs linked to features
- Track bug status and assignments
- View bug analytics
For detailed explanations of the AI system, see:
-
AI_SYSTEM_EXPLANATION.md - Complete AI system documentation (Arabic)
- Full workflow explanations
- Component details
- Technical deep dives
- Best practices
-
AI_QUICK_GUIDE.md - Quick reference guide (Arabic)
- Key concepts
- Quick workflows
- Important notes
- Cost information
- SRS Processing: 30-60 seconds (depending on document size)
- Feature Extraction: 30-60 seconds per SRS (with 8 parallel queries)
- Test Case Generation: 10-20 seconds per feature
- Gherkin Conversion: 2-5 seconds per test case
- Section Coverage: 75-85% average coverage
- Feature Extraction Accuracy: High (validated by section matching)
- Test Case Quality: Comprehensive (happy path + negative + edge cases)
- Embeddings (text-embedding-3-small): $0.02 per 1M tokens
- GPT-4o-mini: $0.15 per 1M input tokens
- Average Cost per SRS: $0.10 - $0.50 (depending on size)
- Cost per Feature Extraction: ~$0.05 - $0.15
- Cost per Test Case Generation: ~$0.01 - $0.03
- β JWT-based authentication
- β HTTP-only cookies for token storage
- β Password hashing with bcrypt (12 rounds)
- β Email verification required
- β Password reset with secure tokens
- β Input validation with Zod schemas
- β SQL injection prevention (MongoDB)
- β XSS protection
- β CORS configuration
- β Environment variable protection
- β Rate limiting (recommended in production)
- β Request size limits (500MB for file uploads)
- β File type validation (PDF/TXT only)
- β Row Level Security (RLS) on Supabase
- β
Never commit
.envfiles - β Use strong JWT secrets
- β Rotate API keys regularly
- β Monitor API usage
- β Implement logging and monitoring
cd backend
npm testcd frontend
npm test- User authentication (sign up, sign in, email verification)
- Project creation and management
- SRS upload and processing
- Feature extraction
- Test case generation
- Gherkin conversion
- Chatbot queries
- Bug tracking
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow TypeScript best practices
- Write meaningful commit messages
- Add tests for new features
- Update documentation as needed
- Follow existing code style
- Add JSDoc comments for complex functions
- Use ESLint and Prettier
- Follow existing naming conventions
- Keep functions focused and small
- Add error handling
- Include input validation
This project is licensed under the MIT License - see the LICENSE file for details.
- Fatima Rajab - Initial work and development
- OpenAI - For GPT models and embeddings
- LangChain - For LLM framework
- Supabase - For vector database
- shadcn/ui - For beautiful UI components
- Google Document AI - For PDF processing
- Vercel - For deployment inspiration