# bigsk1/ai-screen-analyzer architecture

> Architecture diagram of the GitHub repository bigsk1/ai-screen-analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bigsk1/ai-screen-analyzer
- Repository: https://github.com/bigsk1/ai-screen-analyzer

## Overview

#### Purpose and Entry Points
AI Screen Analyzer is a React single-page application for capturing browser-accessible screens/windows, sending images to vision-capable AI providers, and continuing a chat about the capture. The browser starts at `public/index.html` and mounts React through `src/index.js`; application composition begins in `src/App.js`. A Node/Express process in `server.js` provides backend integration, especially for services that should not be called directly from the client.

#### Application Shell and UI State
`src/App.js` coordinates the major user workflow: capture selection, analysis, chat, history, and active AI model/provider state. `src/components/Layout.js` supplies the shared visual frame, while `src/context/ThemeContext.js` owns dark/light theme preference and makes it available across the component tree. Styling is primarily defined by `src/App.css`, `src/index.css`, and Tailwind configuration in `tailwind.config.js`.

#### Screen Capture Pipeline
`src/components/ScreenCapture.js` is the capture boundary between browser media/screen APIs and application state. It obtains a screenshot from the user-selected display/window and passes image data onward for display, persistence, and AI analysis. Image encoding, resizing, or conversion concerns are centralized in `src/utils/imageUtils.js`, keeping provider-facing image preparation separate from capture UI.

#### Image Analysis Orchestration
`src/components/ImageAnalysis.js` presents analysis controls and results for the active screenshot. Provider/model selection and request dispatch are centralized in `src/utils/aiServices.js`, which forms the integration boundary for OpenAI vision, Anthropic Claude, and locally hosted Ollama-compatible models. The key runtime configuration comes from environment variables represented by `.env.sample`, including OpenAI/Anthropic credentials, Anthropic model selection, and the Ollama base URL.

#### Conversational Continuation
`src/components/Chat.js` manages the user-facing conversation over the analyzed image or general follow-up questions. It relies on the selected model/provider flow from `src/utils/aiServices.js` and preserves enough client state to allow model switching without discarding the conversation context. This is distinct from image analysis presentation in `src/components/ImageAnalysis.js`, though both converge on the same AI-service abstraction.

#### Capture History and Client Persistence
`src/components/CaptureHistory.js` exposes saved captures for revisiting or managing prior work. `src/utils/storage.js` is the persistence boundary, likely backed by browser storage rather than a repository-visible database layer. The capture-to-history flow is: `ScreenCapture.js` produces image data, `App.js` coordinates current capture state, and `storage.js` persists/retrieves history consumed by `CaptureHistory.js`.

#### Runtime, Deployment, and External Dependencies
The frontend runs in the browser under React; the backend runtime is Node.js with Express (`server.js`). AI requests target external OpenAI and Anthropic APIs or a local/network Ollama instance. `Dockerfile` and `docker-compose.yml` define containerized deployment, including connectivity to Ollama from Docker via host networking conventions. `package.json` is the dependency and script control point for local development and production execution.

