CareCompass Architecture & Implementation

Multi-agent healthcare navigator providing evidence-based wellness insights
CareCompass is a production-ready FastAPI backend that uses advanced AI agents to process healthcare queries through a sophisticated LangGraph workflow. Our system combines cutting-edge AI technology with healthcare domain expertise to deliver reliable, evidence-based guidance.

Technology Stack

FastAPI High-performance web framework for building APIs with automatic documentation
LangGraph Agent workflow orchestration platform for complex AI agent coordination
MongoDB Atlas Cloud-native document database for scalable data persistence
OpenAI API Large language models for intelligent planning and classification
Tavily API Real-time search and content extraction from trusted sources

Multi-Agent Architecture

CareCompass employs a sophisticated multi-agent system where specialized AI agents work together to process healthcare queries through a coordinated workflow:

Intent Agent

Purpose: Classifies and filters healthcare-related queries from general requests

Technology: OpenAI classification models with intelligent keyword fallback mechanisms

Output: Healthcare classification confidence scores and intent categorization

Search Agent

Purpose: Discovers and retrieves relevant healthcare information from trusted sources

Technology: Tavily Search API for production environments, mock data for development

Output: Curated collection of healthcare source URLs and metadata

Extractor Agent

Purpose: Extracts comprehensive content from identified healthcare sources

Technology: Tavily Extract API with intelligent content caching and persistence

Output: Full-text content from verified healthcare authorities and institutions

Validator Agent

Purpose: Evaluates content quality, credibility, and healthcare relevance

Technology: Rule-based scoring algorithms with trusted domain validation

Output: Content credibility scores, quality metrics, and source reliability assessments

Planner Agent

Purpose: Synthesizes information into actionable healthcare guidance

Technology: Template-based deterministic planning or AI-powered dynamic planning

Output: Structured action plans with safety recommendations and clinical guidance

LangGraph Workflow

The workflow orchestrates agents in a sequential pipeline with error handling:

Step 1: Query intake and user validation
Step 2: Intent classification (healthcare vs. non-healthcare)
Step 3: Information search and source discovery
Step 4: Content extraction from trusted sources
Step 5: Content validation and credibility scoring
Step 6: Action plan generation with safety checks
Step 7: Response compilation and persistence

Database Schema

Users Collection

{ "_id": "user123", "runs_count": 5, "created_at": "2025-01-15T10:00:00Z", "last_run": "2025-01-15T14:30:00Z" }

Runs Collection

{ "_id": "uuid-run-id", "user_id": "user123", "prompt": "What are symptoms of vitamin D deficiency?", "status": "completed|running|failed|queued", "result": { /* Final response object */ }, "artifacts": { /* Agent execution details */ }, "created_at": "2025-01-15T14:30:00Z", "updated_at": "2025-01-15T14:30:45Z" }

Extracts Collection

{ "_id": "url-hash", "url": "https://mayo.edu/article", "content": "Full extracted content...", "metadata": { /* Content metadata */ }, "created_at": "2025-01-15T14:30:30Z" }

Deployment Guide

Environment Variables

# Database Configuration MONGODB_URI=mongodb+srv://... MONGO_DB=carecompass # API Keys OPENAI_API_KEY=sk-... TAVILY_API_KEY=tvly-... # Feature Flags USE_TAVILY=true USE_LLM_PLANNER=true # Optional Configuration CC_MAX_EXTRACT_URLS=5 CC_PERSIST_EXTRACTS=true

Production Deployment

  • Platform: AWS Elastic Beanstalk (via Procfile)
  • Database: MongoDB Atlas (cloud-hosted)
  • Monitoring: Health checks at /health, /env-check, /db-check
  • Rate Limiting: One active query per user every 5 minutes
  • Error Handling: Comprehensive logging with structured context

Safety Features

Key Metrics

API Integration

The backend exposes a RESTful API for healthcare query processing:

CareCompass Backend v1.0.0
Evidence-based healthcare navigation through AI-powered multi-agent workflows
Built with FastAPI, LangGraph, MongoDB, OpenAI, and Tavily API