# Project export: CareLink

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: Cal Hacks 12.0
- Tagline: AI-powered discharge coordination connecting hospitals, shelters, and social workers to ensure safe patient transitions
- Devpost: https://devpost.com/software/carelink-mf4qvr
- GitHub: https://github.com/altran03/calhacks12
- Video: https://www.youtube.com/embed/EZo7LiU-GUY?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Result: winner (Vapi: Best Use of Vapi)
- Team: 2 GitHub contributor(s) — alvintran (10 commits), Scott Martin Bihag (6 commits)

## Devpost submission (written by the team)

### Inspiration

Every day across America, hospitals discharge unhoused patients with nowhere safe to go. We were shocked to learn that over 50-70% of homeless patients in U.S. hospitals are discharged to unsafe or unstable environments without a clear care plan. The current process is slow, fragmented, and relies on phone tag between hospitals, shelters, transport providers, and social workers. Case coordinators spend 4-5 hours per case, making dozens of phone calls, often only to find shelters are full or transportation isn't available. We built CareLink to solve this critical problem by creating an intelligent, voice-enabled coordination system that ensures every unhoused patient leaving a hospital has a verified shelter placement, coordinated transport, and connected social worker for continuity of care.

### What it does

CareLink is a decentralized, multi-agent AI system that automates the entire discharge planning workflow for unhoused patients: 9 Specialized AI Agents (Powered by Fetch.ai) Coordinator Agent: Orchestrates the entire workflow https://agentverse.ai/agents/details/agent1qf5tefy3dd9jwtwl8s0ht0aq6yn4du7ntvwdhhcfxqwwjas7fwcpsme6g35/profile Parser Agent: Extracts structured data from discharge documents using LlamaParse + Gemini AI https://agentverse.ai/agents/details/agent1qthwalvx5c757u0gsdrx6xfu9lf0y9cc6jce8ddvx87cy2w9a7mgv0rthgr/profile Shelter Agent: Matches patients with available shelter beds using real-time data https://agentverse.ai/agents/details/agent1qd4kn4syvtlypa20aq8pct4d6wa6fke77su5tjqsj2ymgr2n0klew447j3s/profile Transport Agent: Schedules accessible transport (Paratransit, Lyft Access, Uber WAV)\ https://agentverse.ai/agents/details/agent1q0vm9tl5d5tjpj3d7qqk692jz0y9f486twxmjzfv8eng288gqf0pgjt83nd/profile Social Worker Agent: Assigns case workers and schedules follow-ups https://agentverse.ai/agents/details/agent1qfxx6ry60e9clra6vgyp76q0uvfrkc6n0kga4cln3f7c6fnl44wgujvphnd/profile Resource Agent: Coordinates food, hygiene kits, and clothing https://agentverse.ai/agents/details/agent1qfz242vsc6hr3ck48kmef73hlj39538ksgt2w4v3fpawyjp8q2yrwr2hdfp/profile Pharmacy Agent: Ensures medication continuity post-discharge https://agentverse.ai/agents/details/agent1qdaq0qhnsgt3f3p0sk0f5642fyceqfh44739prhv0x9x828ay0a6vh4dgen/profile Eligibility Agent: Verifies benefits (Medi-Cal, GA, SNAP) https://agentverse.ai/agents/details/agent1qf0phyg2dqm4q5nee9jx8ukzlry5k3x388rqzdp24kksujmc2nzysa398tf/profile Analytics Agent: Tracks system performance and outcomes https://agentverse.ai/agents/details/agent1qg0g6fm790qu6rcl6tqulk5gvvvq0ma5a4tzcwzkdzp3dr8tneqdjldgltj/profile Voice-First Communication (Powered by Vapi) Automated shelter availability verification calls Social worker outreach and coordination Transport provider scheduling Post-discharge patient check-ins Accessible for low-tech organizations Real-Time Intelligence (Powered by Bright Data) Live shelter capacity data from San Francisco HSH and community sources Up-to-date resource listings (food banks, medical respite, outreach centers) Transport provider schedules Continuously refreshed community resource database Intelligent Document Processing AI-powered PDF parsing with LlamaParse Automatic form autofill from discharge documents Gemini AI for data extraction and structuring Confidence scoring with manual review flagging

