# stremio/stremio-official-addons architecture

> Architecture diagram of the GitHub repository stremio/stremio-official-addons, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stremio/stremio-official-addons
- Repository: https://github.com/stremio/stremio-official-addons

## Overview

1. **What this repo is**
   - This repository is a **packaged catalog of Stremio’s official add-ons**.
   - It does not implement add-on logic itself; it curates and publishes a **serialized AddonCollection** that downstream apps consume.

2. **Two parallel product lines**
   - **v1** lives at the repo root and is published as the npm package **`stremio-official-addons`**.
   - **v2** lives under **`official-addons-v2/`** and is published as:
     - npm package **`@stremio/stremio-official-addons`**
     - Rust crate **`stremio-official-addons`**

3. **Source of truth vs generated artifacts**
   - The repo is centered around **generation scripts**, not hand-edited output.
   - Root **`scripts/gen.js`** produces the v1 output.
   - **`official-addons-v2/scripts/build.js`** produces the v2 output.
   - The committed files **`index.js`** and **`index.json`** are generated artifacts for the v1 package; the v2 package has its own build output inside its subfolder.

4. **Data model boundary**
   - The key contract is the **AddonCollection.load()/save() format** mentioned in the README.
   - That means the repo’s primary function is to transform an internal add-on list into a **stable serialized representation** that client apps can load directly.

5. **v1 package architecture**
   - Root package metadata is in **`package.json`** with lockfile **`package-lock.json`**.
   - The root package likely exports the generated collection from **`index.js`** and may also expose **`index.json`** for consumers that want raw data.
   - v1 is the legacy distribution path still used by older Stremio apps and infrastructure.

6. **v2 package architecture**
   - The `official-addons-v2/` directory is a self-contained multi-language package.
   - It has:
     - **`package.json`** for npm publishing
     - **`Cargo.toml`** and **`Cargo.lock`** for Rust publishing
     - **`src/lib.rs`** for the crate entry point
     - **`scripts/build.js`** for generating the package contents
   - This makes v2 a shared artifact source for both JS and Rust consumers.

7. **Build and release pipeline**
   - GitHub Actions under **`.github/workflows/build.yml`** and **`publish.yml`** automate validation and release.
   - The repo uses **tag-based releases** (`v1.x.x` and `v2.x.x`) as the trigger for publishing.
   - The publish workflow splits by major version:
     - v1 job builds and publishes the root npm package
     - v2 job builds and publishes both npm and crates.io artifacts

8. **Dependency impact boundaries**
   - The README explicitly calls out downstream systems that depend on this repo’s output:
     - **stremio-api-workers**
     - **stremio**
     - **stremio-rn**
     - **stremio-web**
     - **stremio-core**
   - This means a change here is not local; it propagates into app behavior and backend-served addon collections.

9. **Versioning and packaging discipline**
   - Version bumps must be synchronized with the generated output and lockfiles:
     - root npm metadata for v1
     - v2 npm metadata plus Rust crate version for v2
   - The presence of both **npm lockfiles** and **Cargo.lock** is important architecturally: it shows the repo is a **published artifact repository**, not just source code.

10. **Repository layout signals**
   - Root contains the legacy npm package and generation script.
   - `official-addons-v2/` contains the newer dual-published package.
   - `deflate-macro/` is a separate Rust subcrate, likely a utility dependency used by the v2 crate or build process.
   - `index.js`, `index.json`, and the v2 outputs are the main runtime-facing deliverables.

11. **External service touchpoints**
   - Publication targets are **npm** and **crates.io**.
   - The GitHub release process is operationally important because publishing is driven from tags/releases, not from arbitrary branch builds.

12. **How to diagram this repo**
   - Model it as a **content-generation and packaging pipeline**:
     - curated add-on definitions → generator scripts → versioned distributable artifacts → npm/crates.io publication → consumption by Stremio clients and backend services.
   - The central architectural boundary is between **maintained add-on definitions/generators** and **published serialized collections**.

