# kjt7578/rec_chart architecture

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

- Interactive diagram: https://gitdiagram.com/kjt7578/rec_chart
- Repository: https://github.com/kjt7578/rec_chart

## Overview

##### Project type and purpose
- This is a PyQt6-based desktop application (“Rec Chart OCR”) that assists recruiters by performing real-time OCR on interview video feeds, running AI-based screening and summarization, and generating structured reports.
- It’s not a classic web front-end/back-end but a modular desktop system with UI, core‐processing, AI integration, and persistence layers.

##### File structure
- Top-level directories:
- ocr/             – standalone OCR scripts (legacy or demo)
- src/             – main application code
– config/        • settings.py
– core/          • ocr_engine.py, screen_capture.py
– gpt/           • enhanced_analyzer.py, summarizer.py
– ui/            • widgets and main_window.py
– utils/         • document_saver.py
– main.py        • application entry point
- Other: setup.py, tasks.md, utils/document_saver.py (duplicate util)
- External dependencies are declared in requirements.txt (PyQt6, pytesseract, mss, openai, pillow, etc.)

##### README insights
- 3-stage workflow: template setup → real-time capture & screening → enhanced analysis & report.
- OCR uses pytesseract+Pillow, capture uses mss, AI uses OpenAI GPT-3.5/4.
- Persistent artifacts: JSON templates, .txt reports.
- UI is built with stacked widgets and splitters to reflect the 3-step flow.

##### Main components & interactions
1. UI Layer (PyQt6)
- main_window.py
- capture_widget.py, interview_widget.py, summary_widget.py, result_widget.py, template_editor.py
2. & OCR Layer
- core.screen_capture (mss-based)
- core.ocr_engine (pytesseract + Pillow)
3. AI Analysis Layer
- gpt.enhanced_analyzer (comprehensive interview analysis)
- gpt.summarizer (real-time summarization)
4. Configuration Layer
- config.settings (user templates, API keys, capture intervals)
5. Persistence & Reporting Layer
- utils.document_saver (structured .txt reports, JSON, encoding)
6. External Services
- Tesseract OCR Engine (local binary)
- OpenAI API (GPT-3.5/4)

1. User triggers “Start Capture” in UI → UI calls core.screen_capture
2. screen_capture grabs image → passes to core.ocr_engine
3. ocr_engine returns raw text → forwarded to gpt.summarizer for live screening notes
4. UI updates real-time checklist and notes
5. At interview end, UI sends full transcript to gpt.enhanced_analyzer
6. enhanced_analyzer returns structured analysis → passed to document_saver
7. document_saver writes report file → UI shows “Save Completed”

c. Patterns & principles
- Layered modularity: UI ↔ core ↔ AI ↔ persistence
- Single Responsibility: each module does one job (capture, OCR, summarization, analysis, saving)
- Dependency inversion: config/settings injected into modules
- Event-driven UI updates via signals/slots

