# linhtran00/nest-guard architecture

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

- Interactive diagram: https://gitdiagram.com/linhtran00/nest-guard
- Repository: https://github.com/linhtran00/nest-guard

## Overview

NestGuard is a homeowner risk-assessment app: users enter home details, the frontend submits them for scoring, and the dashboard presents risk categories and ranked mitigation tips. The FastAPI endpoint geocodes the address, enriches it with FEMA hazard data, optionally classifies reported events, then assembles a score response. The React app also provides category details, a house visualization, live weather alerts, and settings. The principal workflow is documented and visible in the endpoint and app excerpts; unsampled page internals and external-service wiring are represented only where documented.

Main entry points: [`frontend/src/App.jsx`](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/App.jsx) (App Flow), [`backend/main.py`](https://github.com/linhtran00/nest-guard/blob/main/backend/main.py) (Score API), [`frontend/src/pages/Dashboard.jsx`](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/Dashboard.jsx) (Risk Dashboard), [`frontend/src/lib/riskColor.js`](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/lib/riskColor.js) (Risk Color Helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Homeowner Experience"]
  node_intake["Home Intake<br/>[IntakeForm.jsx]"]
  node_app["App Flow<br/>[App.jsx]"]
  node_dashboard["Risk Dashboard<br/>[Dashboard.jsx]"]
  node_risk_gauge["Risk Gauge<br/>[risk-gauge.jsx]"]
  node_settings["Settings<br/>[Settings.jsx]"]
end

subgraph group_assessment["Risk Assessment"]
  node_score_api["Score API<br/>[main.py]"]
  node_home_schema["Home and Score Schemas<br/>[schemas.py]"]
  node_risk_engine["Risk Scoring<br/>[risk.py]"]
end

subgraph group_enrichment["Location and Events"]
  node_geocoding["Address Geocoding<br/>[geo.py]"]
  node_fema["FEMA Hazards<br/>[fema.py]"]
  node_fema_service["FEMA Data Service"]
  node_event_classifier["Event Classification<br/>[ai.py]"]
  node_weather_api["Weather API Client<br/>[weatherApi.js]"]
end

subgraph group_insights["Risk Insights"]
  node_risk_colors["Risk Color Helpers<br/>[riskColor.js]"]
  node_category_details["Category Details"]
  node_detail_shell["Detail Wrapper<br/>[DetailShell.jsx]"]
  node_house_map["Home Map<br/>[HouseMap.jsx]"]
  node_house_viz["House Visualization"]
  node_tips["Action Tips<br/>[TipsPage.jsx]"]
  node_alerts["Live Weather Alerts<br/>[LiveAlerts.jsx]"]
end

node_homeowner(("Homeowner"))
node_ai_service["AI Provider"]
node_weather_service["Weather Service"]

node_homeowner -->|"enters home details"| node_intake
node_intake -->|"submits assessment"| node_app
node_app -->|"requests score"| node_score_api
node_score_api -->|"validates input"| node_home_schema
node_score_api -->|"geocodes address"| node_geocoding
node_score_api -->|"fetches hazards"| node_fema
node_fema -.->|"requests hazard data"| node_fema_service
node_score_api -->|"classifies events"| node_event_classifier
node_event_classifier -.->|"uses AI classification"| node_ai_service
node_score_api -->|"scores home"| node_risk_engine
node_risk_engine -->|"assembles response"| node_home_schema
node_app -->|"shows results"| node_dashboard
node_dashboard -->|"renders score"| node_risk_gauge
node_dashboard -->|"opens category"| node_category_details
node_category_details -->|"uses shared wrapper"| node_detail_shell
node_dashboard -->|"shows actions"| node_tips
node_dashboard -->|"formats risk levels"| node_risk_colors
node_risk_gauge -->|"colors score"| node_risk_colors
node_app -->|"opens home map"| node_house_map
node_house_map -->|"renders house"| node_house_viz
node_house_viz -->|"colors risk"| node_risk_colors
node_app -->|"opens alerts"| node_alerts
node_alerts -->|"loads local weather"| node_weather_api
node_weather_api -.->|"requests forecast"| node_weather_service
node_app -->|"opens settings"| node_settings

click node_intake "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/IntakeForm.jsx"
click node_app "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/App.jsx"
click node_score_api "https://github.com/linhtran00/nest-guard/blob/main/backend/main.py"
click node_home_schema "https://github.com/linhtran00/nest-guard/blob/main/backend/models/schemas.py"
click node_geocoding "https://github.com/linhtran00/nest-guard/blob/main/backend/services/geo.py"
click node_fema "https://github.com/linhtran00/nest-guard/blob/main/backend/services/fema.py"
click node_event_classifier "https://github.com/linhtran00/nest-guard/blob/main/backend/services/ai.py"
click node_risk_engine "https://github.com/linhtran00/nest-guard/blob/main/backend/services/risk.py"
click node_dashboard "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/Dashboard.jsx"
click node_risk_gauge "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/components/risk-gauge.jsx"
click node_risk_colors "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/lib/riskColor.js"
click node_category_details "https://github.com/linhtran00/nest-guard/tree/main/frontend/src/pages/details"
click node_detail_shell "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/components/DetailShell.jsx"
click node_house_map "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/HouseMap.jsx"
click node_house_viz "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/components/house-visualization.jsx"
click node_tips "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/TipsPage.jsx"
click node_alerts "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/LiveAlerts.jsx"
click node_weather_api "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/lib/weatherApi.js"
click node_settings "https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/Settings.jsx"

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_intake,node_app,node_dashboard,node_risk_gauge,node_settings toneBlue
class node_score_api,node_home_schema,node_risk_engine toneAmber
class node_geocoding,node_fema,node_fema_service,node_event_classifier,node_weather_api toneMint
class node_risk_colors,node_category_details,node_detail_shell,node_house_map,node_house_viz,node_tips,node_alerts toneRose
class node_homeowner,node_ai_service,node_weather_service toneIndigo
```

## Components

### Homeowner Experience

- [Home Intake](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/IntakeForm.jsx): `frontend/src/pages/IntakeForm.jsx`
- [App Flow](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Risk Dashboard](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Risk Gauge](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/components/risk-gauge.jsx): `frontend/src/components/risk-gauge.jsx`
- [Settings](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/Settings.jsx): `frontend/src/pages/Settings.jsx`

### Risk Assessment

- [Score API](https://github.com/linhtran00/nest-guard/blob/main/backend/main.py): `backend/main.py`
- [Home and Score Schemas](https://github.com/linhtran00/nest-guard/blob/main/backend/models/schemas.py): `backend/models/schemas.py`
- [Risk Scoring](https://github.com/linhtran00/nest-guard/blob/main/backend/services/risk.py): `backend/services/risk.py`

### Location and Events

- [Address Geocoding](https://github.com/linhtran00/nest-guard/blob/main/backend/services/geo.py): `backend/services/geo.py`
- [FEMA Hazards](https://github.com/linhtran00/nest-guard/blob/main/backend/services/fema.py): `backend/services/fema.py`
- **FEMA Data Service**
- [Event Classification](https://github.com/linhtran00/nest-guard/blob/main/backend/services/ai.py): `backend/services/ai.py`
- [Weather API Client](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/lib/weatherApi.js): `frontend/src/lib/weatherApi.js`

### Risk Insights

- [Risk Color Helpers](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/lib/riskColor.js): `frontend/src/lib/riskColor.js`
- [Category Details](https://github.com/linhtran00/nest-guard/tree/main/frontend/src/pages/details): `frontend/src/pages/details`
- [Detail Wrapper](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/components/DetailShell.jsx): `frontend/src/components/DetailShell.jsx`
- [Home Map](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/HouseMap.jsx): `frontend/src/pages/HouseMap.jsx`
- [House Visualization](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/components/house-visualization.jsx): `frontend/src/components/house-visualization.jsx`
- [Action Tips](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/TipsPage.jsx): `frontend/src/pages/TipsPage.jsx`
- [Live Weather Alerts](https://github.com/linhtran00/nest-guard/blob/main/frontend/src/pages/LiveAlerts.jsx): `frontend/src/pages/LiveAlerts.jsx`

### Other components

- **Homeowner**
- **AI Provider**
- **Weather Service**

## Connections

- Homeowner → Home Intake: enters home details
- Home Intake → App Flow: submits assessment (evidence: `frontend/src/App.jsx`)
- App Flow → Score API: requests score (evidence: `frontend/src/App.jsx`)
- Score API → Home and Score Schemas: validates input (evidence: `backend/main.py`)
- Score API → Address Geocoding: geocodes address (evidence: `backend/main.py`)
- Score API → FEMA Hazards: fetches hazards (evidence: `backend/main.py`)
- FEMA Hazards → FEMA Data Service: requests hazard data
- Score API → Event Classification: classifies events (evidence: `backend/main.py`)
- Event Classification → AI Provider: uses AI classification
- Score API → Risk Scoring: scores home (evidence: `backend/main.py`)
- Risk Scoring → Home and Score Schemas: assembles response (evidence: `backend/services/risk.py`)
- App Flow → Risk Dashboard: shows results (evidence: `frontend/src/App.jsx`)
- Risk Dashboard → Risk Gauge: renders score (evidence: `frontend/src/pages/Dashboard.jsx`)
- Risk Dashboard → Category Details: opens category (evidence: `frontend/src/pages/Dashboard.jsx`)
- Category Details → Detail Wrapper: uses shared wrapper (evidence: `frontend/src/pages/details/NaturalDisasterDetail.jsx`)
- Risk Dashboard → Action Tips: shows actions (evidence: `frontend/src/pages/Dashboard.jsx`)
- Risk Dashboard → Risk Color Helpers: formats risk levels (evidence: `frontend/src/pages/Dashboard.jsx`)
- Risk Gauge → Risk Color Helpers: colors score (evidence: `frontend/src/components/risk-gauge.jsx`)
- App Flow → Home Map: opens home map (evidence: `frontend/src/App.jsx`)
- Home Map → House Visualization: renders house (evidence: `frontend/src/pages/HouseMap.jsx`)
- House Visualization → Risk Color Helpers: colors risk (evidence: `frontend/src/components/house-visualization.jsx`)
- App Flow → Live Weather Alerts: opens alerts (evidence: `frontend/src/App.jsx`)
- Live Weather Alerts → Weather API Client: loads local weather (evidence: `frontend/src/pages/LiveAlerts.jsx`)
- Weather API Client → Weather Service: requests forecast
- App Flow → Settings: opens settings (evidence: `frontend/src/App.jsx`)
