Thank you for your interest in contributing. This document covers everything you need to get started.
- Node.js 22+
- pnpm 9+
- Docker and Docker Compose (optional)
- Anthropic API key (optional — rule-based classifier runs without one)
git clone https://github.com/viktor-veresh-dev/webhook-ai-router.git
cd webhook-ai-router
pnpm install
cp .env.example .env
# Set your API_KEY in .env
# Optionally set ANTHROPIC_API_KEY for AI classification
pnpm devpnpm test
pnpm test:watch
pnpm test:coverageAll 236 tests run without external dependencies. The Anthropic API is always mocked.
This project follows strict engineering contracts. Before submitting a PR, verify:
- Every function does one thing and is 20 lines or fewer
- No more than 2 levels of nesting — use early returns
- No magic numbers or strings — all go to
src/config/constants.ts - All inputs validated at system boundaries
- Every external I/O wrapped in try/catch with specific error types
- Self-explanatory names, no abbreviations
- Boolean variables use
is*,has*,can*,should*prefixes
The project uses Clean Architecture with four layers:
- Domain — interfaces, models, enums, error types. Zero external dependencies.
- Application — classification, ingestion, routing, processing services. Depends only on Domain.
- Infrastructure — classifiers, destinations, queue, rule store, middleware. Implements Domain interfaces.
- Controllers — HTTP endpoints. Composition root.
Key design patterns: Strategy (classifiers, destinations), Factory (destination creation), Repository (rule store).
- Implement
IDestinationinsrc/domain/interfaces/destination.interface.ts - Register it in
DestinationFactoryatsrc/infrastructure/destinations/destination-factory.ts - Add a rule to
data/rules.jsonwith your newdestinationType - Write tests covering
send()andisHealthy()
- Implement
IClassifierfromsrc/domain/interfaces/classifier.interface.ts - Add selection logic in
ClassificationService - Write tests covering all classification categories
- Fork the repository
- Create a feature branch from
main(git checkout -b feature/your-feature) - Write your code with tests
- Ensure all tests pass (
pnpm test) - Ensure the build succeeds (
pnpm build) - Commit with a clear message describing what changed and why
- Open a pull request against
main
- One concern per PR — don't mix features with refactors
- Every new function must have tests covering happy path, edge cases, and at least one error path
- Update the relevant
.ctx.mdcontext file if you change a module's interface or behavior - No existing tests should break
- No existing log messages should be shortened or removed
Rules live in data/rules.json and reload on every request. You can test rule changes without restarting the service.
Open an issue with:
- Clear description of the problem or suggestion
- Steps to reproduce (for bugs)
- Expected vs actual behavior
- Environment details (OS, Node version)
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.