How iamwasim7/ai-companion works
AI Companion is an opt-in Windows desktop assistant for programming help. Its principal workflow captures changed screen frames, extracts text locally, detects errors and context, and requests AI analysis only after a local error signal; notifications surface results in the companion. The main window also provides chat, dashboard, history, monitoring, and settings. Supporting layers include shared state/events and SQLite-backed session persistence. Edges reflect shown calls, imports, or README behavior; some UI and monitoring wiring is supported by the source index rather than inspected excerpts.
Main entry points: main_window.py Main window · detection_pipeline.py Detection pipeline · events.py Event bus · monitor_service.py Monitor service
Components 28
Desktop interface
- Main window
app/ui/main_window.py - Dashboard
app/ui/dashboard.py - Chat window
app/ui/chat_window.py - Analysis panel
app/ui/analysis_panel.py - History page
app/ui/history_page.py - Monitoring page
app/ui/monitoring_page.py - Settings page
app/ui/settings_page.py - Floating companion
app/ui/companion.py
Monitoring and detection
- Notifications
app/services/notification_service.py - Monitor service
app/monitoring/monitor_service.py - Screen capture
app/monitoring/screen_capture.py - Change detection
app/monitoring/change_detector.py - Detection pipeline
app/services/detection_pipeline.py - OCR
app/ocr/ocr_service.py - Context detector
app/detection/context_detector.py - Error detector
app/detection/error_detector.py
AI and analysis
- Error analysis
app/ai/error_analysis_service.py - AI provider service
app/core/ai_service.py - Mock provider
app/core/mock_ai.py
Runtime and persistence
- App entry
app/main.py - Settings service
app/services/settings_service.py - Session store
app/core/session.py - Repositories
app/database/repositories.py - SQLite database
app/database/database.py - Shared state
app/core/state.py - Event bus
app/core/events.py
Other components
- User
- AI provider API
Connections 42
- User → App entry: launches
README.md - App entry → Main window: creates
app/main.py - App entry → Floating companion: creates
app/main.py - App entry → SQLite database: logs startup
app/main.py - Main window → Dashboard: routes to
app/ui/main_window.py - Main window → Chat window: routes to
app/ui/main_window.py - Main window → History page: routes to
app/ui/main_window.py - Main window → Monitoring page: routes to
app/ui/main_window.py - Main window → Settings page: routes to
app/ui/main_window.py - Main window → Monitor service: configures
app/ui/main_window.py - Main window → Detection pipeline: configures
app/ui/main_window.py - Main window → Notifications: configures
app/ui/main_window.py - Main window → Settings service: uses
app/ui/main_window.py - Main window → Shared state: reads
app/ui/main_window.py - Main window → Event bus: uses
app/ui/main_window.py - Dashboard → Analysis panel: shows
app/ui/dashboard.py - Dashboard → Notifications: uses
app/ui/dashboard.py - Analysis panel → Error analysis: requests analysis
app/ui/analysis_panel.py - Analysis panel → Session store: reads history
app/ui/analysis_panel.py - Floating companion → Notifications: shows alerts
app/ui/companion.py - Floating companion → Event bus: subscribes
app/ui/companion.py - Monitor service → Screen capture: captures frames
app/monitoring/monitor_service.py - Monitor service → Change detection: compares frames
app/monitoring/monitor_service.py - Monitor service → Event bus: emits events
app/monitoring/monitor_service.py - Monitor service → Shared state: updates
app/monitoring/monitor_service.py - Detection pipeline → OCR: extracts text
app/services/detection_pipeline.py - Detection pipeline → Context detector: detects context
app/services/detection_pipeline.py - Detection pipeline → Error detector: detects errors
app/services/detection_pipeline.py - Detection pipeline → Event bus: subscribes and emits
app/services/detection_pipeline.py - Detection pipeline → Shared state: updates
app/services/detection_pipeline.py - Detection pipeline → Error analysis: requests analysis
- Notifications → Event bus: subscribes and emits
app/services/notification_service.py - Error analysis → AI provider service: calls provider
app/ai/error_analysis_service.py - Error analysis → Context detector: formats context
app/ai/error_analysis_service.py - AI provider service → Mock provider: uses in mock mode
app/core/ai_service.py - AI provider service → AI provider API: sends requests
README.md - Settings page → Settings service: saves settings
app/ui/settings_page.py - Settings page → AI provider service: configures AI
app/ui/settings_page.py - Settings service → SQLite database: persists settings
app/services/settings_service.py - Session store → Repositories: uses
app/core/session.py - Repositories → SQLite database: queries
app/database/repositories.py - Session store → Event bus: emits changes
app/core/session.py