How ysfemrealbyrk/ollama-monitor works
Project type and purpose
• This is a lightweight Windows system-tray desktop application written in Python.
Main architectural components
a. User Interface Layer
• Notification pop-ups (using Windows APIs via Python)
b. Core Monitoring Engine
• Poller/Watcher: periodically sends HTTP requests to the Ollama API
• Status evaluator: maps HTTP responses to status codes (green/blue/red)
• Event emitter: notifies the UI layer of status changes
c. API Client
• Configurable HTTP client (supports proxy, authentication)
• Encapsulates URL formatting, request retries, error handling
d. Configuration Manager
• Reads and writes user settings (API URL, startup preferences)
• Persists config (e.g., in %APPDATA% or registry)
e. Logger
• Centralized logging to file in %APPDATA%/OllamaMonitor/logs
• Separate log levels for info, warnings, errors
f. Build & Packaging
• build.py: compiles the Python code into an executable (e.g., via PyInstaller)
• create_version_info.py and __version__.py: manage version injection
External dependencies and services
• Ollama AI service: HTTP endpoint at localhost:11434 or configured proxy
• Windows OS subsystem (system tray, startup registry, notifications)
• Python runtime (3.8+), pystray, requests (or similar HTTP lib)
Relationships and interactions
• On launch: Configuration Manager loads settings → Core Monitoring Engine starts polling.
• Poller calls API Client → receives model status → passes to Status Evaluator → triggers Event Emitter.
• Logger records each poll cycle, errors, and user actions.
• UI Layer user actions (Settings, Exit) go back to Configuration Manager or shut down the Engine.
• Build & Packaging scripts do not run at runtime but are part of the CI/build pipeline.
Architectural patterns and design principles
• Separation of concerns: UI vs. core logic vs. config vs. logging.
• Observer/Publisher-Subscriber: Event Emitter notifies UI of status changes.
• Single Responsibility: each module (API Client, Config Manager) handles one aspect.
• Adapter: wrap HTTP library calls in a single API client interface.
Deliverables
• Runtime flow: launch → poll → update UI → shutdown.
• Build flow: version bump → build.py → dist/OllamaMonitor.exe.