# farheenaiml/nurtureai architecture

> Architecture diagram of the GitHub repository farheenaiml/nurtureai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/farheenaiml/nurtureai
- Repository: https://github.com/farheenaiml/nurtureai

## Overview

NurtureAI is a maternity and health companion whose main workflow takes a user’s text or voice question through a web interface to an AI service, where a planner selects a specialist, guideline retrieval supplies context, and a critic reviews the draft before a response is returned. The application also includes pregnancy and postpartum tracking, nutrition, symptoms, and account features. README documentation describes capabilities beyond the sampled code; links for those are cited to the README rather than treated as source-inspected.

Main entry points: [`src/routes/app.ai-assistant.tsx`](https://github.com/farheenaiml/nurtureai/blob/main/src/routes/app.ai-assistant.tsx) (AI chat interface), [`agents/main.py`](https://github.com/farheenaiml/nurtureai/blob/main/agents/main.py) (AI backend), [`src/routes/app.index.tsx`](https://github.com/farheenaiml/nurtureai/blob/main/src/routes/app.index.tsx) (Maternity dashboard), [`src/backend/aiServer.ts`](https://github.com/farheenaiml/nurtureai/blob/main/src/backend/aiServer.ts) (AI request service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_dashboard["Maternity dashboard<br/>[app.index.tsx]"]
  node_care_pages["Care tracking pages"]
  node_nutrition_page["Nutrition tracking<br/>[app.nutrition.tsx]"]
  node_pregnancy_page["Pregnancy journey<br/>[app.pregnancy.tsx]"]
  node_chat_page["AI chat interface"]
  node_voice_mode["Voice mode<br/>[VoiceMode.tsx]"]
end

subgraph group_services["Application services"]
  node_auth_store["Account state<br/>[authStore.ts]"]
  node_auth_server["Authentication service<br/>[authServer.ts]"]
  node_postgres[("PostgreSQL")]
  node_ai_server["AI request service<br/>[aiServer.ts]"]
  node_mock_fallback["Fallback responses<br/>[mockFallback.ts]"]
  node_mock_data["Application data<br/>[mockData.ts]"]
end

subgraph group_agents["AI agent workflow"]
  node_fastapi["AI backend<br/>[main.py]"]
  node_planner["Query planner<br/>[planner_agent.py]"]
  node_specialists["Domain specialists"]
  node_critic["Safety critic<br/>[critic_agent.py]"]
end

subgraph group_knowledge["Guideline retrieval"]
  node_retriever["Context retriever<br/>[retriever.py]"]
  node_embeddings["Query embeddings<br/>[embeddings.py]"]
  node_vector_store[("ChromaDB store<br/>[vector_store.py]")]
  node_ingestion["Guideline ingestion<br/>[ingest.py]"]
end

subgraph group_voice["Voice processing"]
  node_voice_routes["Voice endpoints<br/>[routes.py]"]
  node_stt["Speech recognition<br/>[speech_to_text.py]"]
  node_tts["Speech synthesis<br/>[text_to_speech.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_dashboard
node_user -->|"asks questions"| node_chat_page
node_dashboard -.->|"opens care tools"| node_care_pages
node_chat_page -->|"sends prompt"| node_ai_server
node_chat_page -->|"offers voice mode"| node_voice_mode
node_chat_page -->|"reads questions"| node_mock_data
node_dashboard -->|"reads dashboard data"| node_mock_data
node_nutrition_page -->|"reads nutrition data"| node_mock_data
node_pregnancy_page -->|"reads profile"| node_auth_store
node_auth_store -->|"calls account actions"| node_auth_server
node_auth_server -->|"reads and writes"| node_postgres
node_ai_server -->|"forwards AI requests"| node_fastapi
node_ai_server -->|"uses fallback"| node_mock_fallback
node_fastapi -->|"routes query"| node_planner
node_fastapi -->|"dispatches query"| node_specialists
node_fastapi -->|"reviews draft"| node_critic
node_specialists -->|"retrieves context"| node_retriever
node_retriever -->|"embeds query"| node_embeddings
node_retriever -->|"queries collection"| node_vector_store
node_ingestion -->|"stores guideline chunks"| node_vector_store
node_voice_mode -->|"uses voice endpoints"| node_voice_routes
node_voice_routes -->|"transcribes audio"| node_stt
node_voice_routes -->|"generates speech"| node_tts

click node_dashboard "https://github.com/farheenaiml/nurtureai/blob/main/src/routes/app.index.tsx"
click node_care_pages "https://github.com/farheenaiml/nurtureai/tree/main/src/routes"
click node_nutrition_page "https://github.com/farheenaiml/nurtureai/blob/main/src/routes/app.nutrition.tsx"
click node_pregnancy_page "https://github.com/farheenaiml/nurtureai/blob/main/src/routes/app.pregnancy.tsx"
click node_chat_page "https://github.com/farheenaiml/nurtureai/blob/main/src/routes/app.ai-assistant.tsx"
click node_voice_mode "https://github.com/farheenaiml/nurtureai/blob/main/src/components/ai/VoiceMode.tsx"
click node_auth_store "https://github.com/farheenaiml/nurtureai/blob/main/src/store/authStore.ts"
click node_auth_server "https://github.com/farheenaiml/nurtureai/blob/main/src/backend/authServer.ts"
click node_ai_server "https://github.com/farheenaiml/nurtureai/blob/main/src/backend/aiServer.ts"
click node_mock_fallback "https://github.com/farheenaiml/nurtureai/blob/main/src/backend/mockFallback.ts"
click node_mock_data "https://github.com/farheenaiml/nurtureai/blob/main/src/services/mockData.ts"
click node_fastapi "https://github.com/farheenaiml/nurtureai/blob/main/agents/main.py"
click node_planner "https://github.com/farheenaiml/nurtureai/blob/main/agents/planner_agent.py"
click node_specialists "https://github.com/farheenaiml/nurtureai/tree/main/agents"
click node_critic "https://github.com/farheenaiml/nurtureai/blob/main/agents/critic_agent.py"
click node_retriever "https://github.com/farheenaiml/nurtureai/blob/main/agents/rag/retriever.py"
click node_embeddings "https://github.com/farheenaiml/nurtureai/blob/main/agents/rag/embeddings.py"
click node_vector_store "https://github.com/farheenaiml/nurtureai/blob/main/agents/rag/vector_store.py"
click node_ingestion "https://github.com/farheenaiml/nurtureai/blob/main/agents/rag/ingest.py"
click node_voice_routes "https://github.com/farheenaiml/nurtureai/blob/main/agents/voice/routes.py"
click node_stt "https://github.com/farheenaiml/nurtureai/blob/main/agents/voice/speech_to_text.py"
click node_tts "https://github.com/farheenaiml/nurtureai/blob/main/agents/voice/text_to_speech.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_care_pages,node_nutrition_page,node_pregnancy_page,node_chat_page,node_voice_mode,node_user toneBlue
class node_auth_store,node_auth_server,node_postgres,node_ai_server,node_mock_fallback,node_mock_data toneAmber
class node_fastapi,node_planner,node_specialists,node_critic toneMint
class node_retriever,node_embeddings,node_vector_store,node_ingestion toneRose
class node_voice_routes,node_stt,node_tts toneIndigo
```

## Components

### Web experience

- [Maternity dashboard](https://github.com/farheenaiml/nurtureai/blob/main/src/routes/app.index.tsx): `src/routes/app.index.tsx`
- [Care tracking pages](https://github.com/farheenaiml/nurtureai/tree/main/src/routes): `src/routes`
- [Nutrition tracking](https://github.com/farheenaiml/nurtureai/blob/main/src/routes/app.nutrition.tsx): `src/routes/app.nutrition.tsx`
- [Pregnancy journey](https://github.com/farheenaiml/nurtureai/blob/main/src/routes/app.pregnancy.tsx): `src/routes/app.pregnancy.tsx`
- [AI chat interface](https://github.com/farheenaiml/nurtureai/blob/main/src/routes/app.ai-assistant.tsx): `src/routes/app.ai-assistant.tsx`
- [Voice mode](https://github.com/farheenaiml/nurtureai/blob/main/src/components/ai/VoiceMode.tsx): `src/components/ai/VoiceMode.tsx`

### Application services

- [Account state](https://github.com/farheenaiml/nurtureai/blob/main/src/store/authStore.ts): `src/store/authStore.ts`
- [Authentication service](https://github.com/farheenaiml/nurtureai/blob/main/src/backend/authServer.ts): `src/backend/authServer.ts`
- **PostgreSQL**
- [AI request service](https://github.com/farheenaiml/nurtureai/blob/main/src/backend/aiServer.ts): `src/backend/aiServer.ts`
- [Fallback responses](https://github.com/farheenaiml/nurtureai/blob/main/src/backend/mockFallback.ts): `src/backend/mockFallback.ts`
- [Application data](https://github.com/farheenaiml/nurtureai/blob/main/src/services/mockData.ts): `src/services/mockData.ts`

### AI agent workflow

- [AI backend](https://github.com/farheenaiml/nurtureai/blob/main/agents/main.py): `agents/main.py`
- [Query planner](https://github.com/farheenaiml/nurtureai/blob/main/agents/planner_agent.py): `agents/planner_agent.py`
- [Domain specialists](https://github.com/farheenaiml/nurtureai/tree/main/agents): `agents`
- [Safety critic](https://github.com/farheenaiml/nurtureai/blob/main/agents/critic_agent.py): `agents/critic_agent.py`

### Guideline retrieval

- [Context retriever](https://github.com/farheenaiml/nurtureai/blob/main/agents/rag/retriever.py): `agents/rag/retriever.py`
- [Query embeddings](https://github.com/farheenaiml/nurtureai/blob/main/agents/rag/embeddings.py): `agents/rag/embeddings.py`
- [ChromaDB store](https://github.com/farheenaiml/nurtureai/blob/main/agents/rag/vector_store.py): `agents/rag/vector_store.py`
- [Guideline ingestion](https://github.com/farheenaiml/nurtureai/blob/main/agents/rag/ingest.py): `agents/rag/ingest.py`

### Voice processing

- [Voice endpoints](https://github.com/farheenaiml/nurtureai/blob/main/agents/voice/routes.py): `agents/voice/routes.py`
- [Speech recognition](https://github.com/farheenaiml/nurtureai/blob/main/agents/voice/speech_to_text.py): `agents/voice/speech_to_text.py`
- [Speech synthesis](https://github.com/farheenaiml/nurtureai/blob/main/agents/voice/text_to_speech.py): `agents/voice/text_to_speech.py`

### Other components

- **User**

## Connections

- User → Maternity dashboard: uses
- User → AI chat interface: asks questions
- Maternity dashboard → Care tracking pages: opens care tools
- AI chat interface → AI request service: sends prompt (evidence: `src/routes/app.ai-assistant.tsx`)
- AI chat interface → Voice mode: offers voice mode (evidence: `src/routes/app.ai-assistant.tsx`)
- AI chat interface → Application data: reads questions (evidence: `src/routes/app.ai-assistant.tsx`)
- Maternity dashboard → Application data: reads dashboard data (evidence: `src/routes/app.index.tsx`)
- Nutrition tracking → Application data: reads nutrition data (evidence: `src/routes/app.nutrition.tsx`)
- Pregnancy journey → Account state: reads profile (evidence: `src/routes/app.pregnancy.tsx`)
- Account state → Authentication service: calls account actions (evidence: `src/store/authStore.ts`)
- Authentication service → PostgreSQL: reads and writes (evidence: `src/backend/authServer.ts`)
- AI request service → AI backend: forwards AI requests
- AI request service → Fallback responses: uses fallback (evidence: `src/backend/aiServer.ts`)
- AI backend → Query planner: routes query (evidence: `agents/main.py`)
- AI backend → Domain specialists: dispatches query (evidence: `agents/main.py`)
- AI backend → Safety critic: reviews draft (evidence: `agents/main.py`)
- Domain specialists → Context retriever: retrieves context (evidence: `agents/emergency_agent.py`)
- Context retriever → Query embeddings: embeds query (evidence: `agents/rag/retriever.py`)
- Context retriever → ChromaDB store: queries collection (evidence: `agents/rag/retriever.py`)
- Guideline ingestion → ChromaDB store: stores guideline chunks (evidence: `agents/rag/ingest.py`)
- Voice mode → Voice endpoints: uses voice endpoints
- Voice endpoints → Speech recognition: transcribes audio (evidence: `agents/voice/routes.py`)
- Voice endpoints → Speech synthesis: generates speech (evidence: `agents/voice/routes.py`)