Main entry points: [`src/App.js`](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/App.js) (Application coordinator), [`src/utils/aiServices.js`](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/utils/aiServices.js) (AI service dispatcher), [`src/components/ScreenCapture.js`](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/components/ScreenCapture.js) (Screen capture), [`server.js`](https://github.com/bigsk1/ai-screen-analyzer/blob/main/server.js) (Express backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React Frontend"]
  node_html["Browser entry<br/>HTML entry<br/>[index.html]"]
  node_react_entry["React mount<br/>React bootstrap<br/>[index.js]"]
  node_app["Application coordinator<br/>React app<br/>[App.js]"]
  node_layout["Shared layout<br/>UI shell<br/>[Layout.js]"]
  node_theme["Theme state<br/>React context<br/>[ThemeContext.js]"]
  node_styles["Styles<br/>CSS and Tailwind<br/>[App.css]"]
end

subgraph group_capture["Capture &amp; History"]
  node_screen_capture["Screen capture<br/>Capture UI<br/>[ScreenCapture.js]"]
  node_image_utils["Image preparation<br/>Image utility<br/>[imageUtils.js]"]
  node_history["Capture history<br/>History UI<br/>[CaptureHistory.js]"]
  node_storage[("Client persistence<br/>Browser storage<br/>[storage.js]")]
end

subgraph group_ai["AI Integration"]
  node_analysis["Image analysis<br/>Analysis UI<br/>[ImageAnalysis.js]"]
  node_chat["Follow-up chat<br/>Chat UI<br/>[Chat.js]"]
  node_ai_services{{"AI service dispatcher<br/>Provider abstraction<br/>[aiServices.js]"}}
  node_providers{{"Vision AI providers<br/>External APIs"}}
end

subgraph group_runtime["Runtime &amp; Deployment"]
  node_server["Express backend<br/>Node service<br/>[server.js]"]
  node_env["Runtime environment<br/>Environment config<br/>[.env.sample]"]
  node_package["Scripts and dependencies<br/>Package manifest<br/>[package.json]"]
  node_containers["Container deployment<br/>Docker deployment<br/>[docker-compose.yml]"]
end

node_html -->|"loads"| node_react_entry
node_react_entry -->|"mounts"| node_app
node_app -->|"composes"| node_layout
node_theme -->|"provides theme"| node_app
node_styles -.->|"styles"| node_app
node_app -->|"coordinates"| node_screen_capture
node_screen_capture -->|"prepares image"| node_image_utils
node_screen_capture -->|"returns capture"| node_app
node_app -->|"saves and loads captures"| node_storage
node_storage -->|"supplies saved captures"| node_history
node_app -->|"supplies active capture"| node_analysis
node_app -->|"supplies conversation state"| node_chat
node_analysis -->|"submits image analysis"| node_ai_services
node_chat -->|"sends follow-ups"| node_ai_services
node_ai_services -->|"dispatches requests"| node_providers
node_env -.->|"configures providers"| node_ai_services
node_ai_services -.->|"uses backend integration"| node_server
node_package -.->|"runs"| node_server
node_containers -->|"deploys"| node_server
node_containers -.->|"connects to Ollama"| node_providers

click node_html "https://github.com/bigsk1/ai-screen-analyzer/blob/main/public/index.html"
click node_react_entry "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/index.js"
click node_app "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/App.js"
click node_layout "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/components/Layout.js"
click node_theme "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/context/ThemeContext.js"
click node_styles "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/App.css"
click node_screen_capture "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/components/ScreenCapture.js"
click node_image_utils "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/utils/imageUtils.js"
click node_history "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/components/CaptureHistory.js"
click node_storage "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/utils/storage.js"
click node_analysis "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/components/ImageAnalysis.js"
click node_chat "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/components/Chat.js"
click node_ai_services "https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/utils/aiServices.js"
click node_server "https://github.com/bigsk1/ai-screen-analyzer/blob/main/server.js"
click node_env "https://github.com/bigsk1/ai-screen-analyzer/blob/main/.env.sample"
click node_package "https://github.com/bigsk1/ai-screen-analyzer/blob/main/package.json"
click node_containers "https://github.com/bigsk1/ai-screen-analyzer/blob/main/docker-compose.yml"

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_html,node_react_entry,node_app,node_layout,node_theme,node_styles toneBlue
class node_screen_capture,node_image_utils,node_history,node_storage toneAmber
class node_analysis,node_chat,node_ai_services,node_providers toneMint
class node_server,node_env,node_package,node_containers toneRose
```

## Components

### React Frontend

Browser single-page application.

- [Browser entry](https://github.com/bigsk1/ai-screen-analyzer/blob/main/public/index.html): HTML entry · `public/index.html`
- [React mount](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/index.js): React bootstrap · `src/index.js`
- [Application coordinator](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/App.js): React app · Coordinates capture, analysis, chat, history, and active provider state. · `src/App.js`
- [Shared layout](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/components/Layout.js): UI shell · `src/components/Layout.js`
- [Theme state](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/context/ThemeContext.js): React context · `src/context/ThemeContext.js`
- [Styles](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/App.css): CSS and Tailwind · `src/App.css`

### Capture & History

- [Screen capture](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/components/ScreenCapture.js): Capture UI · Uses browser screen and media APIs to obtain a selected display or window image. · `src/components/ScreenCapture.js`
- [Image preparation](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/utils/imageUtils.js): Image utility · Encodes, resizes, or converts provider-ready images. · `src/utils/imageUtils.js`
- [Capture history](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/components/CaptureHistory.js): History UI · `src/components/CaptureHistory.js`
- [Client persistence](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/utils/storage.js): Browser storage · Persists and retrieves saved captures. · `src/utils/storage.js`

### AI Integration

- [Image analysis](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/components/ImageAnalysis.js): Analysis UI · `src/components/ImageAnalysis.js`
- [Follow-up chat](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/components/Chat.js): Chat UI · Retains conversation context while allowing provider or model switching. · `src/components/Chat.js`
- [AI service dispatcher](https://github.com/bigsk1/ai-screen-analyzer/blob/main/src/utils/aiServices.js): Provider abstraction · Centralizes provider selection and image/chat request dispatch. · `src/utils/aiServices.js`
- **Vision AI providers**: External APIs · OpenAI, Anthropic Claude, and Ollama-compatible models.

### Runtime & Deployment

- [Express backend](https://github.com/bigsk1/ai-screen-analyzer/blob/main/server.js): Node service · Backend integration boundary for services not called directly by the browser. · `server.js`
- [Runtime environment](https://github.com/bigsk1/ai-screen-analyzer/blob/main/.env.sample): Environment config · Defines provider credentials, model selection, and Ollama base URL. · `.env.sample`
- [Scripts and dependencies](https://github.com/bigsk1/ai-screen-analyzer/blob/main/package.json): Package manifest · `package.json`
- [Container deployment](https://github.com/bigsk1/ai-screen-analyzer/blob/main/docker-compose.yml): Docker deployment · Defines application containers and Docker-to-Ollama connectivity. · `docker-compose.yml`

## Connections

- Browser entry → React mount: loads
- React mount → Application coordinator: mounts
- Application coordinator → Shared layout: composes
- Theme state → Application coordinator: provides theme
- Styles → Application coordinator: styles
- Application coordinator → Screen capture: coordinates
- Screen capture → Image preparation: prepares image
- Screen capture → Application coordinator: returns capture
- Application coordinator → Client persistence: saves and loads captures
- Client persistence → Capture history: supplies saved captures
- Application coordinator → Image analysis: supplies active capture
- Application coordinator → Follow-up chat: supplies conversation state
- Image analysis → AI service dispatcher: submits image analysis
- Follow-up chat → AI service dispatcher: sends follow-ups
- AI service dispatcher → Vision AI providers: dispatches requests
- Runtime environment → AI service dispatcher: configures providers
- AI service dispatcher → Express backend: uses backend integration
- Scripts and dependencies → Express backend: runs
- Container deployment → Express backend: deploys
- Container deployment → Vision AI providers: connects to Ollama
