When generating code for this repository:
- Version Compatibility: Always respect the exact versions of Node.js, TypeScript, and libraries used in this project
- Codebase Patterns: Scan the codebase for established patterns before generating code
- Architectural Consistency: Maintain the layered architecture and established module boundaries
- Performance: Keep to best-practices to maintain high performance
- Code Quality: Prioritize maintainability, type safety, and consistency with existing patterns
- Testing: Follow the established Vitest testing patterns
- Runtime: Node.js
- Language: TypeScript
- Package Manager: pnpm
- Testing: Vitest with @vitest/coverage-v8
- Benchmarking: Vitest
- Code Quality: Biome (formatting, linting)
- Build: TypeScript compiler
src/
├── index.ts # Public API exports
├── adapter/ # Hardware adapter layer (Z-Stack, EZSP, etc.)
├── buffalo/ # Binary data serialization/deserialization
├── controller/ # Core business logic
│ ├── controller.ts # Main controller orchestration
│ ├── database.ts # Persistence layer
│ ├── helpers/ # Shared utilities
│ └── model/ # Domain models (Device, Endpoint, Group)
├── models/ # Backup and configuration models
├── utils/ # Cross-cutting utilities
└── zspec/ # Zigbee specification implementation
├── zcl/ # Zigbee Cluster Library
└── zdo/ # Zigbee Device Objects
test/ # Vitest test/bench files with mocks
dist/ # Compiled JavaScript output
- Separation of Concerns: Adapter layer handles hardware communication, controller handles business logic
- Entity Pattern: Device, Endpoint, Group, Entity form a hierarchy
- Event-Driven: Controller extends EventEmitter for loose coupling
- Static Caching: Device and Group use static Maps for singleton-like behavior
- Database Abstraction: All persistence goes through
database.ts
Use JSDoc, following existing patterns.
- Official API Documentation
- GitHub Repository
- Related Project: Zigbee2MQTT