# javazeroo/bilibili_senior_llm architecture

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

- Interactive diagram: https://gitdiagram.com/javazeroo/bilibili_senior_llm
- Repository: https://github.com/javazeroo/bilibili_senior_llm

## Overview

##### Main Components
- Screen Capture & OCR Module – Likely handled by components in cap.py.
- Language Model Integration – This logic is implemented inside llm.py, which contains the get_ans function that interacts with the GPT-4 API or similar.
- Main Control & Automation Module – Located in main.py; this file serves as the central orchestrator that triggers the screen capture, passes the recognized text for processing, and then simulates mouse clicks.
- External Dependencies – These include PaddleOCR for text recognition, pyautogui for screen capture and mouse simulation, and possibly PaddlePaddle as the underlying deep learning framework.

##### Interactions and Data Flow
- The process begins with the main control module (main.py) which initiates a screen capture (possibly by calling functions in cap.py).
- The captured screenshot is processed with PaddleOCR to extract text, where:
- The recognized text (extracted question content and answer options) is sent to the language model layer (llm.py). Here, the get_ans function calls the GPT-4 API to determine the correct answer.
- Once the answer is generated, main.py uses pyautogui to simulate a mouse click at the corresponding on-screen button or area.

##### Architectural Patterns & Design Principles
- Separation of Concerns – Each Python file (cap.py, llm.py, main.py) is dedicated to a specific task: capturing/processing screenshots, interfacing with the language model, and coordinating the actions.
- Modularity – Using separate modules allows for easy testing and future enhancements. For example, if the OCR method or language model API needs to be updated, it can be done in isolation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Modules
    subgraph "Core Modules"
        A["Automation Controller (main.py)"]
        B["Screen Capture & OCR Module (cap.py)"]
        C["Language Model Integration (llm.py)"]
    end

    %% External Services
    subgraph "External Services"
        D["PaddleOCR (PaddlePaddle)"]
        E["GPT-4 API/LanguageModel"]
        F["pyautogui (Simulated Clicks)"]
    end

    %% Interactions between Core Modules
    A -->|"capture_screenshot"| B
    B -->|"send_OCR_results"| A
    A -->|"send_text_for_answer"| C
    C -->|"return_generated_answer"| A
    A -->|"simulate_click"| F

    %% Interactions with External Services
    B -->|"process_OCR"| D
    C -->|"call_API"| E

    %% Click Events for Components
    click B "https://github.com/javazeroo/bilibili_senior_llm/blob/main/cap.py"
    click C "https://github.com/javazeroo/bilibili_senior_llm/blob/main/llm.py"
    click A "https://github.com/javazeroo/bilibili_senior_llm/blob/main/main.py"

    %% Styles
    classDef internal fill:#f9f,stroke:#333,stroke-width:2px,color:#000;
    classDef external fill:#ccf,stroke:#333,stroke-width:2px,color:#000,stroke-dasharray: 5,5;
    
    class A,B,C internal;
    class D,E,F external;
```