### How we built it

Frontend: Framework: Next.js 14 with TypeScript UI/UX: Tailwind CSS + Framer Motion for smooth animations Maps: Mapbox GL JS + react-map-gl for interactive shelter mapping Components: React 18 with modern hooks and state management Icons: Lucide React for consistent iconography Backend: API Framework: FastAPI (Python) Agent Framework: Fetch.ai uAgents for decentralized coordination Database: Supabase (PostgreSQL) for persistent case storage Voice AI: Vapi for automated phone communications Document Processing: LlamaParse for PDF parsing AI Intelligence: Google Gemini 1.5 Pro for data extraction Web Intelligence: Bright Data for real-time shelter/resource data DevOps & Integration: HTTP Client: httpx for async API calls Tunneling: ngrok for webhook handling during development Testing: pytest for backend testing Code Quality: black, ruff, mypy for Python; ESLint for TypeScript

### Challenges we ran into

Agent Communication Complexity Challenge: Coordinating 9 independent Fetch.ai agents without message loss or race conditions Solution: Implemented a robust coordinator pattern with: Message queuing and retry logic State synchronization via Supabase Unique message IDs to prevent duplicates Timeout handling for unresponsive agents Timeline Visualization Challenge: Displaying complex multi-agent workflows in an intuitive timeline Solution: Used Framer Motion for smooth animations Built hierarchical status tracking (agent → task → subtask) Implemented collapsible sections for detailed logs

### Accomplishments we're proud of

9 Production-Ready Fetch.ai Agents - Fully functional multi-agent system with real coordination Vapi Voice Integration - Successfully automated shelter verification and social worker outreach calls Bright Data Intelligence - Live web scraping provides up-to-date shelter availability

### What we learned

Multi-Agent Systems Are Powerful But Complex Agent coordination requires careful message handling State synchronization is critical for distributed systems Fallback strategies are essential for production readiness Document Intelligence Needs Multiple Layers Single-tool solutions aren't robust enough Combining specialized tools (LlamaParse + Gemini) improves accuracy Confidence scoring enables manual review workflows

### What's next

Mobile App Native iOS/Android apps for social workers Push notifications for case assignments Offline mode for areas with poor connectivity SMS Integration Text updates for patients without smartphones Bilingual support (English/Spanish) Two-way communication for confirmations

## README (from the GitHub repository)

# 🏥 CareLink

Empowering hospitals, shelters, transport services, and social workers through Fetch.ai agents, Bright Data intelligence, and Vapi voice coordination.

## 📁 Project Structure

```
calhacks12/
├── frontend/                 # Next.js Frontend
│   ├── src/
│   │   ├── app/             # Next.js App Router
│   │   └── components/      # React Components
│   ├── public/              # Static Assets
│   ├── package.json         # Frontend Dependencies
│   └── next.config.mjs      # Next.js Configuration
├── backend/                 # FastAPI Backend
│   ├── main.py             # FastAPI Application
│   ├── agents.py           # Fetch.ai Agents
│   ├── requirements.txt    # Python Dependencies
│   └── venv/               # Python Virtual Environment
├── package.json            # Root Package Management
├── start-dev.sh           # Development Startup Script
└── README.md              # This File
```

## 🏗️ Architecture

- **Frontend**: Next.js with TypeScript and Tailwind CSS
- **Backend**: FastAPI with Python
- **AI Agents**: Fetch.ai uAgents for coordination
- **Voice AI**: Vapi for voice communication
- **Data Intelligence**: Bright Data for real-time information
- **Maps**: Mapbox for interactive shelter mapping
- **UI/UX**: Framer Motion for smooth animations