Main entry points: [`scripts/gen.js`](https://github.com/stremio/stremio-official-addons/blob/master/scripts/gen.js) (Gen script), [`official-addons-v2`](https://github.com/stremio/stremio-official-addons/tree/master/official-addons-v2) (V2 output), [`package.json`](https://github.com/stremio/stremio-official-addons/blob/master/package.json) (Root package), [`official-addons-v2/scripts/build.js`](https://github.com/stremio/stremio-official-addons/blob/master/official-addons-v2/scripts/build.js) (Build script)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_root["v1 package"]
  node_node_root_gen["Gen script<br/>v1 generator<br/>[gen.js]"]
  node_node_root_indexjs["Index JS<br/>v1 artifact<br/>[index.js]"]
  node_node_root_indexjson["Index JSON<br/>v1 artifact<br/>[index.json]"]
  node_node_root_pkg["Root package<br/>npm package<br/>[package.json]"]
end

subgraph group_group_v2["v2 package"]
  node_node_v2_build["Build script<br/>v2 generator<br/>[build.js]"]
  node_node_v2_lib["Crate entry<br/>rust crate<br/>[lib.rs]"]
  node_node_v2_pkg["V2 package<br/>npm package<br/>[package.json]"]
  node_node_v2_crate["V2 crate<br/>rust crate<br/>[Cargo.toml]"]
  node_node_v2_output["V2 output<br/>generated artifacts"]
end

subgraph group_group_release["Release pipeline"]
  node_node_build_workflow["Build workflow<br/>CI validation<br/>[build.yml]"]
  node_node_publish_workflow["Publish workflow<br/>release automation<br/>[publish.yml]"]
end

subgraph group_group_downstream["Downstream consumers"]
  node_node_clients["Stremio apps<br/>downstream consumers"]
end

node_node_collection_contract["AddonCollection<br/>serialized contract"]
node_node_source_catalog["Addon list<br/>curated catalog<br/>[README.md]"]
node_node_deflate["Deflate macro<br/>rust helper crate<br/>[lib.rs]"]
node_node_npm(("npm<br/>package registry"))
node_node_crates(("crates.io<br/>crate registry"))

node_node_source_catalog -->|"input"| node_node_root_gen
node_node_root_gen -->|"generates"| node_node_root_indexjs
node_node_root_gen -->|"generates"| node_node_root_indexjson
node_node_root_gen -->|"serializes"| node_node_collection_contract
node_node_root_indexjs -->|"published by"| node_node_root_pkg
node_node_root_indexjson -->|"published by"| node_node_root_pkg
node_node_source_catalog -->|"input"| node_node_v2_build
node_node_v2_build -->|"generates"| node_node_v2_output
node_node_v2_output -->|"packed by"| node_node_v2_pkg
node_node_v2_output -->|"packed by"| node_node_v2_crate
node_node_v2_lib -->|"entry point"| node_node_v2_crate
node_node_deflate -.->|"supports"| node_node_v2_build
node_node_build_workflow -->|"validates"| node_node_root_gen
node_node_build_workflow -->|"validates"| node_node_v2_build
node_node_publish_workflow -->|"publishes"| node_node_root_pkg
node_node_publish_workflow -->|"publishes"| node_node_v2_pkg
node_node_publish_workflow -->|"publishes"| node_node_v2_crate
node_node_root_pkg -->|"release target"| node_node_npm
node_node_v2_pkg -->|"release target"| node_node_npm
node_node_v2_crate -->|"release target"| node_node_crates
node_node_root_indexjson -->|"consumed by"| node_node_clients
node_node_v2_output -->|"consumed by"| node_node_clients

click node_node_source_catalog "https://github.com/stremio/stremio-official-addons/blob/master/README.md"
click node_node_root_gen "https://github.com/stremio/stremio-official-addons/blob/master/scripts/gen.js"
click node_node_root_indexjs "https://github.com/stremio/stremio-official-addons/blob/master/index.js"
click node_node_root_indexjson "https://github.com/stremio/stremio-official-addons/blob/master/index.json"
click node_node_root_pkg "https://github.com/stremio/stremio-official-addons/blob/master/package.json"
click node_node_v2_build "https://github.com/stremio/stremio-official-addons/blob/master/official-addons-v2/scripts/build.js"
click node_node_v2_lib "https://github.com/stremio/stremio-official-addons/blob/master/official-addons-v2/src/lib.rs"
click node_node_v2_pkg "https://github.com/stremio/stremio-official-addons/blob/master/official-addons-v2/package.json"
click node_node_v2_crate "https://github.com/stremio/stremio-official-addons/blob/master/official-addons-v2/Cargo.toml"
click node_node_v2_output "https://github.com/stremio/stremio-official-addons/tree/master/official-addons-v2"
click node_node_deflate "https://github.com/stremio/stremio-official-addons/blob/master/deflate-macro/src/lib.rs"
click node_node_build_workflow "https://github.com/stremio/stremio-official-addons/blob/master/.github/workflows/build.yml"
click node_node_publish_workflow "https://github.com/stremio/stremio-official-addons/blob/master/.github/workflows/publish.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_root_gen,node_node_root_indexjs,node_node_root_indexjson,node_node_root_pkg toneBlue
class node_node_v2_build,node_node_v2_lib,node_node_v2_pkg,node_node_v2_crate,node_node_v2_output toneAmber
class node_node_build_workflow,node_node_publish_workflow toneMint
class node_node_clients toneRose
class node_node_collection_contract,node_node_source_catalog,node_node_deflate,node_node_npm,node_node_crates toneNeutral
```

## Components

### v1 package

Legacy npm package at the repository root.

- [Gen script](https://github.com/stremio/stremio-official-addons/blob/master/scripts/gen.js): v1 generator · Builds the legacy root distribution. · `scripts/gen.js`
- [Index JS](https://github.com/stremio/stremio-official-addons/blob/master/index.js): v1 artifact · Generated runtime entry for the legacy npm package. · `index.js`
- [Index JSON](https://github.com/stremio/stremio-official-addons/blob/master/index.json): v1 artifact · Generated serialized collection for consumers that want raw data. · `index.json`
- [Root package](https://github.com/stremio/stremio-official-addons/blob/master/package.json): npm package · Legacy published package metadata and release boundary. · `package.json`

### v2 package

New dual-published package under official-addons-v2/.

- [Build script](https://github.com/stremio/stremio-official-addons/blob/master/official-addons-v2/scripts/build.js): v2 generator · Builds the newer shared package outputs. · `official-addons-v2/scripts/build.js`
- [Crate entry](https://github.com/stremio/stremio-official-addons/blob/master/official-addons-v2/src/lib.rs): rust crate · Rust-facing library entry point for v2 consumers. · `official-addons-v2/src/lib.rs`
- [V2 package](https://github.com/stremio/stremio-official-addons/blob/master/official-addons-v2/package.json): npm package · npm metadata for the v2 publishable package. · `official-addons-v2/package.json`
- [V2 crate](https://github.com/stremio/stremio-official-addons/blob/master/official-addons-v2/Cargo.toml): rust crate · Cargo package metadata for publishing to crates.io. · `official-addons-v2/Cargo.toml`
- [V2 output](https://github.com/stremio/stremio-official-addons/tree/master/official-addons-v2): generated artifacts · Built distributable files produced by the v2 pipeline. · `official-addons-v2`

### Release pipeline

GitHub Actions workflows that validate and publish tagged releases.

- [Build workflow](https://github.com/stremio/stremio-official-addons/blob/master/.github/workflows/build.yml): CI validation · GitHub Actions workflow for verification builds. · `.github/workflows/build.yml`
- [Publish workflow](https://github.com/stremio/stremio-official-addons/blob/master/.github/workflows/publish.yml): release automation · Tag-triggered workflow that publishes v1 and v2 artifacts. · `.github/workflows/publish.yml`

### Downstream consumers

Stremio apps and backend systems that load the serialized addon collection.

- **Stremio apps**: downstream consumers · Clients and backend services that consume the generated addon collections.

### Other components

- **AddonCollection**: serialized contract · Stable load/save format that downstream clients consume.
- [Addon list](https://github.com/stremio/stremio-official-addons/blob/master/README.md): curated catalog · Maintained addon definitions that are transformed into distributable artifacts. · `README.md`
- [Deflate macro](https://github.com/stremio/stremio-official-addons/blob/master/deflate-macro/src/lib.rs): rust helper crate · Separate Rust subcrate likely used by the v2 build or runtime packaging. · `deflate-macro/src/lib.rs`
- **npm**: package registry · Publication target for the root package and the v2 npm package.
- **crates.io**: crate registry · Publication target for the v2 Rust crate.

## Connections

- Addon list → Gen script: input · Curated addon definitions are transformed by the v1 generator.
- Gen script → Index JS: generates · Produces the legacy JS entry artifact.
- Gen script → Index JSON: generates · Produces the serialized collection artifact.
- Gen script → AddonCollection: serializes · Emits the AddonCollection load/save format.
- Index JS → Root package: published by · The root package exposes the generated JS entry.
- Index JSON → Root package: published by · The root package can expose raw generated data.
- Addon list → Build script: input · The maintained catalog is also transformed for v2 outputs.
- Build script → V2 output: generates · Builds the v2 distributable package contents.
- V2 output → V2 package: packed by · npm publish uses the generated v2 package files.
- V2 output → V2 crate: packed by · Cargo publish uses the generated crate contents.
- Crate entry → V2 crate: entry point · Defines the Rust crate surface.
- Deflate macro → Build script: supports · Auxiliary Rust code that may assist the v2 packaging pipeline.
- Build workflow → Gen script: validates · CI checks the generation pipeline.
- Build workflow → Build script: validates · CI checks the v2 build pipeline.
- Publish workflow → Root package: publishes · Tag-based release publishes the legacy npm package.
- Publish workflow → V2 package: publishes · Tag-based release publishes the v2 npm package.
- Publish workflow → V2 crate: publishes · Tag-based release publishes the Rust crate.
- Root package → npm: release target · Root v1 package is distributed through npm.
- V2 package → npm: release target · V2 JS package is distributed through npm.
- V2 crate → crates.io: release target · V2 Rust package is distributed through crates.io.
- Index JSON → Stremio apps: consumed by · Older clients and services load the serialized collection directly.
- V2 output → Stremio apps: consumed by · Newer clients and services consume the v2 package outputs.
