# open-spaced-repetition/rs-fsrs architecture

> Architecture diagram of the GitHub repository open-spaced-repetition/rs-fsrs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/open-spaced-repetition/rs-fsrs
- Repository: https://github.com/open-spaced-repetition/rs-fsrs

## Overview

##### Project type and its purpose
- This is a Rust library implementing the FSRS scheduling algorithm.
- The README clearly indicates it is meant to be used as a dependency, with example usage for scheduling “Card” objects based on review timings.

##### File structure to determine the core components
- Top-level project files: Cargo.toml/Cargo.lock define Rust dependency management.
- The src directory contains modules:
– lib.rs: Serves as the core entry point (public API) of the library.
– scheduler.rs, scheduler_basic.rs, scheduler_longterm.rs: These modules encapsulate different scheduling strategies or facets of the FSRS algorithm.
– algo.rs and alea.rs: Likely implement various algorithms or randomization elements.
– models.rs: Contains the data models such as Card, and possibly Rating.
– parameters.rs: Manages the FSRS parameters used in computation.
– tests.rs: Contains tests to validate functionality.
- Additionally, the .github directory and configuration files (workflows, CODE_OF_CONDUCT.md, etc.) set up CI/CD and community guidelines.

##### README for further insights
- The README outlines the library’s purpose, installation via Cargo, and quickstart code examples which reveal usage of FSRS, Card, and Rating types.
- The “Other implementation” and “Bindings” sections indicate that the project is part of a larger ecosystem and that its core algorithm is used by multiple language interfaces.
- The development instructions also point to an emphasis on code quality (cargo fmt, clippy, tests).

- Clear labels:
– Differentiate between core processing modules (e.g., scheduler/algorithm) and supporting modules (e.g., models, parameters).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Core Modules
    subgraph "Core Modules"
        API["lib.rs – Public API"]
    end

    %% Scheduling Engines
    subgraph "Scheduling Engines"
        general["scheduler.rs – General Scheduler"]
        basic["scheduler_basic.rs – Basic Scheduler"]
        longterm["scheduler_longterm.rs – Longterm Scheduler"]
    end

    %% Algorithm Modules
    subgraph "Algorithm Modules"
        algo["algo.rs – Algorithm Implementation"]
        alea["alea.rs – Randomization/Utility"]
    end

    %% Data Models & Parameters
    subgraph "Data Models & Parameters"
        models["models.rs – Data Models"]
        params["parameters.rs – FSRS Parameters"]
    end

    %% Testing and CI/CD
    subgraph "Testing and CI/CD"
        tests["tests.rs – Testing Suite"]
        cicd["CI/CD (GitHub Workflows)"]
    end

    %% External Integration
    integration["External Bindings (C/C++,Python,Java,Node.js)"]

    %% Relationships
    integration -->|"calls"| API
    API -->|"invokes"| general
    API -->|"invokes"| basic
    API -->|"invokes"| longterm

    general -->|"uses"| algo
    general -->|"uses"| alea
    basic -->|"uses"| algo
    basic -->|"uses"| alea
    longterm -->|"uses"| algo
    longterm -->|"uses"| alea

    general -->|"accesses"| models
    general -->|"reads"| params
    basic -->|"accesses"| models
    basic -->|"reads"| params
    longterm -->|"accesses"| models
    longterm -->|"reads"| params

    tests -->|"verifies"| API
    cicd -->|"runs"| tests

    %% Click Events
    click API "https://github.com/open-spaced-repetition/rs-fsrs/blob/master/src/lib.rs"
    click general "https://github.com/open-spaced-repetition/rs-fsrs/blob/master/src/scheduler.rs"
    click basic "https://github.com/open-spaced-repetition/rs-fsrs/blob/master/src/scheduler_basic.rs"
    click longterm "https://github.com/open-spaced-repetition/rs-fsrs/blob/master/src/scheduler_longterm.rs"
    click algo "https://github.com/open-spaced-repetition/rs-fsrs/blob/master/src/algo.rs"
    click alea "https://github.com/open-spaced-repetition/rs-fsrs/blob/master/src/alea.rs"
    click models "https://github.com/open-spaced-repetition/rs-fsrs/blob/master/src/models.rs"
    click params "https://github.com/open-spaced-repetition/rs-fsrs/blob/master/src/parameters.rs"
    click tests "https://github.com/open-spaced-repetition/rs-fsrs/blob/master/src/tests.rs"
    click cicd "https://github.com/open-spaced-repetition/rs-fsrs/tree/master/.github/workflows"

    %% Styles
    classDef core fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef sched fill:#aed6f1,stroke:#3498db,stroke-width:2px;
    classDef algo fill:#a9dfbf,stroke:#27ae60,stroke-width:2px;
    classDef data fill:#f5b7b1,stroke:#e74c3c,stroke-width:2px;
    classDef test fill:#f9e79f,stroke:#f39c12,stroke-width:2px;
    classDef external fill:#d2b4de,stroke:#8e44ad,stroke-width:2px;

    class API core;
    class general,basic,longterm sched;
    class algo,alea algo;
    class models,params data;
    class tests,cicd test;
    class integration external;
```
