MamaCare AI is a safety-first maternal information assistant I built to explore how retrieval-augmented generation can provide clear, stage-aware pregnancy information between care contacts while keeping emergency escalation, medication safety and uncertainty outside the generative layer.
33Curated knowledge cards structured by topic, stage, questions and escalation context.
6Deterministic safety layers applied before retrieval or answer generation.
HybridLexical high-priority FAQ matching plus semantic retrieval.
LocalRetrieval architecture designed without requiring an external LLM API.
The Human Problem
Imagine a pregnant mother at home with a question. Her next antenatal appointment is several days away. She may not need a diagnosis, but she needs trustworthy information now.
The problem is not the absence of information. The problem is knowing which information is reliable, relevant to pregnancy and safe enough to act on. A fluent general-purpose chatbot can create another risk when its source is unclear, when the question falls outside available evidence or when the user describes a warning sign.
For maternal health, a plausible-looking wrong answer is more dangerous than an unanswered question.
The Challenge
The challenge was not simply making AI answer pregnancy questions. Modern language systems can generate answers easily. The harder product question was how to design an assistant whose safest action is sometimes to stop answering.
That required the prototype to separate grounding, safety routing, uncertainty, stage relevance, traceability and privacy. The assistant should answer from controlled maternal-health content, but high-risk patterns should be checked before normal retrieval and response generation.
The Product Question
I framed MamaCare around one central question:
Can a RAG assistant provide useful maternal-health education while keeping high-risk decisions outside the generative model?
This changed the design from a simple question-to-answer chatbot into a controlled request workflow where safety policy, context detection, retrieval, citation, escalation and abstention are treated as separate responsibilities.
My Role
I designed and developed the prototype across problem definition, product workflow, maternal knowledge-card schema, document ingestion, lexical retrieval, semantic retrieval, embedding strategy, ChromaDB indexing, safety-rule architecture, stage-awareness logic, response grounding, citation handling, uncertainty fallbacks, privacy rules, sandbox implementation and evaluation-roadmap design.
The project allowed me to explore AI development beyond connecting a chatbot to an API. The main engineering challenge became controlling model behaviour around the edges of what it should be allowed to answer.
The Design Principle
MamaCare follows one central rule: safety should not depend on the assistant generating the right sentence.
A conventional RAG flow might use question, retrieval and generation. MamaCare places deterministic policy checks before retrieval so certain categories of prompts do not depend on semantic search deciding whether they are dangerous.
The Solution Architecture
The solution separates the visible chat experience from the policy, retrieval and evidence layers underneath it. This makes the system easier to test, audit, improve and discuss with domain reviewers.
Receive and normalize Accept the user's message and prepare it for policy screening.
Input context Message ready for safety checks.
Safety policy
Screen before retrieval Check emergency, medication, crisis, privacy and out-of-scope patterns.
Route decision Continue, escalate, block or abstain.
Stage context
Add pregnancy context Identify available stage or trimester signals where possible.
Relevant framing The response is shaped around available context.
Hybrid retrieval
Find trusted content Use high-priority FAQ matching and semantic retrieval against curated knowledge cards.
Grounding evidence Ranked source cards support the answer.
Response layer
Answer or stop Produce concise education, cite source context, escalate or decline to guess.
Safe output Educational answer, referral boundary or abstention.
The Safety Architecture
The current prototype contains six deterministic policy layers. Emergency-pattern routing sends matched high-risk symptom patterns to escalation guidance before normal retrieval. Crisis-language patterns take a separate escalation path. Sensitive pregnancy-related decision language receives supportive boundaries rather than a decision.
Medication and dosage requests are blocked from normal answer generation. Privacy protection discourages unnecessary personal identifier sharing. Out-of-scope questions are declined rather than routed into unrestricted general-purpose generation.
The more defensible claim is not that every phrasing is guaranteed. The claim is that matched high-risk symptom patterns follow the same deterministic escalation path rather than relying on generative-model judgement.
Why Safety And Retrieval Are Separate
If safety were left entirely to the language model, a reviewer would have to trust the model to recognise risk, classify it correctly, ignore unsafe retrieved text and produce the appropriate response.
MamaCare makes policy decisions visible in code. That makes the logic easier to test, audit, version, review with subject-matter specialists, expand and challenge.
Use AI where interpretation helps. Use deterministic rules where policy must be explicit.
The Knowledge Layer
The highest-trust content is stored as structured maternal-health knowledge cards. A card can contain topic, stage or trimester, keywords, common question phrasing, plain-language guidance, when-to-seek-care information, danger-sign metadata, trust metadata and source reference.
This avoids retrieving an arbitrary paragraph from a large PDF and treating it as an answer. Approved information can instead be deliberately structured for known user needs.
Hybrid Retrieval
MamaCare does not rely on semantic search alone. Some common questions are mapped through lexical signals and known question patterns, giving important topics a predictable route.
When lexical matching is insufficient, the full application uses sentence-transformer embeddings and ChromaDB to search for nearest relevant knowledge cards. Lexical matching protects known high-priority patterns. Semantic retrieval improves flexibility.
User Journey
When a user asks MamaCare a question, the system receives the message, screens it for policy conditions, adds available pregnancy-stage context, checks high-trust FAQ paths, retrieves relevant content where needed, ranks trusted cards and responds only within the evidence available.
If trusted evidence is weak, the system should decline to guess and direct the user toward appropriate professional care. The important product behaviour is not only that MamaCare can answer. It is also that MamaCare can decide ordinary answering is not the correct workflow.
Intended Use Cases
Pregnant Mothers
The assistant can provide clear educational information between antenatal contacts, with a strict boundary: no diagnosis, prescription or replacement for antenatal care.
Community Health Workers
A governed knowledge layer could make approved educational messages easier to retrieve during community engagement, subject to programme and clinical validation.
Maternal-Health Programmes
The architecture could help distribute reviewed information consistently across locations and channels through versioned, tagged and centrally updated knowledge cards.
Why This Is More Than A Chatbot
The visible interface is chat, but the AI Developer story sits underneath it: knowledge engineering, RAG, guardrails, abstention, traceability, local retrieval architecture and evaluation design.
MamaCare demonstrates how trusted information can be structured for retrieval, how semantic search can be used without making it responsible for safety policy and how source information stays attached to answers.
Evaluation Should Become The Next Major Feature
The current prototype demonstrates architecture. The next step is demonstrating performance through a labelled evaluation suite.
I would measure retrieval precision, recall, grounding quality, citation correctness, safety recall, false escalation, medication refusal, abstention quality and latency. Once those numbers exist, implementation counts can be replaced with tested evaluation metrics.
Current Demonstrated Results
Because MamaCare is a prototype rather than a clinical deployment, its current results are product capabilities, not patient outcomes.
Today the project demonstrates 33 curated knowledge cards, six deterministic policy layers, hybrid retrieval, grounded-response design and a local retrieval architecture. The phrase "citations required on grounded-answer paths" is more accurate than presenting citation behaviour as a clinical evaluation result.
What The Project Does Not Prove
MamaCare has not demonstrated clinical efficacy, improved maternal outcomes, reduced clinic workload, diagnostic accuracy, validated clinical triage, nationwide usability, multilingual safety equivalence, regulatory approval, production-scale security or clinician-approved coverage of all pregnancy topics.
It should remain described as a safety-first AI prototype and architectural demonstration. That transparency makes the project look more mature, not less.
Production-Readiness Path
Before real-world deployment, the product would need clinical content governance, clinician review, labelled safety test sets, monitoring, localization, security controls and health-system integration.
The architecture makes safety logic explicit and reviewable, which is necessary before considering use in a sensitive health setting. It does not make the prototype production-ready by itself.
Technology
Language: Python. Retrieval: RAG, ChromaDB and sentence-transformers. Knowledge processing: Pandas, PyPDF, python-docx and OpenPyXL. AI framework: LangChain Core. Safety: deterministic policy and routing layer. Demo: browser-based portfolio implementation mirroring the retrieval and guardrail workflow.
The Value In One Sentence
MamaCare demonstrates how I design AI systems around a business rule that matters more than generation quality: the system must know what it knows, show where it came from and stop when automated answering is no longer appropriate.