A comprehensive, production-ready template management framework for integrating Claude AI with n8n workflows. This system provides secure, scalable prompt template management with comprehensive monitoring, authentication, and deployment capabilities.
- Template Management: Automatic discovery, validation, and quality scoring
- Multi-Provider Support: Claude, OpenAI, and local LLM providers
- n8n Integration: Seamless workflow integration with REST API
- Version Control: Semantic versioning with change tracking
- Input Sanitization: Comprehensive validation against injection attacks
- API Key Authentication: Secure access control with rate limiting
- Error Handling: Sanitized error messages without information disclosure
- HTTPS Support: Production-ready SSL/TLS configuration
- Health Checks: Comprehensive service monitoring with readiness/liveness probes
- Metrics Collection: Performance tracking and usage analytics
- Request Monitoring: Real-time request/response tracking
- Logging: Structured logging with configurable levels
- Docker Support: Multi-stage production builds with security best practices
- Kubernetes Ready: Complete K8s manifests with auto-scaling
- CI/CD Pipeline: GitHub Actions with automated testing and deployment
- Environment Management: Comprehensive configuration management
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β n8n Workflow ββββββ API Gateway ββββββ Claude API β
βββββββββββββββββββ β (Rate Limiting) β βββββββββββββββββββ
β (Authentication)β
βββββββββββββββββββ β (Input Valid.) β βββββββββββββββββββ
β External Apps ββββββ ββββββ OpenAI API β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
ββββββββββββββββββββ
β Template Manager β
β - Discovery β
β - Validation β
β - Caching β
β - Quality Score β
ββββββββββββββββββββ
- Node.js 16.x or higher
- Docker (optional, for containerized deployment)
- Anthropic API key
# Clone the repository
git clone https://github.com/bader1919/n8n-claude-prompt-system.git
cd n8n-claude-prompt-system
# Install dependencies
npm install
# Configure environment
cp .env.example .env
# Edit .env with your API keys and configurationEdit .env file:
# Required
ANTHROPIC_API_KEY=sk-ant-your-api-key-here
API_KEYS=your-secure-api-key,another-key
# Optional
NODE_ENV=development
PORT=3000
LOG_LEVEL=info# Development
npm run dev
# Production
npm start
# Using Docker
docker-compose up -dcurl http://localhost:3000/api/healthAll API requests require authentication via API key:
curl -H "x-api-key: your-api-key" http://localhost:3000/api/templatescurl -X POST http://localhost:3000/api/generate \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-key" \
-d '{
"template": "business/customer_support",
"variables": {
"customer_name": "John Doe",
"issue_description": "Login problem",
"urgency_level": "high"
},
"options": {
"temperature": 0.7,
"maxTokens": 1000
}
}'# All templates
curl -H "x-api-key: your-api-key" http://localhost:3000/api/templates
# By category
curl -H "x-api-key: your-api-key" http://localhost:3000/api/templates/businesscurl -H "x-api-key: your-api-key" http://localhost:3000/api/metrics# Build and run
docker-compose up -d
# Check status
docker-compose ps
# View logs
docker-compose logs -f# Use production compose file
docker-compose -f docker-compose.prod.yml up -d# Deploy to Kubernetes
kubectl apply -f k8s-deployment.yaml
# Scale horizontally
kubectl scale deployment n8n-claude-prompt-system --replicas=3# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run linter
npm run lint
# Fix linting issues
npm run lint:fix- Security: Input validation, authentication, sanitization
- API Endpoints: All REST endpoints with various scenarios
- Providers: Claude API integration and error handling
- Error Handling: Comprehensive error scenarios
/api/health- Overall system health/api/health/ready- Readiness probe (for load balancers)/api/health/live- Liveness probe (for container orchestration)/api/metrics- Performance and usage metrics
- Request count and error rates
- Response time percentiles
- Template usage statistics
- Provider performance metrics
- System resource utilization
- Template injection prevention
- Variable sanitization
- Malicious pattern detection
- Content length limits
- API key-based authentication
- Rate limiting per key
- Request origin validation
- Secure error responses
- HTTPS enforcement
- Security headers (Helmet)
- Non-root container execution
- Secrets management best practices
- Create template file in
templates/category/name.txt - Define variables using
{{variable_name}}syntax - Create variable definitions in
variables/name.json - System automatically discovers and validates
Instructions: Clear instructions for the AI
Context: Background information about the task
Variables: {{variable_name}} placeholders
Output: Expected response format
Example content...
Templates are automatically scored (0-100) based on:
- Structure completeness
- Variable usage
- Content quality
- Best practices compliance
- Claude: Latest Anthropic API with proper error handling
- OpenAI: GPT models with function calling
- Local: Support for local LLM deployments
- Template caching with TTL
- Response time tracking
- Automatic rate limiting
- Resource usage monitoring
- n8n Workflows: Pre-built workflow templates
- REST API: Complete OpenAPI specification
- Webhook Support: Event-driven template updates
- Database Ready: Schema for persistent storage
- Setup Guide: Comprehensive setup instructions
- Template Management: Template creation and management
- Deployment Guide: Production deployment instructions
- API Documentation: Complete API reference
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Run tests (
npm test) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
# Install development dependencies
npm install
# Run in development mode with auto-reload
npm run dev
# Run tests with coverage
npm run test:coverage
# Lint and fix code style
npm run lint:fixThis project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
- Database integration for persistent storage
- Advanced analytics and reporting
- Template marketplace
- Multi-tenant support
- Advanced caching strategies
- GraphQL API
- Real-time collaboration features
Note: This system is designed for production use with comprehensive security, monitoring, and deployment features. For development purposes, see the simplified setup in the basic branch.