# labhansh2/prorev architecture

> Architecture diagram of the GitHub repository labhansh2/prorev, 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/labhansh2/prorev
- Repository: https://github.com/labhansh2/prorev

## Overview

##### Main Components
- Client Interface: Represented by client.py and the distributed Windows executable versions (found in the “dist” directory) that provide a user-friendly way to input credentials (integration token, page name) and trigger notifications.
- Backend Service / Core Engine: main.py serves as the entry point when running the service locally or hosting it in the cloud.
- Prorev Package (Business Logic Layer): This is the heart of the project and includes:
- prorev/Notion.py: Contains logic to interact with the Notion API.
- prorev/data.py: Manages the data models or interactions with the database (data.db held in /data and duplicate in /dist/data).
- prorev/rev_model.py: Likely implements the gapped revision or spaced repetition logic.
- prorev/notification.py: Manages the scheduling and triggering of notifications.
- prorev/log_config.py: Sets up logging configuration for the application.
- __init__.py: Marks the package.
- Database and Data Storage: The data folder (and its duplicate in “dist/data”) contains the data.db file used for storage.
- Logs: A directory dedicated to storing logfile.log for tracking and debugging.
- Additional Assets: The img folder includes visual assets (for the README, e.g., learning curves/descriptions) and might also be used by the client interface to render a user interface or presentation elements.

##### Relationships and Data Flow
- User Input Flow: In the client desktop app or via the script on the cloud, users provide their API token and page name. This input is then passed to the main engine (main.py) which interacts with the Notion API.
- Business Logic Layer: main.py calls functions from the prorev package modules (such as Notion.py, notification.py, and rev_model.py) to process the integration, fetch or update data, and plan revisions.
- Data Persistence: All interactions that result in data updates are saved in the data.db file, ensuring that user data (and possibly revision schedules) are persistent.
- Notifications: Once the data is processed and the reading plan is generated, the notification module schedules and issues notifications. Logging throughout this process is handled by the log_config module, with logs stored in the logs directory.
- Packaging and Distribution: The “dist” folder duplicates essential files for distribution, including compiled executables for the client app (main.exe and prorev.exe), making the project accessible without needing to run the scripts directly.

##### Architectural Patterns or Design Principles
- Separation of Concerns: Different modules handle API interactions, business logic, notification scheduling, and logging.
- Modular Design: The prorev package divides functionality into clearly defined modules, making it easier to maintain and extend.
- Dual Deployment Modes: The architecture supports both a desktop client (for local usage) and a cloud-deployed service.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        CA["Client App (client.py)"]:::client
        WE["Windows Executables (dist)"]:::distribution
    end

    %% Backend Service
    subgraph "Backend Service"
        MS["Main Service (main.py)"]:::service
    end

    %% Business Logic Layer (prorev Package)
    subgraph "Business Logic Layer"
        NI["Notion Integration (prorev/Notion.py)"]:::business
        DM["Data Management (prorev/data.py)"]:::business
        RL["Revision Logic (prorev/rev_model.py)"]:::business
        NS["Notification Service (prorev/notification.py)"]:::business
        LC["Logging Infrastructure (prorev/log_config.py)"]:::business
    end

    %% Data Storage
    subgraph "Data Storage"
        DB["Database (data/data.db)"]:::data
    end

    %% Logging Files
    subgraph "Logging"
        LD["Log Files (logs)"]:::log
    end

    %% Distribution Bundles
    subgraph "Distribution Bundles"
        DBund["Distribution Bundles (dist)"]:::distribution
    end

    %% Connections from UI Layer to Backend Service
    CA -->|"send-input"| MS
    WE -->|"trigger-app"| MS

    %% Main Service calling Business Logic modules
    MS -->|"calls"| NI
    MS -->|"calls"| DM
    MS -->|"calls"| RL
    MS -->|"calls"| NS
    MS -->|"configures"| LC

    %% Data Management persistence
    DM -->|"persists"| DB

    %% Logging: Logging configuration writes to log files
    LC -->|"writes-logs"| LD

    %% Distribution Bundles duplicate key components
    DBund -->|"contains"| CA
    DBund -->|"contains"| WE
    DBund -->|"contains"| DB
    DBund -->|"contains"| LD

    %% Click Events
    click CA "https://github.com/labhansh2/prorev/blob/main/client.py"
    click WE "https://github.com/labhansh2/prorev/tree/main/dist"
    click MS "https://github.com/labhansh2/prorev/blob/main/main.py"
    click NI "https://github.com/labhansh2/prorev/blob/main/prorev/Notion.py"
    click DM "https://github.com/labhansh2/prorev/blob/main/prorev/data.py"
    click DB "https://github.com/labhansh2/prorev/blob/main/data/data.db"
    click RL "https://github.com/labhansh2/prorev/blob/main/prorev/rev_model.py"
    click NS "https://github.com/labhansh2/prorev/blob/main/prorev/notification.py"
    click LC "https://github.com/labhansh2/prorev/blob/main/prorev/log_config.py"
    click LD "https://github.com/labhansh2/prorev/tree/main/logs"
    click DBund "https://github.com/labhansh2/prorev/tree/main/dist"

    %% Styles
    classDef client fill:#f4cccc,stroke:#333,stroke-width:2px;
    classDef service fill:#cfe2f3,stroke:#333,stroke-width:2px;
    classDef business fill:#d9ead3,stroke:#333,stroke-width:2px;
    classDef data fill:#ead1dc,stroke:#333,stroke-width:2px;
    classDef log fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef distribution fill:#d0e0e3,stroke:#333,stroke-width:2px;
```