## 💡 Problem

Every day, hospitals discharge unhoused patients with nowhere safe to go. Manual coordination between hospitals, shelters, transport providers, and social workers is slow, fragmented, and error-prone.

📊 Studies show that over 50–70% of homeless patients in U.S. hospitals are discharged to unsafe or unstable environments without a clear care plan.

## 💡 Solution — CareLink

CareLink is a decentralized, voice-enabled coordination system that connects hospitals, shelters, transport services, and social workers through Fetch.ai agents, Bright Data, and Vapi voice calls.

It automates discharge planning, verifies real shelter availability, arranges transportation, and connects social workers — all through a human-centered, AI-assisted workflow.

## 🧭 Vision

Ensure every unhoused patient leaving a hospital has:
- A verified shelter placement
- A coordinated transport route
- A connected social worker for continuity of care
- Access to basic post-discharge needs like meals, clothing, and medication

All orchestrated seamlessly through voice, automation, and community data.

## ⚙️ How It Works

### 🧠 Fetch.ai Multi-Agent Network

#### Core Coordination Agents
| Agent | Role | Port |
|-------|------|------|
| 🏥 HospitalAgent | Collects discharge details and starts coordination | 8001 |
| 🧭 CoordinatorAgent | Manages agent communication and Bright Data queries | 8002 |
| 🏠 ShelterAgent | Manages capacity info retrieved from Bright Data or voice calls | 8003 |
| 🚐 TransportAgent | Schedules transport and tracks progress | 8004 |
| 🧑‍🤝‍🧑 SocialWorkerAgent | Connects to follow-up care and approves placement | 8005 |
| ❤️ FollowUpCareAgent | Conducts post-discharge check-ins via voice | 8006 |

#### Specialized Service Agents
| Agent | Role | Port |
|-------|------|------|
| 📄 ParserAgent | Parses discharge documents with LlamaParse + Gemini to autofill intake | 8011 |
| 🥣 ResourceAgent | Coordinates food, hygiene kits, and clothing post-discharge | 8007 |
| 💊 PharmacyAgent | Ensures medication continuity via pharmacy coordination | 8008 |
| 🧾 EligibilityAgent | Automates benefit verification (Medi-Cal, GA, SNAP) | 8009 |
| 📊 AnalyticsAgent | Collects non-PII metrics for system optimization | 8010 |

**Agent Network Architecture:**
```
Parser → Hospital → Coordinator → [Shelter, Transport, SocialWorker, FollowUp]
                                        ↓           ↓            ↓
                                   [Resource, Pharmacy, Eligibility]
                                                  ↓
                                             Analytics
```

### 🌐 Bright Data Integration (Data Intelligence Layer)

Instead of relying on static or outdated lists, Bright Data continuously retrieves and refreshes real-world information such as:
- Live San Francisco shelter listings from HSH and other local sources
- Publicly available community resource databases (food banks, medical respite, outreach centers)
- Transport provider schedules (municipal and nonprofit)

### 🔊 Vapi Voice Integration

Vapi powers the human interaction layer — ensuring accessibility for shelters and social workers who rely on phone communication.

- **Shelter Availability Calls**: Vapi contacts shelters automatically each evening
- **Social Worker Outreach**: Vapi calls social workers to confirm patient assignments
- **Transport Coordination**: Calls transport providers to schedule patient pickup/drop-off
- **Follow-Up Calls**: Conducts post-discharge voice check-ins with patients

## 🚀 Quick Start

### Prerequisites

- Node.js 18+ 
- Python 3.9+
- Git

### Installation

1. **Clone the repository**
   ```bash
   git clone <repository-url>
   cd calhacks12
   ```

2. **Install dependencies**
   ```bash
   # Install frontend dependencies
   cd frontend && npm install && cd ..
   
   # Install backend dependencies
   cd backend && python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt && cd ..
   ```

