The OpenWebUI GitHub Connector is a Kubernetes-native application that synchronizes files from GitHub repositories to OpenWebUI knowledge bases using an adapter architecture pattern.
- Interface:
adapter.Adapterdefines the contract for data source adapters - GitHub Adapter: Implements GitHub API integration for repository file fetching
- Extensible: Easy to add new adapters (GitLab, Bitbucket, etc.)
- File Diffing: Uses SHA256 hashing to detect file changes
- Local Storage: Maintains files on persistent volumes
- OpenWebUI Integration: Handles file uploads and knowledge base association
- Cron-based: Uses robfig/cron for scheduled synchronization
- Configurable: Supports various interval patterns (1h, 2h, etc.)
- Graceful Shutdown: Properly handles termination signals
- YAML-based: Primary configuration via YAML files
- Environment Override: Environment variables override file settings
- Kubernetes Integration: ConfigMaps and Secrets support
- HTTP Endpoints:
/healthand/readyfor Kubernetes probes - Structured Logging: JSON-formatted logs with configurable levels
- Error Handling: Comprehensive error handling and recovery
GitHub Repository → GitHub Adapter → Sync Manager → OpenWebUI API
↓
Local Storage (PVC)
- Scheduler Trigger: Cron job triggers sync process
- Adapter Fetch: GitHub adapter fetches repository files
- File Processing: Files are filtered (text files only) and hashed
- Change Detection: Compare hashes with previously synced files
- Local Storage: Save files to persistent volume
- OpenWebUI Upload: Upload new/changed files to OpenWebUI
- Knowledge Association: Add files to specified knowledge base
- Index Update: Update local file index for future comparisons
POST /api/v1/files/- Upload filesGET /api/v1/knowledge/- List knowledge sourcesPOST /api/v1/knowledge/{id}/file/add- Add file to knowledgePOST /api/v1/knowledge/{id}/file/remove- Remove file from knowledge
GET /repos/{owner}/{repo}/contents- Fetch repository contents- File content retrieval via GitHub's content API
- Markdown (
.md) - Text files (
.txt) - Code files (
.go,.py,.js,.ts, etc.) - Configuration files (
.yaml,.json,.env) - Documentation files (
.rst,.adoc) - And many more text-based formats
- Binary files are automatically excluded
- Large files are handled via GitHub's download URLs
- File size limits can be configured
- Persistent Volume: Kubernetes PVC for data persistence
- File Organization: Files organized by source and path
- Index Management: JSON-based file index for change tracking
{
"source:path": {
"path": "file.md",
"hash": "sha256_hash",
"file_id": "openwebui_file_id",
"source": "github",
"synced_at": "2024-01-01T00:00:00Z",
"modified": "2024-01-01T00:00:00Z"
}
}- Network failures are retried with exponential backoff
- GitHub API rate limits are respected
- OpenWebUI API failures are logged and retried
- Application can recover from crashes
- File index is persisted and restored
- Partial syncs are resumed on restart
- GitHub Personal Access Tokens
- OpenWebUI API Keys
- Kubernetes Secrets for credential management
- HTTPS for all external API calls
- Configurable timeouts and retry limits
- No sensitive data in logs
- Structured JSON logging
- Configurable log levels
- Request/response logging for debugging
- Liveness probe:
/health - Readiness probe:
/ready - Kubernetes-native health monitoring
- Sync operation counts
- File processing statistics
- Error rates and types
- Stateless design allows multiple replicas
- File index can be shared via external storage
- Adapter instances can be distributed
- Configurable resource limits
- Memory usage scales with repository size
- CPU usage scales with sync frequency
- Deployment with health checks
- PersistentVolumeClaim for storage
- ConfigMap for configuration
- Secrets for credentials
- Multi-stage build for minimal image size
- Alpine Linux base image
- Non-root user for security
OPENWEBUI_BASE_URL: OpenWebUI instance URLOPENWEBUI_API_KEY: API authenticationGITHUB_TOKEN: GitHub authenticationGITHUB_KNOWLEDGE_ID: Target knowledge baseSTORAGE_PATH: Local storage pathLOG_LEVEL: Logging verbosity
log_level: info
schedule:
interval: 1h
storage:
path: /data
openwebui:
base_url: "http://localhost:8080"
api_key: ""
github:
enabled: true
token: ""
repositories:
- "owner/repo1"
- "owner/repo2"
knowledge_id: ""- Additional adapters (GitLab, Bitbucket)
- Webhook-based real-time sync
- File content transformation
- Advanced filtering rules
- Sync status dashboard
- Metrics and alerting
- Plugin architecture for custom adapters
- Custom file processors
- Integration with CI/CD pipelines
- Multi-tenant support