# fandiplay/market-impulse architecture

> Architecture diagram of the GitHub repository fandiplay/market-impulse, 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/fandiplay/market-impulse
- Repository: https://github.com/fandiplay/market-impulse

## Overview

This appears to be a browser-based global-news/AI analysis app: users can request analysis through a default AI endpoint or configure an OpenAI-compatible agent, with settings persisted locally. The sampled code shows the AI request and model-listing paths, but not the page markup or event wiring, so the user-interface links into those paths are not asserted. The service worker caches the app shell and provides a navigation fallback.

Main entry points: [`js/ai-agent.js`](https://github.com/fandiplay/market-impulse/blob/main/js/ai-agent.js) (AI agent), [`service-worker.js`](https://github.com/fandiplay/market-impulse/blob/main/service-worker.js) (Service worker), [`api/agent/chat.js`](https://github.com/fandiplay/market-impulse/blob/main/api/agent/chat.js) (Chat proxy), [`api/agent/models.js`](https://github.com/fandiplay/market-impulse/blob/main/api/agent/models.js) (Models proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser AI"]
  node_default_ai["Default AI<br/>[ai.js]"]
  node_agent["AI agent<br/>[ai-agent.js]"]
  node_settings[("AI settings<br/>[settings.js]")]
end

subgraph group_proxy["Agent Proxy"]
  node_chat_proxy["Chat proxy<br/>[chat.js]"]
  node_models_proxy["Models proxy<br/>[models.js]"]
end

subgraph group_runtime["App Runtime"]
  node_app["App page<br/>[index.html]"]
  node_service_worker["Service worker<br/>[service-worker.js]"]
end

node_user(("User"))
node_default_service{{"Default AI service"}}
node_configured_service{{"Configured AI service"}}
node_model_service{{"Model service"}}
node_browser_cache[("Browser cache")]

node_agent -->|"reads config"| node_settings
node_agent -->|"posts chat"| node_chat_proxy
node_agent -->|"requests models"| node_models_proxy
node_chat_proxy -->|"forwards chat"| node_configured_service
node_models_proxy -->|"fetches models"| node_model_service
node_default_ai -->|"sends prompt"| node_default_service
node_service_worker -->|"caches shell"| node_browser_cache
node_service_worker -->|"caches page"| node_app
node_user -->|"uses"| node_app

click node_app "https://github.com/fandiplay/market-impulse/blob/main/index.html"
click node_default_ai "https://github.com/fandiplay/market-impulse/blob/main/js/ai.js"
click node_agent "https://github.com/fandiplay/market-impulse/blob/main/js/ai-agent.js"
click node_settings "https://github.com/fandiplay/market-impulse/blob/main/js/settings.js"
click node_chat_proxy "https://github.com/fandiplay/market-impulse/blob/main/api/agent/chat.js"
click node_models_proxy "https://github.com/fandiplay/market-impulse/blob/main/api/agent/models.js"
click node_service_worker "https://github.com/fandiplay/market-impulse/blob/main/service-worker.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_default_ai,node_agent,node_settings,node_user toneBlue
class node_chat_proxy,node_models_proxy,node_browser_cache toneAmber
class node_app,node_service_worker toneMint
class node_default_service,node_configured_service,node_model_service toneIndigo
```

## Components

### Browser AI

- [Default AI](https://github.com/fandiplay/market-impulse/blob/main/js/ai.js): `js/ai.js`
- [AI agent](https://github.com/fandiplay/market-impulse/blob/main/js/ai-agent.js): `js/ai-agent.js`
- [AI settings](https://github.com/fandiplay/market-impulse/blob/main/js/settings.js): `js/settings.js`

### Agent Proxy

- [Chat proxy](https://github.com/fandiplay/market-impulse/blob/main/api/agent/chat.js): `api/agent/chat.js`
- [Models proxy](https://github.com/fandiplay/market-impulse/blob/main/api/agent/models.js): `api/agent/models.js`

### App Runtime

- [App page](https://github.com/fandiplay/market-impulse/blob/main/index.html): `index.html`
- [Service worker](https://github.com/fandiplay/market-impulse/blob/main/service-worker.js): `service-worker.js`

### Other components

- **User**
- **Default AI service**
- **Configured AI service**
- **Model service**
- **Browser cache**

## Connections

- AI agent → AI settings: reads config (evidence: `js/ai-agent.js`)
- AI agent → Chat proxy: posts chat (evidence: `js/ai-agent.js`)
- AI agent → Models proxy: requests models (evidence: `js/ai-agent.js`)
- Chat proxy → Configured AI service: forwards chat (evidence: `api/agent/chat.js`)
- Models proxy → Model service: fetches models (evidence: `api/agent/models.js`)
- Default AI → Default AI service: sends prompt (evidence: `js/ai.js`)
- Service worker → Browser cache: caches shell (evidence: `service-worker.js`)
- Service worker → App page: caches page (evidence: `service-worker.js`)
- User → App page: uses
