YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
SentinelQMS - AI-Powered Customer Complaint Management System MVP
An end-to-end MVP for a Pharmaceutical Manufacturing Quality Management System (QMS). This tool automates customer complaint intake by extracting 11 structured fields from unstructured complaint text or uploaded documents (PDF, DOCX, TXT, EML) using a LangGraph state graph powered by Groq API, and assigns an initial GMP risk severity & priority rating.
ποΈ System Architecture
βββββββββββββββββββββββββββββββββββββββββββ
β React + Redux Store β
β (Vite + Inter Font) β
ββββββββββββββββββββββ¬βββββββββββββββββββββ
β
POST /api/extract
POST /api/parse-and-extract
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Backend β
ββββββββββββββββββββββ¬βββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β LangGraph State Pipeline β
ββββββββββββββββββββββ¬βββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββββββββββ ββββββββββββββββββββββββ ββββββββββββββββββββββββ
β 1. extract_fields β β 2. assess_severity β β 3. generate_summary β
β βββββββββββββββββΊβ _priority βββββββββββββββββΊβ (Bonus) β
β Model: llama-3.1-8b-instant β β Model: llama-3.3-70b β β Model: llama-3.1-8b-instant β
ββββββββββββββββββββββββ ββββββββββββββββββββββββ ββββββββββββββββββββββββ
LangGraph Nodes & Model Strategy
extract_fields(llama-3.1-8b-instant): Extracts 11 key QMS metadata fields:complaint_source,customer_name,product_name,product_strength_grade,batch_lot_number,manufacturing_date,expiry_date,quantity_affected,complaint_type,complaint_date,detailed_description.assess_severity_priority(llama-3.3-70b-versatile): Evaluates initial severity (Critical,Major,Minor) and priority (High,Medium,Low) based on GMP risk, patient health impact, and sterility/potency risks. Includes detailed technical rationale.generate_exec_summary[Bonus Node] (llama-3.1-8b-instant): Produces a 2-3 line executive summary and immediate QA action items (e.g. batch quarantine, sample returns).
π Repository Structure
.
βββ backend/
β βββ app/
β β βββ api/
β β βββ core/
β β β βββ config.py # Environment & Groq configuration
β β βββ graph/
β β β βββ nodes.py # LangGraph node definitions
β β β βββ workflow.py # LangGraph StateGraph setup
β β βββ schemas/
β β β βββ complaint.py # Pydantic schemas
β β βββ services/
β β β βββ groq_client.py # Groq API client with JSON mode
β β βββ utils/
β β β βββ doc_parser.py # PDF/DOCX/TXT/EML parser
β β βββ main.py # FastAPI server & routes
β βββ tests/
β β βββ sample_fixtures.py # 3 realistic pharma complaint fixtures
β βββ .env.example
β βββ requirements.txt
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ Header.jsx
β β β βββ LeftPanelForm.jsx # Log Customer Complaint Form
β β β βββ RightPanelAssistant.jsx # AI Intake & Chat Assistant
β β β βββ ProgressBar.jsx # LangGraph stage indicator
β β βββ store/
β β β βββ complaintSlice.js # Redux Toolkit state
β β β βββ store.js
β β βββ App.jsx
β β βββ main.jsx
β β βββ index.css # Modern dark theme styles
β βββ index.html
β βββ package.json
β βββ vite.config.js
βββ README.md
π Quickstart Guide
Prerequisites
- Python 3.9+
- Node.js 18+ & npm
- Groq API Key (Sign up free at console.groq.com)
1. Running Backend (FastAPI)
Open terminal and navigate to
/backend:cd backendCreate a virtual environment & activate it:
python -m venv venv # On Windows (PowerShell): .\venv\Scripts\Activate.ps1 # On Mac/Linux: source venv/bin/activateInstall dependencies:
pip install -r requirements.txtConfigure your
.envfile:cp .env.example .envOpen
.envand set your Groq API Key:GROQ_API_KEY=gsk_your_actual_groq_api_key_here GROQ_MODEL_FAST=llama-3.1-8b-instant GROQ_MODEL_REASONING=llama-3.3-70b-versatile PORT=8000Launch FastAPI development server:
python -m app.mainThe backend runs on
http://localhost:8000. You can test API endpoints interactively athttp://localhost:8000/docs.
2. Running Frontend (React + Vite)
Open a second terminal window and navigate to
/frontend:cd frontendInstall dependencies:
npm installStart Vite dev server:
npm run devOpen
http://localhost:5173in your browser.
π§ͺ Testing the MVP
- Preset Test Fixtures:
On the top right panel, click one of the preset buttons:
- Sterility / Particulate Contamination (Critical)
- Sub-potency / Efficacy Failure (Major)
- Packaging / Labeling Defect (Minor)
- Text / Document Upload:
- Paste raw text into the text area OR drop a PDF / DOCX file into the upload zone.
- Click "Extract & Assess AI".
- Inspect Extraction:
- Watch the Extraction Progress Bar move through LangGraph stages (Node 1 $\rightarrow$ Node 2 $\rightarrow$ Node 3).
- Observe auto-populated form fields on the Left Panel.
- Review Executive Summary & Recommended Steps on the Right Panel.
- Follow-Up Interactive Chat:
- Use the chat box at the bottom right to ask questions like:
- "What risk does this issue pose to patient health?"
- "What root cause analysis steps should we take?"
- Use the chat box at the bottom right to ask questions like:
π‘οΈ Robustness & Error Handling
- JSON Mode & Pydantic Validation: Every LLM node enforces structured JSON responses via Pydantic model validation.
- Graceful Fallbacks: API key errors, network issues, or malformed LLM outputs are caught and handled gracefully in the state graph without crashing the UI.
- Database Abstraction: Built with an in-memory dictionary layer that can be swapped for PostgreSQL by updating a single repository module.