# syedamehakzahra/flyrank_capstone_sitepulseai architecture

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

- Interactive diagram: https://gitdiagram.com/syedamehakzahra/flyrank_capstone_sitepulseai
- Repository: https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai

## Overview

SitePulse AI is a conversational website-metadata analyzer. A user enters or selects a URL; the chat page sends messages to the streaming API, which selects a free OpenRouter model and provides a server-side website-analysis tool. The tool fetches and extracts metadata, and the streamed tool result and assistant response are rendered in the chat. The graph preserves the documented analysis, fallback, and UI branches; some detailed wiring is supported only by README or SOURCE INDEX references, as noted by evidence paths.

Main entry points: [`app/page.jsx`](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/app/page.jsx) (Chat page), [`app/api/chat/route.js`](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/app/api/chat/route.js) (Streaming chat API), [`components/ChatInput.jsx`](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ChatInput.jsx) (URL input), [`components/WelcomeScreen.jsx`](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/WelcomeScreen.jsx) (Suggestions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat interface"]
  node_chatpage["Chat page<br/>[page.jsx]"]
  node_chatinput["URL input<br/>[ChatInput.jsx]"]
  node_welcome["Suggestions<br/>[WelcomeScreen.jsx]"]
  node_message["Message renderer<br/>[ChatMessage.jsx]"]
  node_toolcard["Analysis result card<br/>[ToolInvocation.jsx]"]
  node_skeleton["Loading skeleton<br/>[ChatSkeleton.jsx]"]
  node_errorbanner["Error banner<br/>[ErrorBanner.jsx]"]
  node_scroll["Auto-scroll control"]
end

subgraph group_orchestration["Chat orchestration"]
  node_chatapi["Streaming chat API<br/>[route.js]"]
end

subgraph group_analysis["Website analysis"]
  node_analyzetool["Metadata tool<br/>[tools.js]"]
end

subgraph group_support["Model and errors"]
  node_model["Model selection<br/>[ai.js]"]
  node_errors["Error classification<br/>[errorMessages.js]"]
end

node_user(("Visitor"))
node_openrouter["OpenRouter"]
node_website["Target website"]

node_user -->|"uses"| node_chatpage
node_chatpage -->|"renders"| node_chatinput
node_chatpage -->|"renders"| node_welcome
node_welcome -->|"sends suggestion"| node_chatpage
node_chatinput -.->|"submits URL"| node_chatpage
node_chatpage -->|"sends messages"| node_chatapi
node_chatapi -->|"selects and falls back"| node_model
node_model -->|"configures provider"| node_openrouter
node_chatapi -->|"streams model response"| node_openrouter
node_chatapi -->|"provides tool"| node_analyzetool
node_analyzetool -->|"fetches HTML"| node_website
node_chatpage -->|"renders messages"| node_message
node_message -->|"renders tool parts"| node_toolcard
node_chatpage -->|"renders loading state"| node_skeleton
node_chatpage -->|"renders errors"| node_errorbanner
node_errorbanner -->|"classifies errors"| node_errors
node_chatapi -->|"sanitizes errors"| node_errors
node_chatpage -->|"controls scrolling"| node_scroll

click node_chatpage "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/app/page.jsx"
click node_chatinput "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ChatInput.jsx"
click node_welcome "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/WelcomeScreen.jsx"
click node_message "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ChatMessage.jsx"
click node_toolcard "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ToolInvocation.jsx"
click node_skeleton "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ChatSkeleton.jsx"
click node_errorbanner "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ErrorBanner.jsx"
click node_scroll "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ScrollToBottomButton.jsx"
click node_chatapi "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/app/api/chat/route.js"
click node_model "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/lib/ai.js"
click node_analyzetool "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/lib/tools.js"
click node_errors "https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/lib/errorMessages.js"

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_chatpage,node_chatinput,node_welcome,node_message,node_toolcard,node_skeleton,node_errorbanner,node_scroll toneBlue
class node_chatapi toneAmber
class node_analyzetool,node_openrouter toneMint
class node_model,node_errors toneRose
class node_user,node_website toneIndigo
```

## Components

### Chat interface

- [Chat page](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/app/page.jsx): `app/page.jsx`
- [URL input](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ChatInput.jsx): `components/ChatInput.jsx`
- [Suggestions](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/WelcomeScreen.jsx): `components/WelcomeScreen.jsx`
- [Message renderer](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ChatMessage.jsx): `components/ChatMessage.jsx`
- [Analysis result card](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ToolInvocation.jsx): `components/ToolInvocation.jsx`
- [Loading skeleton](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ChatSkeleton.jsx): `components/ChatSkeleton.jsx`
- [Error banner](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ErrorBanner.jsx): `components/ErrorBanner.jsx`
- [Auto-scroll control](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/components/ScrollToBottomButton.jsx): `components/ScrollToBottomButton.jsx`

### Chat orchestration

- [Streaming chat API](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/app/api/chat/route.js): `app/api/chat/route.js`

### Website analysis

- [Metadata tool](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/lib/tools.js): `lib/tools.js`

### Model and errors

- [Model selection](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/lib/ai.js): `lib/ai.js`
- [Error classification](https://github.com/syedamehakzahra/flyrank_capstone_sitepulseai/blob/main/lib/errorMessages.js): `lib/errorMessages.js`

### Other components

- **Visitor**
- **OpenRouter**
- **Target website**

## Connections

- Visitor → Chat page: uses (evidence: `README.md`)
- Chat page → URL input: renders (evidence: `app/page.jsx`)
- Chat page → Suggestions: renders (evidence: `app/page.jsx`)
- Suggestions → Chat page: sends suggestion (evidence: `components/WelcomeScreen.jsx`)
- URL input → Chat page: submits URL (evidence: `app/page.jsx`)
- Chat page → Streaming chat API: sends messages (evidence: `app/page.jsx`)
- Streaming chat API → Model selection: selects and falls back (evidence: `app/api/chat/route.js`)
- Model selection → OpenRouter: configures provider (evidence: `lib/ai.js`)
- Streaming chat API → OpenRouter: streams model response (evidence: `README.md`)
- Streaming chat API → Metadata tool: provides tool (evidence: `app/api/chat/route.js`)
- Metadata tool → Target website: fetches HTML (evidence: `lib/tools.js`)
- Chat page → Message renderer: renders messages (evidence: `app/page.jsx`)
- Message renderer → Analysis result card: renders tool parts (evidence: `components/ChatMessage.jsx`)
- Chat page → Loading skeleton: renders loading state (evidence: `app/page.jsx`)
- Chat page → Error banner: renders errors (evidence: `app/page.jsx`)
- Error banner → Error classification: classifies errors (evidence: `components/ErrorBanner.jsx`)
- Streaming chat API → Error classification: sanitizes errors (evidence: `app/api/chat/route.js`)
- Chat page → Auto-scroll control: controls scrolling (evidence: `app/page.jsx`)