3. **Set up environment variables**
   ```bash
   cp backend/env.example backend/.env
   # Edit backend/.env with your API keys
   ```

4. **Start the development servers**
   ```bash
   # Use the startup script (recommended)
   ./start-dev.sh
   
   # OR start manually:
   # Terminal 1: cd frontend && npm run dev
   # Terminal 2: cd backend && source venv/bin/activate && python main.py
   ```

This will start:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Fetch.ai Agents: Ports 8001-8011 (11 agents)

## 📦 Dependencies

### Backend (Python)
- **Framework**: FastAPI 0.120.0, Uvicorn 0.30.6
- **AI Agents**: uAgents 0.22.10, cosmpy 0.9.3
- **Document Parsing**: llama-parse 0.5.17, google-generativeai 0.8.3
- **HTTP/Async**: requests 2.32.5, httpx 0.28.1, aiohttp 3.13.1
- **Data**: pydantic 2.8.2, pydantic-settings 2.6.1
- **Database**: SQLAlchemy 2.0.25, Alembic 1.13.1
- **Testing**: pytest 8.3.3, pytest-asyncio 0.24.0, pytest-cov 5.0.0
- **Code Quality**: black 25.1.0, ruff 0.10.2, mypy 1.15.0

### Frontend (Node.js)
- **Framework**: Next.js 14.2.5, React 18.3.1, TypeScript 5.8.2
- **Maps**: Mapbox GL 3.6.0, react-map-gl 7.1.7
- **UI/Animation**: Framer Motion 11.5.0, Lucide React 0.400.0
- **Styling**: Tailwind CSS 3.4.1, PostCSS 8.4.38, Autoprefixer 10.4.21

## ✨ Key Features

### 📄 AI-Powered Document Parsing
- **Automatic form autofill** from discharge documents
- **LlamaParse integration** for accurate document extraction
- **Gemini AI** for intelligent data structuring
- **Confidence scoring** for parsed data quality
- **Manual review flagging** for low-confidence results

### 🗺️ Interactive Mapbox Integration
- **Real-time shelter mapping** with Mapbox GL JS
- **Dynamic markers** showing shelter availability
- **Interactive popups** with detailed shelter information
- **Live workflow tracking** on the map
- **Responsive design** for all screen sizes

### 🤖 Animated Fetch.ai Agent Dashboard
- **Real-time agent status** with live progress bars
- **Animated workflow timeline** showing step-by-step progress
- **Agent communication logs** with message history
- **Visual indicators** for agent states (idle, working, completed, error)
- **Interactive agent selection** to view detailed activity

### 🎨 Modern UI/UX
- **Smooth animations** powered by Framer Motion
- **Responsive design** with Tailwind CSS
- **Interactive components** with hover effects
- **Real-time updates** without page refresh
- **Accessible design** following WCAG guidelines

## 🧱 Tech Stack

| Layer | Technology | Purpose |
|-------|------------|---------|
| AI Agents | Fetch.ai uAgents | Decentralized, autonomous coordinati

[README truncated for size]

## Detected evidence (automated analysis)

Indexed codebase: 77 recognized source files, 971 KB.
- CSS (language) — detected in the code
- FastAPI (technology) — detected in the code
- JavaScript (language) — detected in the code
- Next.js (technology) — detected in the code
- Python (language) — detected in the code
- React (technology) — detected in the code
- SQL (language) — detected in the code
- Supabase (technology) — detected in the code
- Tailwind CSS (technology) — detected in the code
- TypeScript (language) — detected in the code
- Google Gemini (technology) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (110 of 110)

