# kjhosein/rtm-milkscript-scripts architecture

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

- Interactive diagram: https://gitdiagram.com/kjhosein/rtm-milkscript-scripts
- Repository: https://github.com/kjhosein/rtm-milkscript-scripts

## Overview

##### Project type and purpose
- This is an open-source utility collection—specifically, a set of MilkScript (JavaScript) scripts that run inside the Remember the Milk (RTM) Pro environment to automate queries and generate reports on tasks. There is no standalone frontend or backend; each file is an independent script that plugs into the RTM MilkScript engine.

##### Main components
a. MilkScript Engine (hosted by RTM)
b. RTM Cloud Service / API
c. Individual script modules (*.js files)
d. (Optional) Scheduler or user trigger mechanism

##### Relationships and interactions
- Each script module is loaded into the MilkScript Engine.
- The MilkScript Engine authenticates and communicates with the RTM Cloud Service over HTTPS.
- The RTM API responds with task data (completed tasks, incomplete tasks, subtasks, etc.).
- The script processes the data and renders a report back in the MilkScript UI or forwards it (e.g., via email or UI output).

##### Architectural patterns and design principles
- Single‐responsibility: each .js file handles one report type (today’s completed tasks, last month’s completed tasks, etc.).
- Extensibility point: new scripts can be dropped into the repo, each defining its query parameters and output formatting.

##### Relevant technologies
- JavaScript (MilkScript)
- RTM MilkScript Engine APIs
- HTTPS/REST for RTM Cloud Service
- (Optional) Cron or RTM’s built-in scheduling

##### Important details to capture
- Authentication flow (MilkScript Engine uses stored user credentials)
- Data flow: Script→Engine→RTM API→Engine→Script output
- Separation of concerns: query logic in each .js, transport in Engine, data store in RTM Cloud

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Scheduler
    SCHEDULER["Scheduler / Trigger"]:::scheduler

    %% Script Modules and Documentation
    subgraph "Scripts (Extensibility Point)"
        all_tasks_and_subtasks.js["all_tasks_and_subtasks.js"]:::scripts
        completed_tasks_last_month.js["completed_tasks_last_month.js"]:::scripts
        completed_tasks_this_month.js["completed_tasks_this_month.js"]:::scripts
        completed_tasks_today.js["completed_tasks_today.js"]:::scripts
        completed_tasks_yesterday.js["completed_tasks_yesterday.js"]:::scripts
        incomplete_tasks_due_x_days_ago.js["incomplete_tasks_due_x_days_ago.js"]:::scripts
        README.md["README.md"]:::docs
        LICENSE["LICENSE"]:::docs
    end

    %% Core Engine
    MILKSCRIPT_ENGINE["MilkScript Engine"]:::engine

    %% RTM Service
    RTM_API["RTM Cloud Service / API"]:::rtm

    %% Relationships
    SCHEDULER -->|"trigger"| all_tasks_and_subtasks.js
    SCHEDULER -->|"trigger"| completed_tasks_last_month.js
    SCHEDULER -->|"trigger"| completed_tasks_this_month.js
    SCHEDULER -->|"trigger"| completed_tasks_today.js
    SCHEDULER -->|"trigger"| completed_tasks_yesterday.js
    SCHEDULER -->|"trigger"| incomplete_tasks_due_x_days_ago.js

    all_tasks_and_subtasks.js -->|"load & execute"| MILKSCRIPT_ENGINE
    completed_tasks_last_month.js -->|"load & execute"| MILKSCRIPT_ENGINE
    completed_tasks_this_month.js -->|"load & execute"| MILKSCRIPT_ENGINE
    completed_tasks_today.js -->|"load & execute"| MILKSCRIPT_ENGINE
    completed_tasks_yesterday.js -->|"load & execute"| MILKSCRIPT_ENGINE
    incomplete_tasks_due_x_days_ago.js -->|"load & execute"| MILKSCRIPT_ENGINE

    MILKSCRIPT_ENGINE -->|"request tasks"| RTM_API
    RTM_API -->|"task data"| MILKSCRIPT_ENGINE

    MILKSCRIPT_ENGINE -->|"render report"| all_tasks_and_subtasks.js
    MILKSCRIPT_ENGINE -->|"render report"| completed_tasks_last_month.js
    MILKSCRIPT_ENGINE -->|"render report"| completed_tasks_this_month.js
    MILKSCRIPT_ENGINE -->|"render report"| completed_tasks_today.js
    MILKSCRIPT_ENGINE -->|"render report"| completed_tasks_yesterday.js
    MILKSCRIPT_ENGINE -->|"render report"| incomplete_tasks_due_x_days_ago.js

    %% Click Events
    click all_tasks_and_subtasks.js "https://github.com/kjhosein/rtm-milkscript-scripts/blob/main/all_tasks_and_subtasks.js"
    click completed_tasks_last_month.js "https://github.com/kjhosein/rtm-milkscript-scripts/blob/main/completed_tasks_last_month.js"
    click completed_tasks_this_month.js "https://github.com/kjhosein/rtm-milkscript-scripts/blob/main/completed_tasks_this_month.js"
    click completed_tasks_today.js "https://github.com/kjhosein/rtm-milkscript-scripts/blob/main/completed_tasks_today.js"
    click completed_tasks_yesterday.js "https://github.com/kjhosein/rtm-milkscript-scripts/blob/main/completed_tasks_yesterday.js"
    click incomplete_tasks_due_x_days_ago.js "https://github.com/kjhosein/rtm-milkscript-scripts/blob/main/incomplete_tasks_due_x_days_ago.js"
    click README.md "https://github.com/kjhosein/rtm-milkscript-scripts/blob/main/README.md"
    click LICENSE "https://github.com/kjhosein/rtm-milkscript-scripts/tree/main/LICENSE"

    %% Styles
    classDef scripts fill:#ccf,stroke:#000,stroke-width:1px
    classDef engine fill:#cfc,stroke:#000,stroke-width:1px
    classDef rtm fill:#cfc,stroke:#000,stroke-width:1px
    classDef scheduler fill:#fc9,stroke:#000,stroke-width:1px
    classDef docs fill:#eee,stroke:#000,stroke-width:1px
```