d. Key technologies & frameworks
- PyQt6 for UI
- mss for multi-screen capture
- pytesseract + Pillow for OCR
- OpenAI Python SDK for AI calls
- JSON for templates, .txt for reports

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layer: Template Setup
    subgraph "Template Setup"
        direction TB
        MainApp["main.py\n(Application Entry)"]:::core
        MainWindow["main_window.py\n(Main UI Frame)"]:::ui
        TemplateEditor["template_editor.py\n(Edit Templates)"]:::ui
        Settings["settings.py\n(Config: templates, API keys)"]:::config
    end

    %% Layer: Real-Time Capture
    subgraph "Real-Time Capture"
        direction TB
        CaptureWidget["capture_widget.py\n(Start Capture UI)"]:::ui
        ScreenCapture["screen_capture.py\n(Grab Frames)"]:::core
        OCREngine["ocr_engine.py\n(Image→Raw Text)"]:::core
        Summarizer["summarizer.py\n(Live Screening Notes)"]:::ai
        SummaryWidget["summary_widget.py\n(Display Live Notes)"]:::ui
    end

    %% Layer: Post-Interview Analysis
    subgraph "Post-Interview Analysis"
        direction TB
        InterviewWidget["interview_widget.py\n(Full Transcript UI)"]:::ui
        EnhancedAnalyzer["enhanced_analyzer.py\n(Structured Analysis)"]:::ai
        DocumentSaver["document_saver.py\n(Generate Reports)"]:::persistence
        ResultWidget["result_widget.py\n(Show Save Completed)"]:::ui
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Tesseract["Tesseract OCR\n(Local Binary)"]:::external
        OpenAI["OpenAI API\n(GPT-3.5/4)"]:::external
    end

    %% Entry point to UI
    MainApp -->|"launch"| MainWindow

    %% Template Setup Flow
    MainWindow -->|"edit templates"| TemplateEditor
    TemplateEditor -->|"load/save JSON"| Settings

    %% Real-Time Capture Flow
    MainWindow -->|"select capture"| CaptureWidget
    CaptureWidget -->|"trigger capture"| ScreenCapture
    ScreenCapture -->|"Image"| OCREngine
    OCREngine -->|"Raw Text"| Summarizer
    Summarizer -->|"Live Notes"| SummaryWidget

    %% Post-Interview Analysis Flow
    MainWindow -->|"review transcript"| InterviewWidget
    InterviewWidget -->|"Full Transcript"| EnhancedAnalyzer
    EnhancedAnalyzer -->|"Structured Analysis"| DocumentSaver
    DocumentSaver -->|"Report File"| ResultWidget

    %% Config injections
    Settings -->|">capture_interval, API_KEY"| ScreenCapture
    Settings -->|">tesseract_path"| OCREngine
    Settings -->|">openai_key"| Summarizer
    Settings -->|">openai_key"| EnhancedAnalyzer

    %% External calls
    OCREngine -->|"calls"| Tesseract
    Summarizer -->|"API request"| OpenAI
    EnhancedAnalyzer -->|"API request"| OpenAI

    %% Click events
    click MainApp "https://github.com/kjt7578/rec_chart/blob/main/src/main.py"
    click MainWindow "https://github.com/kjt7578/rec_chart/blob/main/src/ui/main_window.py"
    click TemplateEditor "https://github.com/kjt7578/rec_chart/blob/main/src/ui/template_editor.py"
    click Settings "https://github.com/kjt7578/rec_chart/blob/main/src/config/settings.py"
    click CaptureWidget "https://github.com/kjt7578/rec_chart/blob/main/src/ui/capture_widget.py"
    click ScreenCapture "https://github.com/kjt7578/rec_chart/blob/main/src/core/screen_capture.py"
    click OCREngine "https://github.com/kjt7578/rec_chart/blob/main/src/core/ocr_engine.py"
    click Summarizer "https://github.com/kjt7578/rec_chart/blob/main/src/gpt/summarizer.py"
    click SummaryWidget "https://github.com/kjt7578/rec_chart/blob/main/src/ui/summary_widget.py"
    click InterviewWidget "https://github.com/kjt7578/rec_chart/blob/main/src/ui/interview_widget.py"
    click EnhancedAnalyzer "https://github.com/kjt7578/rec_chart/blob/main/src/gpt/enhanced_analyzer.py"
    click DocumentSaver "https://github.com/kjt7578/rec_chart/blob/main/src/utils/document_saver.py"
    click ResultWidget "https://github.com/kjt7578/rec_chart/blob/main/src/ui/result_widget.py"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#003366,color:#003366;
    classDef core fill:#E0FFD0,stroke:#336600,color:#336600;
    classDef ai fill:#FFE8C0,stroke:#CC6600,color:#CC6600;
    classDef config fill:#F0F0F0,stroke:#666666,color:#666666;
    classDef persistence fill:#F0F0F0,stroke:#666666,color:#666666;
    classDef external fill:#F4E1FF,stroke:#663399,color:#663399;
```