```
.gitignore
backend/.env.example
backend/.gitignore
backend/agent_conversations_1761472395.json
backend/agent_conversations_1761473119.json
backend/agents/__init__.py
backend/agents/agent_conversations_1761472157.json
backend/agents/agent_conversations_1761472186.json
backend/agents/agent_conversations_1761472214.json
backend/agents/agent_conversations_1761472349.json
backend/agents/agent_conversations_1761472438.json
backend/agents/agent_registry.py
backend/agents/analytics_agent.py
backend/agents/coordinator_agent.py
backend/agents/eligibility_agent.py
backend/agents/fetchai_agent_communication.py
backend/agents/models.py
backend/agents/parser_agent.py
backend/agents/pharmacy_agent.py
backend/agents/pharmacy_database.json
backend/agents/README.md
backend/agents/resource_agent.py
backend/agents/run_all.py
backend/agents/shelter_agent.py
backend/agents/social_worker_agent.py
backend/agents/transport_agent.py
backend/brightdata_integration.py
backend/case_manager.py
backend/complete_workflow_logs_1761469562.json
backend/conversation_logs_CONVERSATION_TEST_1761467238.json
backend/database.py
backend/env.local.example
backend/find_free_ports.py
backend/gemini_integration.py
backend/hospital_pharmacy_inventory.json
backend/init_database.py
backend/init_json_database.py
backend/json_database.py
backend/live_conversation_logs_LIVE_CONVERSATION_1761467309.json
backend/local_database.py
backend/main_workflow_logs_1761469812.json
backend/main.py
backend/migrate_to_local_postgres.py
backend/MIGRATION_TO_LOCAL_POSTGRES.md
backend/package.json
backend/real_agent_coordination.py
backend/real_workflow_logs_1761471074.json
backend/requirements.txt
backend/setup_local_postgres.sh
backend/setup_project.py
backend/start_agents.sh
backend/start_backend.sh
backend/start_frontend.sh
backend/supabase_client.py
backend/supabase_database.py
backend/test_agent_communication_simple.py
backend/test_agent_conversations.py
backend/test_json_database.py
backend/vapi_integration_demo.py
backend/vapi_integration.py
coderabbit.yml
data/benefits.json
data/cases.json
data/resources.json
data/shelters.json
data/transport.json
data/workflows.json
database/cases_schema.sql
database/supabase_schema.sql
frontend/.gitignore
frontend/env.local.example
frontend/eslint.config.mjs
frontend/next.config.mjs
frontend/next.config.ts
frontend/package.json
frontend/postcss.config.mjs
frontend/setup-env.sh
frontend/src/app/debug-simple/page.tsx
frontend/src/app/debug/page.tsx
frontend/src/app/globals.css
frontend/src/app/layout.tsx
frontend/src/app/page.tsx
frontend/src/components/AgentMapBox.tsx
frontend/src/components/CaseSummary.tsx
frontend/src/components/CaseWorkflowInterface.tsx
frontend/src/components/Dashboard.tsx
frontend/src/components/DebugDischargeIntake.tsx
frontend/src/components/DischargeIntake.tsx
frontend/src/components/DischargePlan.tsx
frontend/src/components/FinalizedReport.tsx
frontend/src/components/Header.tsx
frontend/src/components/LoadingScreen.tsx
frontend/src/components/MapView.tsx
frontend/src/components/SimplePatientForm.tsx
frontend/src/components/TransportTracker.tsx
frontend/src/components/WorkflowList.tsx
frontend/src/components/WorkflowTimeline.tsx
frontend/src/utils/mockData.ts
frontend/tailwind.config.js
frontend/tsconfig.json
README.md
start-dev.sh
VAPI_ASSISTANT_CONFIG.md
VAPI_BOT_CONFIGURATION.md
VAPI_DEMO_SETUP.md
VAPI_SETUP_INSTRUCTIONS.md
VAPI_SHELTER_AGENT_PROMPT.md
verify-setup.sh
WORKFLOW_DELETE_IMPLEMENTATION.md
YOUR_SETUP_CHECKLIST.md
```

### Dependencies

