Private-by-design Streamlit demo for drafting structured CAPA and root-cause analysis outputs in a MedTech quality-system context.
The tool helps a Quality Engineer turn a complaint, nonconformity, PMS trend, audit finding, supplier issue, production deviation, or design issue into a structured investigation draft.
It does not approve CAPA, confirm root cause, decide vigilance reportability, or replace QA/RA review.
From a structured case intake, the app returns:
- problem statement;
- containment and immediate-control actions;
- visual 5-Why chain plus detailed evidence expectations;
- visual Ishikawa cause map with causes and evidence checks;
- root-cause hypotheses;
- correction, corrective action, and preventive action plan;
- owner/action matrix;
- evidence gaps;
- effectiveness-check proposal;
- QMS record links;
- regulatory, PMS, vigilance, and risk-management prompts;
- Markdown and PDF investigation draft export.
Many small MedTech teams still manage CAPA, complaints, nonconformities, and PMS signals through spreadsheets and manual reviews. This project explores a lightweight middle ground:
- keep the human responsible for quality and regulatory decisions;
- use structured AI assistance to prepare a better first draft;
- make the output easier to review, challenge, assign, and document.
The goal is not to automate quality decisions. The goal is to reduce blank-page work and make investigation thinking more consistent.
The prompt and guardrails are grounded in practical QMS logic:
- ISO 13485-style CAPA, complaint, nonconformity, document-control, training, supplier, design, and management-review thinking;
- ISO 14971-style risk-file feedback thinking;
- MDR post-market surveillance and vigilance screening prompts;
- human review boundaries for root cause, CAPA approval, risk decisions, and regulatory decisions.
The app asks the LLM for structured JSON, then applies post-processing guardrails before showing the result. The visible draft must contain a complete 5-Why chain, all Ishikawa categories, minimum action depth, evidence gaps, effectiveness checks, QMS links, and regulatory prompts. If the model response is incomplete, the deterministic quality engine fills the missing structure.
Supported providers:
- Groq: OpenAI-compatible API, practical free-tier demo option.
- Gemini: official developer API option.
- OpenAI-compatible: OpenAI API, OpenRouter, private gateways, or another compatible provider.
Users bring their own API key. No API key is committed to this repository.
For real complaint or client data, do not use a free-tier model unless the client's data policy allows it. Use fictional, anonymized, or synthetic records for demos.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
streamlit run app.pyOn Windows PowerShell:
py -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
streamlit run app.pyThe included sample case uses the fictional SomniAir Auto portfolio:
- firmware
v0.9.3; - pressure spike complaints after humidifier reconnect;
- increasing PMS trend;
- CAPA opened;
- field action initiated;
- design, risk, V&V, complaint, and PMS records linked.
The app includes a saved AI-style draft for this sample case:
sample_data/somniair_pressure_spike_ai_draft.json
When the SomniAir sample is loaded, the app displays this saved result automatically without calling an API. Use the API only when generating a new draft or intentionally regenerating the sample.
This is a portfolio/demo tool, not validated QMS software.
For real operational use, it would need software validation, access control, audit trail, record retention, change control, cybersecurity review, supplier/API risk assessment, data-processing controls, and procedural integration before being used inside a regulated QMS.