# lenderson00/bunnyjs architecture

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

- Interactive diagram: https://gitdiagram.com/lenderson00/bunnyjs
- Repository: https://github.com/lenderson00/bunnyjs

## Overview

1. **What this repository is**
   - `bunnyjs` is a small TypeScript client library for the Bunny.net API, specifically the Bunny Stream area.
   - The architecture is library-shaped, not app-shaped: it exposes reusable modules rather than running a server or CLI.

2. **Public entry points**
   - `src/index.ts` is the top-level export surface for consumers.
   - `src/core.ts` appears to provide the shared client foundation used by feature modules.
   - `src/stream/index.ts` is the feature entry point for Stream-specific operations.

3. **Core vs feature-layer split**
   - `src/core.ts` is the shared boundary for common client concerns such as setup, request handling, and API wiring.
   - `src/stream/*` contains the Bunny Stream domain features built on top of that shared core.
   - This keeps transport/client behavior separated from resource-specific operations.

4. **Stream subsystem**
   - The Stream module is split into two resource areas:
     - `src/stream/collections.ts`
     - `src/stream/videos.ts`
   - This suggests the library models Bunny Stream around two main resource types: collections and videos.
   - `src/stream/index.ts` likely composes and re-exports these resource handlers.

5. **Type boundary**
   - `src/@types/bunny/*` holds domain models for the Bunny API objects.
   - Files like `collection.ts` and `video.ts` indicate the API payload shapes are centralized and reused by the runtime code.
   - This separation helps keep runtime logic lightweight and makes the API contract explicit.

6. **Likely data flow**
   - Consumer code imports from `src/index.ts` or the stream entrypoint.
   - A client/core layer is initialized with configuration.
   - Stream methods call through the core layer to interact with Bunny endpoints.
   - Responses are mapped back into the typed Bunny domain objects from `src/@types/bunny/*`.

7. **Module boundaries and responsibilities**
   - Core layer: shared configuration and request execution.
   - Stream layer: resource-specific operations for collections and videos.
   - Types layer: API schema and data contracts.
   - This is a clean three-tier separation for a client SDK.

8. **Testing structure**
   - Tests mirror the source layout:
     - `tests/core.spec.ts`
     - `tests/stream/collections.spec.ts`
     - `tests/stream/video.spec.ts`
   - That alignment strongly suggests each module is tested independently at the same boundary it is exposed.

9. **Runtime and language**
   - The project is TypeScript-based, with `tsconfig.json` and `tsconfig.prod.json` indicating separate development and production builds.
   - `jest.config.ts` shows Jest is used for unit testing.

10. **Repository tooling**
   - Husky hooks (`.husky/pre-commit`, `.husky/commit-msg`) enforce local git quality gates.
   - `commitlint.config.js` indicates commit message formatting is part of the workflow.
   - These tools affect development process, not runtime architecture.

11. **What the architecture diagram should emphasize**
   - A consumer-facing SDK entry point.
   - A shared core client foundation.
   - A Stream feature area split into collections and videos.
   - A dedicated types/contracts layer.
   - A parallel test structure validating each module boundary.

12. **External dependency boundary**
   - The only implied external system is Bunny.net’s API, especially Bunny Stream.
   - The library is the integration layer between application code and that external service.