- backend/requirements.txt: aiohttp@>=3.13.1, alembic@>=1.13.1, black@>=25.1.0, cosmpy@>=0.9.2, fastapi@>=0.120.0, google-generativeai@>=0.8.5, httpx@>=0.26,<0.29, llama-parse@>=0.5.17, mypy@>=1.15.0, ngrok@>=1.4.0, playwright@>=1.49.0, pydantic@>=2.8.2, pydantic-settings@>=2.6.1, pytest@>=8.3.3, pytest-asyncio@>=0.24.0, pytest-cov@>=5.0.0, python-dotenv@>=1.1.1, python-multipart@>=0.0.20, requests@>=2.32.5, ruff@>=0.14.2, sqlalchemy@>=2.0.36, supabase@>=2.22.2, uagents@>=0.22.0, uvicorn[standard]@>=0.30.6, websockets@>=15.0.1
- frontend/package.json: @types/node@^22.13.0, @types/react@^18.3.15, @types/react-dom@^18.3.5, @types/react-map-gl@^6.1.7, autoprefixer@^10.4.21, clsx@^2.1.0, eslint@^8.57.0, eslint-config-next@14.2.5, framer-motion@^11.5.0, lucide-react@^0.400.0, mapbox-gl@^3.6.0, next@14.2.5, postcss@^8.4.38, react@^18.3.1, react-dom@^18.3.1, react-map-gl@^7.1.7, tailwind-merge@^2.2.0, tailwindcss@^3.4.1, typescript@^5.8.2

### Recent commits (newest first)

- last commit
- Resolve merge conflict in shelter_agent.py - keep working Vapi integration
- get this alvin pls
- VAPI shelter calling
- fix saving
- fix
- agent workflow update
- work pls
- alvin
- bright data parsing, supabase
- get this alvin
- parser agent
- new agents
- get this pls
- fix tracking
- second push
- initial

## Key source files (fetched from GitHub, selected and truncated for size)

### VAPI_ASSISTANT_CONFIG.md

```markdown
# Vapi Assistant Configuration

## System Prompt
```
You are calling as a CareLink representative from the hospital. You have a homeless patient being discharged tonight and need to verify shelter availability and services.

Your goal is to gather this information:
1. How many beds are available tonight
2. If they can accommodate a homeless person with medical needs
3. What accessibility features they have (wheelchair access, etc.)
4. What services they provide (meals, showers, medical support)
5. If they can accept the patient for tonight

Instructions:
- Be professional, patient, and listen to their responses
- Ask ONE question at a time and wait for their answer
- If they say they're busy or can't talk, ask if there's a better time to call
- Once you have the key information (beds available, accessibility, services), thank them and end the call
- If they say "goodbye", "bye", "thank you", "that's all", "we're all set", or "sounds good", immediately say your closing message and end the call

Closing message: "Thank you for your time and information. We'll coordinate the patient's arrival. Have a good day!"

Remember: Keep the conversation focused and end it once you have the essential information.
```

## First Message
```
Hello, this is CareLink calling from the hospital. We have a homeless patient being discharged tonight and need to check if you have available beds and can accommodate them. Do you have a moment to discuss capacity and services?
```

## End Call Phrases
- "goodbye"
- "bye" 
- "thank you"
- "that's all"
- "have a good day"
- "we're all set"
- "sounds good"

## End Call Message
```
Thank you for your time and information. We'll coordinate the patient's arrival. Have a good day!
```

## Additional Settings
- **Max Duration**: 600 seconds (10 minutes)
- **Voice**: Elliot
- **Model**: GPT-4o
- **Interruptible**: Yes
- **Silence Timeout**: 30 seconds

```

### VAPI_BOT_CONFIGURATION.md

```markdown
# Vapi Bot Configuration for CareLink Project

## System Prompt
```
You are calling as a CareLink representative from San Francisco General Hospital. You have a homeless patient being discharged tonight and need to verify shelter availability and services.

Your goal is to gather this information:
1. How many beds are available tonight
2. If they can accommodate a homeless person with medical needs
3. What accessibility features they have (wheelchair access, etc.)
4. What services they provide (meals, showers, medical support)
5. If they can accept the patient for tonight

