# phittayanan/hackathon-team architecture

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

- Interactive diagram: https://gitdiagram.com/phittayanan/hackathon-team
- Repository: https://github.com/phittayanan/hackathon-team

## Overview

Agent OS is a voice-first browser agent that routes a user request to a prebuilt scene or a safe generated page, with optional live-agent and web-search capabilities. The browser also supports proactive feed-driven interactions and falls back to keyword routing and saved voice clips when live service is unavailable. Server handlers centralize usage limits and service calls. Some relationships are supported by the README rather than sampled implementation; unsampled subsystems are represented at their existing directory paths.

Main entry points: [`web/lib/handlers.js`](https://github.com/phittayanan/hackathon-team/blob/main/web/lib/handlers.js) (Route handlers), [`web/public/js/app.js`](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/app.js) (Home app), [`web/public/js/api.js`](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/api.js) (API client), [`web/public/js/agent-tools.js`](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/agent-tools.js) (Client tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser experience"]
  node_app["Home app<br/>[app.js]"]
  node_scenes["Ready scenes"]
  node_voice["Voice and speech<br/>[voice.js]"]
  node_feed["Proactive feeds<br/>[feeds.js]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_agent["Agent and UI"]
  node_live["Live agent<br/>[live-agent.js]"]
  node_agent_link["Agent connection<br/>[agent-link.js]"]
  node_agent_loop["Agent loop<br/>[agent-loop.js]"]
  node_tools["Client tools<br/>[agent-tools.js]"]
  node_genui["Generated UI spec<br/>[genui.js]"]
  node_generated["Generated page<br/>[generated.js]"]
  node_offline_router["Keyword router<br/>[router.js]"]
end

subgraph group_server["Server services"]
  node_server["Local server<br/>[server.js]"]
  node_handlers["Route handlers<br/>[handlers.js]"]
  node_vercel["Function adapter<br/>[vercel.js]"]
  node_usage["Usage limits<br/>[usage.js]"]
  node_tts["Speech service<br/>[tts.js]"]
  node_session["Signed sessions<br/>[live-session.js]"]
  node_search["Web search<br/>[search.js]"]
  node_images["Image service<br/>[images.js]"]
  node_runlog["Run logging<br/>[runlog.js]"]
end

subgraph group_platform["External services"]
  node_elevenlabs["ElevenLabs"]
  node_tavily["Tavily"]
  node_redis[("Upstash Redis")]
end

node_user(("Visitor"))

node_user -->|"enters request"| node_app
node_app -->|"opens scene"| node_scenes
node_app -->|"speaks request"| node_voice
node_app -->|"routes request"| node_api_client
node_app -->|"connects agent"| node_agent_link
node_app -->|"starts session"| node_live
node_feed -->|"supplies events"| node_agent_link
node_agent_link -->|"starts loop"| node_agent_loop
node_live -->|"registers tools"| node_tools
node_tools -->|"validates specs"| node_genui
node_tools -->|"opens or revises"| node_generated
node_generated -->|"requests images"| node_api_client
node_api_client -->|"calls API"| node_server
node_api_client -->|"requests fallback"| node_offline_router
node_offline_router -->|"builds fallback spec"| node_genui
node_server -->|"dispatches routes"| node_handlers
node_vercel -->|"adapts functions"| node_handlers
node_handlers -->|"routes offline text"| node_offline_router
node_handlers -->|"checks limits"| node_usage
node_handlers -->|"requests speech"| node_tts
node_handlers -->|"creates signed URL"| node_session
node_handlers -->|"runs search"| node_search
node_handlers -->|"gets image"| node_images
node_handlers -->|"records events"| node_runlog
node_voice -->|"requests speech"| node_api_client
node_search -->|"queries"| node_tavily
node_session -->|"signs session"| node_elevenlabs
node_tts -.->|"generates audio"| node_elevenlabs
node_usage -.->|"stores shared limits"| node_redis

click node_app "https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/app.js"
click node_scenes "https://github.com/phittayanan/hackathon-team/tree/main/web/public/js/scenes"
click node_voice "https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/voice.js"
click node_feed "https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/feeds.js"
click node_api_client "https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/api.js"
click node_live "https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/live-agent.js"
click node_agent_link "https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/agent-link.js"
click node_agent_loop "https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/agent-loop.js"
click node_tools "https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/agent-tools.js"
click node_genui "https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/genui.js"
click node_generated "https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/scenes/generated.js"
click node_offline_router "https://github.com/phittayanan/hackathon-team/blob/main/web/lib/router.js"
click node_server "https://github.com/phittayanan/hackathon-team/blob/main/web/server.js"
click node_handlers "https://github.com/phittayanan/hackathon-team/blob/main/web/lib/handlers.js"
click node_vercel "https://github.com/phittayanan/hackathon-team/blob/main/web/lib/vercel.js"
click node_usage "https://github.com/phittayanan/hackathon-team/blob/main/web/lib/usage.js"
click node_tts "https://github.com/phittayanan/hackathon-team/blob/main/web/lib/tts.js"
click node_session "https://github.com/phittayanan/hackathon-team/blob/main/web/lib/live-session.js"
click node_search "https://github.com/phittayanan/hackathon-team/blob/main/web/lib/search.js"
click node_images "https://github.com/phittayanan/hackathon-team/blob/main/web/lib/images.js"
click node_runlog "https://github.com/phittayanan/hackathon-team/blob/main/web/lib/runlog.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_app,node_scenes,node_voice,node_feed,node_api_client toneBlue
class node_live,node_agent_link,node_agent_loop,node_tools,node_genui,node_generated,node_offline_router toneAmber
class node_server,node_handlers,node_vercel,node_usage,node_tts,node_session,node_search,node_images,node_runlog toneMint
class node_elevenlabs,node_tavily,node_redis toneRose
class node_user toneIndigo
```

## Components

### Browser experience

- [Home app](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/app.js): `web/public/js/app.js`
- [Ready scenes](https://github.com/phittayanan/hackathon-team/tree/main/web/public/js/scenes): `web/public/js/scenes`
- [Voice and speech](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/voice.js): `web/public/js/voice.js`
- [Proactive feeds](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/feeds.js): `web/public/js/feeds.js`
- [API client](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/api.js): `web/public/js/api.js`

### Agent and UI

- [Live agent](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/live-agent.js): `web/public/js/live-agent.js`
- [Agent connection](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/agent-link.js): `web/public/js/agent-link.js`
- [Agent loop](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/agent-loop.js): `web/public/js/agent-loop.js`
- [Client tools](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/agent-tools.js): `web/public/js/agent-tools.js`
- [Generated UI spec](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/genui.js): `web/public/js/genui.js`
- [Generated page](https://github.com/phittayanan/hackathon-team/blob/main/web/public/js/scenes/generated.js): `web/public/js/scenes/generated.js`
- [Keyword router](https://github.com/phittayanan/hackathon-team/blob/main/web/lib/router.js): `web/lib/router.js`

### Server services

- [Local server](https://github.com/phittayanan/hackathon-team/blob/main/web/server.js): `web/server.js`
- [Route handlers](https://github.com/phittayanan/hackathon-team/blob/main/web/lib/handlers.js): `web/lib/handlers.js`
- [Function adapter](https://github.com/phittayanan/hackathon-team/blob/main/web/lib/vercel.js): `web/lib/vercel.js`
- [Usage limits](https://github.com/phittayanan/hackathon-team/blob/main/web/lib/usage.js): `web/lib/usage.js`
- [Speech service](https://github.com/phittayanan/hackathon-team/blob/main/web/lib/tts.js): `web/lib/tts.js`
- [Signed sessions](https://github.com/phittayanan/hackathon-team/blob/main/web/lib/live-session.js): `web/lib/live-session.js`
- [Web search](https://github.com/phittayanan/hackathon-team/blob/main/web/lib/search.js): `web/lib/search.js`
- [Image service](https://github.com/phittayanan/hackathon-team/blob/main/web/lib/images.js): `web/lib/images.js`
- [Run logging](https://github.com/phittayanan/hackathon-team/blob/main/web/lib/runlog.js): `web/lib/runlog.js`

### External services

- **ElevenLabs**
- **Tavily**
- **Upstash Redis**

### Other components

- **Visitor**

## Connections

- Visitor → Home app: enters request
- Home app → Ready scenes: opens scene (evidence: `web/public/js/app.js`)
- Home app → Voice and speech: speaks request (evidence: `web/public/js/app.js`)
- Home app → API client: routes request (evidence: `web/public/js/app.js`)
- Home app → Agent connection: connects agent (evidence: `web/public/js/app.js`)
- Home app → Live agent: starts session (evidence: `web/public/js/app.js`)
- Proactive feeds → Agent connection: supplies events (evidence: `web/public/js/agent-link.js`)
- Agent connection → Agent loop: starts loop (evidence: `web/public/js/agent-link.js`)
- Live agent → Client tools: registers tools (evidence: `web/public/js/live-agent.js`)
- Client tools → Generated UI spec: validates specs (evidence: `web/public/js/agent-tools.js`)
- Client tools → Generated page: opens or revises
- Generated page → API client: requests images (evidence: `web/public/js/scenes/generated.js`)
- API client → Local server: calls API
- API client → Keyword router: requests fallback
- Keyword router → Generated UI spec: builds fallback spec (evidence: `web/lib/router.js`)
- Local server → Route handlers: dispatches routes (evidence: `web/server.js`)
- Function adapter → Route handlers: adapts functions (evidence: `web/lib/vercel.js`)
- Route handlers → Keyword router: routes offline text (evidence: `web/lib/handlers.js`)
- Route handlers → Usage limits: checks limits (evidence: `web/lib/handlers.js`)
- Route handlers → Speech service: requests speech (evidence: `web/lib/handlers.js`)
- Route handlers → Signed sessions: creates signed URL (evidence: `web/lib/handlers.js`)
- Route handlers → Web search: runs search (evidence: `web/lib/handlers.js`)
- Route handlers → Image service: gets image (evidence: `web/lib/handlers.js`)
- Route handlers → Run logging: records events (evidence: `web/lib/handlers.js`)
- Voice and speech → API client: requests speech (evidence: `web/public/js/voice.js`)
- Web search → Tavily: queries (evidence: `web/lib/search.js`)
- Signed sessions → ElevenLabs: signs session
- Speech service → ElevenLabs: generates audio
- Usage limits → Upstash Redis: stores shared limits
