# yu7400ki/moocs-collect architecture

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

## Overview

##### Main Components
- CLI Component:
- Represented by the collect-cli folder. It contains its own Cargo.toml and Rust source (main.rs) and uses the core logic provided by the shared collect-core library.
- Core Library:
- The collect-core folder houses the common business logic (modules such as iniad.rs, pdf.rs, svg.rs, etc.). This is a reusable Rust crate that is referenced by both the CLI and the Tauri desktop app.
- Desktop Application (Tauri Backend):
- Found in the src-tauri folder. It contains Rust code that sets up the Tauri backend (with commands like get_courses, download_slides, etc.), state management, database migrations, and configuration for desktop integration.
- Web Frontend:
- The src folder is structured with components, features, routes, and utilities (likely using React with Vite, as indicated by package.json, vite.config.ts, and various TSX files). This frontend communicates with the Tauri backend.
- Build/Configuration & Additional Assets:
- Other configuration files (panda.config.ts, park-ui.json, patches, etc.) and assets that define the UI design (assets directory) and build pipelines (pnpm, GitHub workflows).

##### Relationships and Interactions
- Both the CLI and the Tauri backend depend on the collect-core crate for handling the actual slide download operations and business logic.
- The Tauri desktop app acts as the bridge between the native OS functionalities and the web frontend. User commands (like login, fetching courses, or downloading slides) initiated from the frontend are processed by Tauri via exposed commands in src-tauri/src/command.
- The web frontend (React/Vite-based) interfaces with the Tauri backend through API calls/command invocations—this encapsulates the interactive part of the GUI.
- External integrations such as file system access, network requests for downloading slides, or database access (as indicated by migrations and state management in Tauri) are managed within the Tauri layer.

##### Architectural Patterns and Design Principles
- Separation of Concerns: There is a clear division where the collect-core library encapsulates the domain logic and is reused by both CLI and GUI applications.
- Modular Design: The project divides functionality into well-defined modules (CLI, core, desktop commands, UI components, feature-based folder structure for authentication, courses, downloads, settings, etc.).
- Multi-Platform Strategy: By using Tauri, the desktop component leverages web technologies (React frontend) while maintaining native capabilities on a desktop environment.
- Dependency Management: Rust’s Cargo setup for backend modules and npm/pnpm for the web frontend demonstrates language-specific dependency management.

##### Additional Details to Capture
- That the CLI and Tauri desktop app are built using Rust, and they share common modules via the collect-core crate.
- That the frontend is built using TypeScript/React (Vite-based) and integrates with the Tauri backend.
- Build and deployment pipelines (e.g., GitHub workflows for publishing) that might be relevant to the deployment lifecycle.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Rust Components"
        CLI["CLI Application (collect-cli)"]:::rust
        CORE["Core Library (collect-core)"]:::rust
        TAURI["Desktop Application (Tauri Backend)"]:::rust
    end

    subgraph "Web Frontend"
        WEB["Web Frontend (src)"]:::frontend
    end

    CLI -->|"FunctionInvocation"| CORE
    TAURI -->|"UsesSharedCore"| CORE
    WEB -->|"CommandInvocation"| TAURI
    TAURI -->|"APIResponse"| WEB

    click CLI "https://github.com/yu7400ki/moocs-collect/blob/main/collect-cli/Cargo.toml"
    click CORE "https://github.com/yu7400ki/moocs-collect/blob/main/collect-core/src/lib.rs"
    click TAURI "https://github.com/yu7400ki/moocs-collect/blob/main/src-tauri/src/main.rs"
    click WEB "https://github.com/yu7400ki/moocs-collect/tree/main/src"

    classDef rust fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef frontend fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
```