Instructions:
- Be professional, patient, and listen to their responses
- Ask ONE question at a time and wait for their answer
- If they say they're busy or can't talk, ask if there's a better time to call
- Once you have the key information (beds available, accessibility, services), thank them and end the call
- If they say "goodbye", "bye", "thank you", "that's all", "we're all set", or "sounds good", immediately say your closing message and end the call

Closing message: "Thank you for your time and information. We'll coordinate the patient's arrival. Have a good day!"

Remember: Keep the conversation focused and end it once you have the essential information.
```

## First Message
```
Hello, this is CareLink calling from San Francisco General Hospital. We have a homeless patient being discharged tonight and need to check if you have available beds and can accommodate them. Do you have a moment to discuss capacity and services?
```

## End Call Phrases
- "goodbye"
- "bye" 
- "thank you"
- "that's all"
- "have a good day"
- "we're all set"
- "sounds good"

## End Call Message
```
Thank you for your time and information. We'll coordinate the patient's arrival. Have a good day!
```

## Additional Settings
- **Max Duration**: 600 seconds (10 minutes)
- **Voice**: Elliot
- **Model**: GPT-4o
- **Interruptible**: Yes
- **Silence Timeout**: 30 seconds

```

### backend/requirements.txt

```
# FastAPI and server
fastapi>=0.120.0
uvicorn[standard]>=0.30.6
python-multipart>=0.0.20

# Data validation
pydantic>=2.8.2
pydantic-settings>=2.6.1

# Environment and config
python-dotenv>=1.1.1

# HTTP requests
requests>=2.32.5
httpx>=0.26,<0.29
aiohttp>=3.13.1

# Fetch.ai uAgents (use latest compatible version)
uagents>=0.22.0
cosmpy>=0.9.2

# WebSockets
websockets>=15.0.1

# Web Scraping
playwright>=1.49.0

# Database
sqlalchemy>=2.0.36
alembic>=1.13.1
supabase>=2.22.2

# ngrok for webhooks
ngrok>=1.4.0

# Testing
pytest>=8.3.3
pytest-asyncio>=0.24.0
pytest-cov>=5.0.0

# Code quality
black>=25.1.0
ruff>=0.14.2
mypy>=1.15.0

# Document parsing
llama-parse>=0.5.17
google-generativeai>=0.8.5

```

### frontend/package.json

```
{
  "name": "carelink-frontend",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "type-check": "tsc --noEmit"
  },
  "dependencies": {
    "next": "14.2.5",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "framer-motion": "^11.5.0",
    "lucide-react": "^0.400.0",
    "mapbox-gl": "^3.6.0",
    "react-map-gl": "^7.1.7",
    "clsx": "^2.1.0",
    "tailwind-merge": "^2.2.0",
    "tailwindcss": "^3.4.1",
    "autoprefixer": "^10.4.21",
    "postcss": "^8.4.38"
  },
  "devDependencies": {
    "@types/node": "^22.13.0",
    "@types/react": "^18.3.15",
    "@types/react-dom": "^18.3.5",
    "@types/react-map-gl": "^6.1.7",
    "typescript": "^5.8.2",
    "eslint": "^8.57.0",
    "eslint-config-next": "14.2.5"
  }
}

```

### backend/package.json

```
{
  "name": "carelink-backend",
  "version": "1.0.0",
  "description": "CareLink Backend API - FastAPI with Fetch.ai agents",
  "private": true,
  "scripts": {
    "dev": "source venv/bin/activate && python main.py",
    "start": "source venv/bin/activate && uvicorn main:app --host 0.0.0.0 --port 8000",
    "install": "python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt",
    "test": "source venv/bin/activate && python -m pytest",
    "lint": "source venv/bin/activate && flake8 .",
    "format": "source venv/bin/activate && black .",
    "agents": "source venv/bin/activate && python agents.py"
  },
  "keywords": [
    "fastapi",
    "python",
    "healthcare",
    "agents",
    "fetchai",
    "vapi",
    "brightdata"
  ],
  "author": "CareLink Team",
  "license": "MIT",
  "engines": {
    "python": ">=3.9.0"
  }
}

```

