How vihdutta/canvascrafter works
Project type and purpose
• CanvasCrafter is an automation tool (a small full-stack-style web app and CLI utility) whose purpose is to generate and upload course pages to Canvas.
• It uses FastAPI (backend) to serve or orchestrate the build process, Tailwind-styled templates (frontend) to produce static HTML, YAML/Excel files as the data source, and Canvas’s REST API for upload.
File structure
Top-level:
• main.py – entry point (starts the FastAPI server or CLI).
• readme.MD – project description.
• .gitignore – excludes build artifacts.
Directories:
• files/backend – Python scripts that implement each step of the pipeline:
– build_html.py
– populate_weeks.py
– upload_to_canvas.py
– zip_built_htmls.py
• files/yaml – data source (images.yaml, learning_objectives.yaml, overview_statements.yaml, schedule.xlsx).
• templates – Jinja2 (or similar) HTML templates (index.html, me2024_template.html) styled with Tailwind.
• resources – static assets (logo, CSS, JS if any).
README
• Tech stack confirms the use of FastAPI for API/CLI orchestration and Tailwind for frontend templates.
Components & Their Interactions
a. Main Components
1. Data Source
– YAML files & schedule.xlsx (local file system)
2. Backend Orchestrator
– main.py (FastAPI app + CLI entrypoint)
3. Processing Modules (in files/backend)
– build_html.py: reads data, populates templates → static HTML
– populate_weeks.py: splits/generates pages per week
– zip_built_htmls.py: packages pages into .zip for manual download
– upload_to_canvas.py: calls Canvas REST API to push built pages
4. Templates & Static Assets
– templates/ (HTML + Tailwind CSS classes)
– resources/ (images, logo, CSS)
5. External Service
– Canvas API (authentication, course page endpoints)
b. Relationships & Data Flow
• User triggers main.py (HTTP request or CLI command)
• main.py invokes populate_weeks.py → build_html.py
• build_html.py loads YAML/Excel → renders templates → writes output HTML
• zip_built_htmls.py packages outputs
• upload_to_canvas.py pushes pages to Canvas
• Responses/Logs flow back to the user via FastAPI endpoints or console
c. Architectural Patterns / Principles
• Modular pipeline: each script is a separate processing stage
• MVC-style templating: data (Model) + Jinja templates (View) + orchestration code (Controller)
• Single responsibility per module, facilitating testing and extension
d. Key Technologies
• FastAPI (orchestration, optional UI)
• Python 3.x (scripts)
• Jinja2 (template engine)
• Tailwind CSS (styling)
• openpyxl / pandas (Excel reading)
• requests or httpx (Canvas API calls)