How bigsk1/ai-screen-analyzer works
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: App.js Application coordinator · aiServices.js AI service dispatcher · ScreenCapture.js Screen capture · server.js Express backend
Components 18
React Frontend
Browser single-page application.
- Browser entry
public/index.html - React mount
src/index.js - Application coordinator · Coordinates capture, analysis, chat, history, and active provider state.
src/App.js - Shared layout
src/components/Layout.js - Theme state
src/context/ThemeContext.js - Styles
src/App.css
Capture & History
- Screen capture · Uses browser screen and media APIs to obtain a selected display or window image.
src/components/ScreenCapture.js - Image preparation · Encodes, resizes, or converts provider-ready images.
src/utils/imageUtils.js - Capture history
src/components/CaptureHistory.js - Client persistence · Persists and retrieves saved captures.
src/utils/storage.js
AI Integration
- Image analysis
src/components/ImageAnalysis.js - Follow-up chat · Retains conversation context while allowing provider or model switching.
src/components/Chat.js - AI service dispatcher · Centralizes provider selection and image/chat request dispatch.
src/utils/aiServices.js - Vision AI providers · OpenAI, Anthropic Claude, and Ollama-compatible models.
Runtime & Deployment
- Express backend · Backend integration boundary for services not called directly by the browser.
server.js - Runtime environment · Defines provider credentials, model selection, and Ollama base URL.
.env.sample - Scripts and dependencies
package.json - Container deployment · Defines application containers and Docker-to-Ollama connectivity.
docker-compose.yml
Connections 20
- 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