### frontend/src/app/layout.tsx

```typescript
import type { Metadata } from "next";
import "./globals.css";

export const metadata: Metadata = {
  title: "CareLink - Healthcare Coordination Platform",
  description: "Empowering hospitals, shelters, transport services, and social workers through AI coordination",
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body className="antialiased">
        {children}
      </body>
    </html>
  );
}

```

### frontend/src/app/page.tsx

```typescript
"use client";

import { useState, useEffect } from "react";
import Dashboard from "@/components/Dashboard";
import Header from "@/components/Header";

export default function Home() {
  const [activeView, setActiveView] = useState<"dashboard" | "intake" | "timeline" | "map" | "report">("dashboard");

  useEffect(() => {
    // Listen for navigation to report
    const handleNavigateToReport = () => {
      setActiveView("report");
    };

    window.addEventListener('navigateToReport', handleNavigateToReport);
    
    return () => {
      window.removeEventListener('navigateToReport', handleNavigateToReport);
    };
  }, []);

  return (
    <div className="min-h-screen relative">
      <Header />
      <main className="container mx-auto px-6 py-12">
        <Dashboard activeView={activeView} setActiveView={setActiveView} />
      </main>
    </div>
  );
}

```

### frontend/src/app/debug-simple/page.tsx

```typescript
import SimplePatientForm from "@/components/SimplePatientForm";

export default function DebugSimplePage() {
  return (
    <div className="min-h-screen bg-gray-50">
      <SimplePatientForm />
    </div>
  );
}

```

### frontend/src/app/debug/page.tsx

```typescript
"use client";

import React from "react";
import DebugDischargeIntake from "@/components/DebugDischargeIntake";

export default function DebugPage() {
  return (
    <div className="min-h-screen bg-gray-50">
      <DebugDischargeIntake />
    </div>
  );
}

```

### coderabbit.yml

```yaml
# Configuration for development teams
language: "en-US"

# Reviews configuration
reviews:
  profile: "chill"
  high_level_summary: true
  auto_review:
    enabled: true
    drafts: false
    base_branches: ['.*']
    ignore_title_keywords:
      - "wip"
      - "draft"
  
  # Tools configuration
  tools:
    # Linting tools
    eslint:
      enabled: true
    ruff:
      enabled: true
    gitleaks:
      enabled: true
    hadolint:
      enabled: true
    # Abstract Syntax Tree (AST) based rules
    ast-grep:
      essential_rules: true
      rule_dirs:
        - "rules"
  
  pre_merge_checks:
    docstrings:
      mode: "error"
      threshold: 85
    title:
      mode: "warning"
      requirements: "Start with an imperative verb; keep under 50 characters."
    description:
      mode: "error"
    issue_assessment:
      mode: "warning"
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: "Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the Breaking Change section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal)."

# Chat configuration
chat:
  auto_reply: true

# Knowledge base configuration
knowledge_base:
  code_guidelines:
    enabled: true
    filePatterns:
      - "**/.cursorrules"
      - "**/CODING_STANDARDS.md"

  path_filters:
    - "!**/*.lock"
    - "!**/node_modules/**"
    - "!**/venv/**"
    - "!**/__pycache__/**"
    - "!**/dist/**"
    - "!**/build/**"
    - "!**/data/**"
  
  path_instructions:
    - path: "backend/**/*.py"
      instructions: "Review Python code for SQL injection, hardcoded secrets, and empty except blocks"
    - path: "frontend/**/*.tsx"
      instructions: "Review TypeScript code for hardcoded secrets, empty catch blocks, and performance issues"
    - path: "frontend/**/*.ts"
      instructions: "Review TypeScript code for security and performance issues"

```

[64 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]