# renzel/work_or_meditate architecture

> Architecture diagram of the GitHub repository renzel/work_or_meditate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/renzel/work_or_meditate
- Repository: https://github.com/renzel/work_or_meditate

## Overview

##### Project type and purpose
- This is a browser extension (“Work or Meditate”) whose purpose is to monitor tab URLs, capture screenshots on navigation, classify content via a local AI server, and prompt the user to meditate if leisure content is detected.

##### File structure
- Top‐level files:
- background.js – background service worker for URL change detection, screenshot capture, and server calls
- workormeditate.js – content script injected into pages (currently minimal)
- test.js & encoded_test.txt – test harness/materials (likely for local dev)
- No backend code in the repo: classification happens on an external AI service.

##### README for additional insights
- The AI server is Ollama running locally at http://localhost:11434 with llava-llama3.
- Workflow: URL change → capture screenshot → POST to AI → parse response → if “leisure,” show meditation prompt.

##### Detailed capture of essential elements
- Local-only processing (privacy boundary).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User[/"User in Browser"/]:::user
    subgraph "Browser Extension"
        Manifest["manifest.json"]:::ext
        Background["background.js"]:::ext
        Content["workormeditate.js"]:::ext
        Icons["icons/"]:::ext
    end
    subgraph "Development Harness"
        TestHarness["test.js"]:::dev
        EncodedData["encoded_test.txt"]:::dev
    end
    README["README.md"]:::docs
    ExternalAI(("Ollama AI Server\nhttp://localhost:11434")):::ai

    User -->|"navigates to URL"| Background
    Background -->|"captureVisibleTab"| Background
    Background -->|"POST screenshot"| ExternalAI
    ExternalAI -->|"returns classification JSON"| Background
    Background -->|"if leisure"| Content
    Content -->|"show meditation prompt"| User

    TestHarness -->|"uses sample data"| Background
    EncodedData -->|"feeds into"| TestHarness
    README -.-> Background

    click Manifest "https://github.com/renzel/work_or_meditate/blob/main/manifest.json"
    click Background "https://github.com/renzel/work_or_meditate/blob/main/background.js"
    click Content "https://github.com/renzel/work_or_meditate/blob/main/workormeditate.js"
    click TestHarness "https://github.com/renzel/work_or_meditate/blob/main/test.js"
    click EncodedData "https://github.com/renzel/work_or_meditate/blob/main/encoded_test.txt"
    click README "https://github.com/renzel/work_or_meditate/blob/main/README.md"

    classDef ext fill:#B3CDE3,stroke:#03396C,color:#03396C;
    classDef ai fill:#FBB040,stroke:#D65F00,color:#FFFFFF;
    classDef user fill:#E0E0E0,stroke:#7F7F7F,color:#000000;
    classDef dev fill:#C7E9C0,stroke:#41AB5D,color:#00441B;
    classDef docs fill:#DECBE4,stroke:#8856A7,color:#000000;
```