Main entry points: [`src/core.ts`](https://github.com/lenderson00/bunnyjs/blob/main/src/core.ts) (Core client), [`src/stream/collections.ts`](https://github.com/lenderson00/bunnyjs/blob/main/src/stream/collections.ts) (Collections), [`src/stream/videos.ts`](https://github.com/lenderson00/bunnyjs/blob/main/src/stream/videos.ts) (Videos), [`src/index.ts`](https://github.com/lenderson00/bunnyjs/blob/main/src/index.ts) (SDK entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_src["Source"]
  node_src_index["SDK entry<br/>exports<br/>[index.ts]"]
  node_src_core["Core client<br/>shared client<br/>[core.ts]"]
  node_src_stream_index["Stream entry<br/>feature entry<br/>[index.ts]"]
  node_src_stream_collections["Collections<br/>resource module<br/>[collections.ts]"]
  node_src_stream_videos["Videos<br/>resource module<br/>[videos.ts]"]
  node_types_index["Types entry<br/>type exports<br/>[index.ts]"]
  node_types_collection["Collection type<br/>domain model<br/>[collection.ts]"]
  node_types_video["Video type<br/>domain model<br/>[video.ts]"]
end

subgraph group_tests["Tests"]
  node_test_core["Core spec<br/>unit test<br/>[core.spec.ts]"]
  node_test_stream_collections["Collections spec<br/>unit test"]
  node_test_stream_video["Video spec<br/>unit test<br/>[video.spec.ts]"]
end

subgraph group_tooling["Tooling"]
  node_tsconfig["TS config<br/>build config<br/>[tsconfig.json]"]
  node_tsconfig_prod["Prod TS config<br/>build config<br/>[tsconfig.prod.json]"]
  node_jest_config["Jest config<br/>test config<br/>[jest.config.ts]"]
  node_commitlint_config["Commit lint<br/>git config"]
end

node_external_bunny[("Bunny.net API<br/>external service")]

node_src_index -->|"re-exports"| node_src_core
node_src_index -->|"re-exports"| node_src_stream_index
node_src_stream_index -->|"composes"| node_src_stream_collections
node_src_stream_index -->|"composes"| node_src_stream_videos
node_src_stream_collections -->|"uses"| node_src_core
node_src_stream_videos -->|"uses"| node_src_core
node_src_stream_collections -->|"returns"| node_types_collection
node_src_stream_videos -->|"returns"| node_types_video
node_types_index -->|"re-exports"| node_types_collection
node_types_index -->|"re-exports"| node_types_video
node_src_core -->|"calls"| node_external_bunny
node_src_stream_collections -->|"calls"| node_external_bunny
node_src_stream_videos -->|"calls"| node_external_bunny
node_test_core -.->|"tests"| node_src_core
node_test_stream_collections -.->|"tests"| node_src_stream_collections
node_test_stream_video -.->|"tests"| node_src_stream_videos
node_test_stream_collections -.->|"asserts"| node_types_collection
node_test_stream_video -.->|"asserts"| node_types_video
node_jest_config -->|"configures"| node_test_core
node_jest_config -->|"configures"| node_test_stream_collections
node_jest_config -->|"configures"| node_test_stream_video
node_tsconfig -->|"compiles"| node_src_index
node_tsconfig -->|"compiles"| node_src_core
node_tsconfig -->|"compiles"| node_src_stream_index
node_tsconfig_prod -->|"builds"| node_src_index
node_commitlint_config -.-> node_external_bunny

click node_src_index "https://github.com/lenderson00/bunnyjs/blob/main/src/index.ts"
click node_src_core "https://github.com/lenderson00/bunnyjs/blob/main/src/core.ts"
click node_src_stream_index "https://github.com/lenderson00/bunnyjs/blob/main/src/stream/index.ts"
click node_src_stream_collections "https://github.com/lenderson00/bunnyjs/blob/main/src/stream/collections.ts"
click node_src_stream_videos "https://github.com/lenderson00/bunnyjs/blob/main/src/stream/videos.ts"
click node_types_index "https://github.com/lenderson00/bunnyjs/blob/main/src/@types/bunny/index.ts"
click node_types_collection "https://github.com/lenderson00/bunnyjs/blob/main/src/@types/bunny/collection.ts"
click node_types_video "https://github.com/lenderson00/bunnyjs/blob/main/src/@types/bunny/video.ts"
click node_test_core "https://github.com/lenderson00/bunnyjs/blob/main/tests/core.spec.ts"
click node_test_stream_collections "https://github.com/lenderson00/bunnyjs/blob/main/tests/stream/collections.spec.ts"
click node_test_stream_video "https://github.com/lenderson00/bunnyjs/blob/main/tests/stream/video.spec.ts"
click node_tsconfig "https://github.com/lenderson00/bunnyjs/blob/main/tsconfig.json"
click node_tsconfig_prod "https://github.com/lenderson00/bunnyjs/blob/main/tsconfig.prod.json"
click node_jest_config "https://github.com/lenderson00/bunnyjs/blob/main/jest.config.ts"
click node_commitlint_config "https://github.com/lenderson00/bunnyjs/blob/main/commitlint.config.js"

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_src_index,node_src_core,node_src_stream_index,node_src_stream_collections,node_src_stream_videos,node_types_index,node_types_collection,node_types_video toneBlue
class node_test_core,node_test_stream_collections,node_test_stream_video toneAmber
class node_tsconfig,node_tsconfig_prod,node_jest_config,node_commitlint_config toneMint
class node_external_bunny toneNeutral
```

## Components

### Source

Public SDK surface, shared client core, stream resources, and domain types.

- [SDK entry](https://github.com/lenderson00/bunnyjs/blob/main/src/index.ts): exports · Top-level public export surface for consumers. · `src/index.ts`
- [Core client](https://github.com/lenderson00/bunnyjs/blob/main/src/core.ts): shared client · Common client foundation for setup, request handling, and API wiring. · `src/core.ts`
- [Stream entry](https://github.com/lenderson00/bunnyjs/blob/main/src/stream/index.ts): feature entry · Feature entry point that composes and re-exports Stream operations. · `src/stream/index.ts`
- [Collections](https://github.com/lenderson00/bunnyjs/blob/main/src/stream/collections.ts): resource module · Stream collection operations built on the shared core. · `src/stream/collections.ts`
- [Videos](https://github.com/lenderson00/bunnyjs/blob/main/src/stream/videos.ts): resource module · Stream video operations built on the shared core. · `src/stream/videos.ts`
- [Types entry](https://github.com/lenderson00/bunnyjs/blob/main/src/@types/bunny/index.ts): type exports · Central export surface for Bunny API domain models. · `src/@types/bunny/index.ts`
- [Collection type](https://github.com/lenderson00/bunnyjs/blob/main/src/@types/bunny/collection.ts): domain model · Typed contract for Bunny collection payloads. · `src/@types/bunny/collection.ts`
- [Video type](https://github.com/lenderson00/bunnyjs/blob/main/src/@types/bunny/video.ts): domain model · Typed contract for Bunny video payloads. · `src/@types/bunny/video.ts`

### Tests

Module-aligned unit tests mirroring the source boundaries.

- [Core spec](https://github.com/lenderson00/bunnyjs/blob/main/tests/core.spec.ts): unit test · Tests the shared core client boundary. · `tests/core.spec.ts`
- [Collections spec](https://github.com/lenderson00/bunnyjs/blob/main/tests/stream/collections.spec.ts): unit test · Tests Stream collection operations. · `tests/stream/collections.spec.ts`
- [Video spec](https://github.com/lenderson00/bunnyjs/blob/main/tests/stream/video.spec.ts): unit test · Tests Stream video operations. · `tests/stream/video.spec.ts`

### Tooling

Build, test, and git workflow configuration.

- [TS config](https://github.com/lenderson00/bunnyjs/blob/main/tsconfig.json): build config · TypeScript configuration for development and production builds. · `tsconfig.json`
- [Prod TS config](https://github.com/lenderson00/bunnyjs/blob/main/tsconfig.prod.json): build config · Production-specific TypeScript configuration. · `tsconfig.prod.json`
- [Jest config](https://github.com/lenderson00/bunnyjs/blob/main/jest.config.ts): test config · Jest configuration for unit tests. · `jest.config.ts`
- [Commit lint](https://github.com/lenderson00/bunnyjs/blob/main/commitlint.config.js): git config · Commit message linting rules. · `commitlint.config.js`

### Other components

- **Bunny.net API**: external service · Remote Bunny Stream API consumed by the SDK.

## Connections

- SDK entry → Core client: re-exports · Public SDK surface exposes the shared client foundation.
- SDK entry → Stream entry: re-exports · Public SDK surface exposes the Stream feature entry point.
- Stream entry → Collections: composes · Stream entry composes collection operations.
- Stream entry → Videos: composes · Stream entry composes video operations.
- Collections → Core client: uses · Collections operations rely on the shared client core.
- Videos → Core client: uses · Video operations rely on the shared client core.
- Collections → Collection type: returns · Collection methods use collection domain models.
- Videos → Video type: returns · Video methods use video domain models.
- Types entry → Collection type: re-exports · Types entry centralizes collection models.
- Types entry → Video type: re-exports · Types entry centralizes video models.
- Core client → Bunny.net API: calls · Core client sends requests to Bunny.net.
- Collections → Bunny.net API: calls · Collection endpoints are backed by Bunny Stream.
- Videos → Bunny.net API: calls · Video endpoints are backed by Bunny Stream.
- Core spec → Core client: tests · Core spec validates the shared client boundary.
- Collections spec → Collections: tests · Collections spec validates collection operations.
- Video spec → Videos: tests · Video spec validates video operations.
- Collections spec → Collection type: asserts · Collections tests exercise collection contracts.
- Video spec → Video type: asserts · Video tests exercise video contracts.
- Jest config → Core spec: configures · Jest config drives unit test execution.
- Jest config → Collections spec: configures · Jest config drives unit test execution.
- Jest config → Video spec: configures · Jest config drives unit test execution.
- TS config → SDK entry: compiles · TypeScript build configuration covers source modules.
- TS config → Core client: compiles · TypeScript build configuration covers source modules.
- TS config → Stream entry: compiles · TypeScript build configuration covers source modules.
- Prod TS config → SDK entry: builds · Production TypeScript configuration targets the library sources.
- Commit lint → Bunny.net API: Commit workflow tooling is separate from runtime architecture.
