# hardikghori/babybot architecture

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

- Interactive diagram: https://gitdiagram.com/hardikghori/babybot
- Repository: https://github.com/hardikghori/babybot

## Overview

BabyBot is a local web app for maintaining baby profiles and requesting age-based health advice. The principal workflow is browser interaction with the GraphQL endpoint, whose resolvers either read/write baby records or produce advice; advice currently uses the OpenRouter-backed response module when the LLM path is enabled. The README describes the app as local-first with no external APIs, which conflicts with the sampled implementation. The frontend source was not sampled, so its specific requests and rendering flow are not shown.

Main entry points: [`app/main.py`](https://github.com/hardikghori/babybot/blob/main/app/main.py) (FastAPI entry), [`app/resolvers.py`](https://github.com/hardikghori/babybot/blob/main/app/resolvers.py) (GraphQL resolvers), [`app/models.py`](https://github.com/hardikghori/babybot/blob/main/app/models.py) (Baby model), [`public/index.html`](https://github.com/hardikghori/babybot/blob/main/public/index.html) (Web UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web_ui["Web UI<br/>[index.html]"]
end

subgraph group_api["GraphQL API"]
  node_graphql_schema["GraphQL schema<br/>[schema.graphql]"]
  node_fastapi["FastAPI entry<br/>[main.py]"]
end

subgraph group_domain["Profiles and advice"]
  node_resolvers["GraphQL resolvers<br/>[resolvers.py]"]
  node_baby_model["Baby model<br/>[models.py]"]
  node_llm_adapter["Advice adapter<br/>[simulate_llm.py]"]
end

subgraph group_infra["Persistence and integration"]
  node_sqlite[("SQLite database<br/>[models.py]")]
end

node_caregiver(("Caregiver"))
node_openrouter{{"OpenRouter API"}}

node_caregiver -->|"uses"| node_web_ui
node_web_ui -->|"GraphQL requests"| node_fastapi
node_fastapi -->|"loads schema"| node_graphql_schema
node_fastapi -->|"dispatches fields"| node_resolvers
node_fastapi -->|"creates tables"| node_baby_model
node_resolvers -->|"queries and mutates"| node_baby_model
node_baby_model -->|"reads and writes"| node_sqlite
node_resolvers -->|"requests advice"| node_llm_adapter
node_llm_adapter -->|"sends prompt"| node_openrouter

click node_web_ui "https://github.com/hardikghori/babybot/blob/main/public/index.html"
click node_graphql_schema "https://github.com/hardikghori/babybot/blob/main/app/schema.graphql"
click node_fastapi "https://github.com/hardikghori/babybot/blob/main/app/main.py"
click node_resolvers "https://github.com/hardikghori/babybot/blob/main/app/resolvers.py"
click node_baby_model "https://github.com/hardikghori/babybot/blob/main/app/models.py"
click node_sqlite "https://github.com/hardikghori/babybot/blob/main/app/models.py"
click node_llm_adapter "https://github.com/hardikghori/babybot/blob/main/app/simulate_llm.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_web_ui toneBlue
class node_graphql_schema,node_fastapi toneAmber
class node_resolvers,node_baby_model,node_llm_adapter,node_openrouter toneMint
class node_sqlite toneRose
class node_caregiver toneIndigo
```

## Components

### Web client

- [Web UI](https://github.com/hardikghori/babybot/blob/main/public/index.html): `public/index.html`

### GraphQL API

- [GraphQL schema](https://github.com/hardikghori/babybot/blob/main/app/schema.graphql): `app/schema.graphql`
- [FastAPI entry](https://github.com/hardikghori/babybot/blob/main/app/main.py): `app/main.py`

### Profiles and advice

- [GraphQL resolvers](https://github.com/hardikghori/babybot/blob/main/app/resolvers.py): `app/resolvers.py`
- [Baby model](https://github.com/hardikghori/babybot/blob/main/app/models.py): `app/models.py`
- [Advice adapter](https://github.com/hardikghori/babybot/blob/main/app/simulate_llm.py): `app/simulate_llm.py`

### Persistence and integration

- [SQLite database](https://github.com/hardikghori/babybot/blob/main/app/models.py): `app/models.py`

### Other components

- **Caregiver**
- **OpenRouter API**

## Connections

- Caregiver → Web UI: uses
- Web UI → FastAPI entry: GraphQL requests
- FastAPI entry → GraphQL schema: loads schema
- FastAPI entry → GraphQL resolvers: dispatches fields
- FastAPI entry → Baby model: creates tables
- GraphQL resolvers → Baby model: queries and mutates
- Baby model → SQLite database: reads and writes
- GraphQL resolvers → Advice adapter: requests advice
- Advice adapter → OpenRouter API: sends prompt
