π¨π³ δΈζθ―΄ζ (Chinese Version) -> README_zh.md
An AI-powered proactive family health management tool. From solving the pain point of "helping children understand parents' medical reports" to evolving into a comprehensive platform including OCR-assisted lab report analysis, prescription medication management, medical visit diaries (with voice-to-text), offline-native PWA experience, comprehensive i18n, and a proactive early-warning system.
- π Full Internationalization (i18n): Seamlessly switch between English and Chinese, covering all UI elements, medical insights, error handling, and the AI alert system.
- βοΈ Production-Grade Compliance: Added Legal Disclaimer and Privacy Policy components. Greatly strengthens the system's compliance for global release and mitigates AI medical advice liability.
- βοΈ Global Flexible Settings: A newly designed platform-level Settings Page, allowing dynamic UI language switching and the ability to change the underlying LLM provider (e.g., Gemini, Claude, Ollama) on the fly.
- π¨ UI/UX Experience Upgrade: Further optimized the borderless, minimalist design and tactile feedback, offering a smoother and more immersive feel tailored to elderly users and differing languages.
How exactly does HealthMate transform a photo of a messy medical report into clear, personalized health advice? It relies on three core technologies working together seamlessly: OCR, a Three-Tier RAG Engine, and an Agent (ReAct Orchestrator).
Here is the step-by-step workflow:
When a user uploads a photo of a lab report, the system first needs to "read" the image. We use local, privacy-safe OCR technology to scan the image and extract unstructured text, outputting raw strings of test item names and numerical values.
RAG (Retrieval-Augmented Generation) is like giving the AI an open-book exam. Instead of hallucinating, it strictly looks up facts. We designed a Three-Tier RAG structure:
- L1 (Global Knowledge): The "Medical Reference Book". It queries local databases (
lab_norms.json,medical_kb.json) to see if an indicator like "ALT" is out of bounds for the user's age/gender. - L2 (Family Timeline): The "Family Medical Folder". The system retrieves the user's historical lab reports from the database. It compares today's "ALT" with the value from 3 months ago to see if it's improving or worsening.
- L3 (Personal Notes): The "Diary". It searches the user's personal notes (e.g., "Dad felt dizzy last week") to provide unique contextual clues.
Now the system has the text and the memories. How does it think? We implemented an Agent Orchestrator based on the ReAct (Reason + Act) pattern. Instead of instantly throwing a prompt to an LLM, the Agent loops through a thought process:
- π€ Thought: "I extracted the text. I need to check the reference norms for ALT."
- π οΈ Act (Tool Call): Calls the
query_lab_normstool. - π Observe: The tool returns "ALT normal range is 0-40, user is at 55."
- π€ Thought: "It's high. Let me check if they had high ALT before."
- π οΈ Act: Calls the
query_lab_historytool. - π Observe: "ALT was 70 three months ago."
- β Final Decision: "Although ALT is high, it is improving. I will assess this as a moderate issue."
Through this dynamic function calling and reasoning loop (running up to 8 iterations), the AI produces highly accurate, personalized outputs. This "thought process" is streamed back to the frontend in real-time using SSE (Server-Sent Events), showing the user exactly how the AI arrived at its conclusions.
- π± Offline PWA Native Experience: Works offline (e.g., in hospital basements) so you can always check your family's medical history.
- π Proactive AI Watchdog: Automatically monitors anomaly trends and medication run-out dates.
- π¬ Multi-Agent RAG Engine: Simulated 3-Tier Multi-Modal RAG architecture (General Knowledge -> Family Timeline -> Personal Notes).
- π‘οΈ Privacy First: Fully local capabilities with Ollama support + End-to-End Encryption principles built-in.
HealthMate/
βββ data/ # Local databases & medical KB (SQLite & JSON)
β βββ drug_interactions_kb.json
β βββ lab_norms.json
β βββ medical_kb.json
β βββ healthmate.db
βββ docs/ # Docs, screenshots, legal templates
β βββ screenshot.png # <== Put your homepage screenshot here
β βββ ...
βββ src/
β βββ components/ # React UI components (LegalModal, Headers, etc.)
β βββ context/ # Global State Management (Auth, Theme)
β βββ lib/ # Utilities (i18n instance, database clients)
β βββ locales/ # i18n Translation Files (en/zh)
β βββ pages/ # Core Pages (Home, History, SettingsPage, etc.)
β βββ server/ # Node.js + Express Backend Services
β βββ agent/ # RAG & ReAct AI Orchestrator
β βββ api/ # Backend API routes
β βββ tools/ # 8 Core Agent Plugin Tools
βββ vite.config.ts # Vite & PWA Build Configuration
βββ server.ts # Node Server entry point
βββ package.json # Scripts and Dependencies
Due to the environment constraints running in Node.js, this system uses TypeScript + Custom ReAct Pattern to implement the required Agent Orchestrator (see src/server/agent/orchestrator.ts).
- ReAct Engine: Built on a self-executing while loop, implementing (Reason -> Act -> Observe).
- Streaming Output (SSE): The backend provides an SSE endpoint, and the frontend intercepts
step_start,tool_call,tool_result,thinking, andfinalevents in real-time to render an immersive thought process. - Dynamic Tool Injection: Utilizes the AI SDK Core's Function Calling system to invoke 8 custom-built tools.
ocr_parse_lab_report: Extracts and parses lab report text from user images via OCR.query_lab_norms: Retrieves structured info (units, thresholds) from localdata/lab_norms.json.search_medical_kb: Matches documents fromdata/medical_kb.jsonbased on suspected symptoms.analyze_indicator: Diagnoses logical implications of an indicator's value vs reference threshold.detect_critical_symptoms: Scans for warning signs (e.g., massive bleeding, loss of consciousness).assess_severity: Evaluates and outputs moderate/severe report summaries.generate_doctor_questions: Generates customized questions for adult children to ask doctors.generate_wechat_message_for_doctor: Drafts a concise WeChat message summarizing patient stats for medical consultation.
npm install
npm run devGoogle Gemini is used by default. Via the Settings Page, you can switch models:
- Ollama Local Mode: Connect to
http://127.0.0.1:11434/v1after running Ollama locally. - Third-Party Cloud Providers: Supports DeepSeek, Tongyi Qianwen (DashScope), and Claude (Anthropic). Configure your API keys in the settings page.
