# lofiturtle/canvastrello architecture

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

- Interactive diagram: https://gitdiagram.com/lofiturtle/canvastrello
- Repository: https://github.com/lofiturtle/canvastrello

## Overview

##### Project Type and Purpose
- This is an open-source integration tool (ETL-style sync) written in Python.
- Purpose: fetch assignments from Canvas courses (Canvas REST API) and populate them as cards on a Trello board (Trello REST API).

##### File Structure
- Top-level scripts/modules:
- canvashelper.py – encapsulates Canvas API calls and data parsing
- trellohelper.py – encapsulates Trello API calls (creating/updating cards)
- sync.py – orchestration layer: reads config, calls helpers in sequence
- secretstemplate.py / secrets.py – configuration holder for API tokens, URLs, course IDs, list IDs
- No subdirectories – a simple, single-process command-line tool.

##### Extract Insights from the README
- Workflow is one-way: Canvas → Trello.
- Security: credentials live in secrets.py, never checked into source.
- Deployment: “Run sync.py on a schedule” (cron, CI/CD, serverless scheduler).

##### Main Components
a. Local Environment / Runtime
- Python VM (virtualenv/container)
- Configuration store (secrets.py)
- Orchestrator script (sync.py)
b. Functional Modules
- CanvasHelper module – fetches assignments via Canvas REST API
- TrelloHelper module – posts/updates cards via Trello REST API
c. External Services
- Canvas REST API (HTTPS endpoint)
- Trello REST API (HTTPS endpoint)
- Trello Calendar plugin (optional—read-only calendar view)
d. Scheduler (optional)
- Cron job or external scheduler that invokes sync.py at intervals

##### Relationships & Data Flows
- sync.py loads secrets.py → instantiates CanvasHelper and TrelloHelper
- CanvasHelper → GET assignments from Canvas REST API → returns list of assignments
- sync.py → passes assignment list to TrelloHelper → POST/PUT cards to Trello REST API
- Trello API → updates board (lists/cards) → Calendar plugin reflects new cards
- (Scheduler) → triggers sync.py periodically

##### Architectural Patterns & Principles
- Separation of concerns:
- canvashelper.py encapsulates all Canvas logic
- trellohelper.py encapsulates all Trello logic
- sync.py orchestrates without business logic
- Configuration decoupling: secrets.py separate from code
- Single responsibility: small, testable modules
- Stateless design: each run stands alone, no persistent local DB

##### Technologies & Frameworks
- Python 3.9+
- Requests or an HTTP client (in requirements.txt/Pipfile)
- Possible scheduler (cron or serverless)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Scheduler
    Scheduler["Scheduler<br/>(cron/CI)"]:::scheduler

    %% Python Runtime Container
    subgraph "Python Runtime"
        direction TB
        PythonEnv["Python Environment<br/>(venv/container)"]:::environment
        Secrets["Configuration Store<br/>(secrets.py)"]:::config
        Sync["sync.py<br/>(Orchestrator)"]:::code
        CanvasHelper["canvashelper.py"]:::code
        TrelloHelper["trellohelper.py"]:::code
    end

    %% External Services
    CanvasAPI["Canvas REST API"]:::external
    TrelloAPI["Trello REST API"]:::external
    CalendarPlugin["Trello Calendar Plugin"]:::external

    %% Project Metadata
    subgraph "Project Metadata"
        direction TB
        README["README.md"]:::metadata
        LICENSE["LICENSE"]:::metadata
        Gitignore[".gitignore"]:::metadata
    end

    %% Dependencies
    subgraph "Dependencies"
        direction TB
        Pipfile["Pipfile"]:::metadata
        PipfileLock["Pipfile.lock"]:::metadata
        Requirements["requirements.txt"]:::metadata
    end

    %% Data Flows
    Scheduler -->|triggers| Sync
    Sync -->|loads| Secrets
    Sync -->|instantiates| CanvasHelper
    Sync -->|instantiates| TrelloHelper

    Sync -->|"GET assignments"| CanvasAPI
    CanvasAPI -->|"assignment data"| Sync

    Sync -->|"POST/PUT cards"| TrelloAPI
    TrelloAPI -->|"updates board"| CalendarPlugin

    %% Click Events
    click CanvasHelper "https://github.com/lofiturtle/canvastrello/blob/main/canvashelper.py"
    click TrelloHelper "https://github.com/lofiturtle/canvastrello/blob/main/trellohelper.py"
    click Sync "https://github.com/lofiturtle/canvastrello/blob/main/sync.py"
    click Secrets "https://github.com/lofiturtle/canvastrello/blob/main/secretstemplate.py"
    click Pipfile "https://github.com/lofiturtle/canvastrello/tree/main/Pipfile"
    click PipfileLock "https://github.com/lofiturtle/canvastrello/blob/main/Pipfile.lock"
    click Requirements "https://github.com/lofiturtle/canvastrello/blob/main/requirements.txt"
    click README "https://github.com/lofiturtle/canvastrello/blob/main/README.md"
    click LICENSE "https://github.com/lofiturtle/canvastrello/tree/main/LICENSE"
    click Gitignore "https://github.com/lofiturtle/canvastrello/blob/main/.gitignore"

    %% Styles
    classDef code fill:#a8d0e6,stroke:#333,stroke-width:1px;
    classDef config fill:#d3d3d3,stroke:#333,stroke-width:1px;
    classDef external fill:#feca57,stroke:#333,stroke-width:1px;
    classDef scheduler fill:#90ee90,stroke:#333,stroke-width:1px;
    classDef metadata fill:#f1c40f,stroke:#333,stroke-width:1px;
    classDef environment fill:#d0e1f9,stroke:#333,stroke-width:1px;
```
