How lenderson00/bunnyjs works
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: core.ts Core client · collections.ts Collections · videos.ts Videos · index.ts SDK entry
Components 16
Source
Public SDK surface, shared client core, stream resources, and domain types.
- SDK entry · Top-level public export surface for consumers.
src/index.ts - Core client · Common client foundation for setup, request handling, and API wiring.
src/core.ts - Stream entry · Feature entry point that composes and re-exports Stream operations.
src/stream/index.ts - Collections · Stream collection operations built on the shared core.
src/stream/collections.ts - Videos · Stream video operations built on the shared core.
src/stream/videos.ts - Types entry · Central export surface for Bunny API domain models.
src/@types/bunny/index.ts - Collection type · Typed contract for Bunny collection payloads.
src/@types/bunny/collection.ts - Video type · Typed contract for Bunny video payloads.
src/@types/bunny/video.ts
Tests
Module-aligned unit tests mirroring the source boundaries.
- Core spec · Tests the shared core client boundary.
tests/core.spec.ts - Collections spec · Tests Stream collection operations.
tests/stream/collections.spec.ts - Video spec · Tests Stream video operations.
tests/stream/video.spec.ts
Tooling
Build, test, and git workflow configuration.
- TS config · TypeScript configuration for development and production builds.
tsconfig.json - Prod TS config · Production-specific TypeScript configuration.
tsconfig.prod.json - Jest config · Jest configuration for unit tests.
jest.config.ts - Commit lint · Commit message linting rules.
commitlint.config.js
Other components
- Bunny.net API · Remote Bunny Stream API consumed by the SDK.
Connections 26
- 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.