You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document defines the three main components that comprise the Semantic-Ticket-Search system. Each component has distinct responsibilities, deployment patterns, and security boundaries.
🏗️ Component Overview
Component
Container
Runtime
Access Pattern
Primary Function
Trainer
semantic-ticket-trainer
Batch (cron/CI)
Write snapshots, Read/Write Freshservice
Build department-aware similarity index from historical tickets
API Server
semantic-ticket-api
Always-on daemon
Read snapshots, Read/Write Freshservice
Real-time duplicate detection & merging within departments
Review Console
streamlit or embedded
On-demand
Read via API Server
Human-in-the-loop validation & active learning with department isolation
🚂 Trainer Component
Primary Responsibility
Generate immutable, timestamped snapshots containing FAISS similarity indexes and ticket metadata for consumption by the API Server.
API Key Security: Never logged or exposed in stdout
Volume Access: Write-only to shared volume, no read dependencies on API Server
Isolation: Runs in separate container with minimal attack surface
🌐 API Server Component
Primary Responsibility
Provide low-latency HTTP endpoints for real-time duplicate detection, manual review workflows, and system management.
Startup Sequence
Snapshot Discovery: Wait for valid snapshot in /shared/current/
Model Loading: Initialize SentenceTransformer based on snapshot metadata
Memory Mapping: Load FAISS index into memory for fast queries
Thread Pool: Pre-warm worker threads for concurrent request handling
Core Endpoints
Production Endpoints
Route
Method
Authentication
Purpose
/webhook
POST
HMAC-SHA256 (optional)
Real-time duplicate detection & auto-merge
/healthz
GET
None
Kubernetes readiness/liveness probe
/metrics
GET
None
Prometheus metrics exposition
Management Endpoints
Route
Method
Authentication
Purpose
/reloadIndex
POST
X-Reload-Token header
Hot-reload new snapshots
Review & Active Learning Endpoints
Route
Method
Authentication
Purpose
/review
GET
None
Human review UI (HTML)
/candidates
GET
None
Potential duplicate pairs (JSON)
/label
POST
None
Submit human feedback for active learning
Request Processing Pipeline
graph TD
A[Webhook Request] --> B[HMAC Validation]
B --> C[Fetch Ticket from FS]
C --> D[Extract Department ID]
D --> E[Generate Embedding]
E --> F[Department-Filtered ANN Search]
F --> G[Probability Calculation<br/>+Email +Dept Bonuses]
G --> H{Above Threshold &<br/>Same Department?}
H -->|Yes| I[Execute Merge]
H -->|No| J[Log Unmerged]
I --> K[Return Success]
J --> K
Loading
Concurrency & Performance
Thread Pool: All I/O operations (FS API, embedding, merge) run in thread pool
Memory Efficiency: FAISS index memory-mapped for fast access
Cache Strategy: LRU caches for embedder and analyzer instances
Hot Reload: <200ms reload time with zero request failures
Failure Modes & Resilience
Failure Scenario
Detection
Mitigation
Snapshot corruption
503 errors on /healthz
Automatic rollback to previous snapshot
Memory exhaustion
Container metrics
Kubernetes resource limits & restart
API rate limiting
HTTP 429 responses
Exponential backoff with jitter
FAISS index corruption
Search exceptions
Graceful degradation to exact similarity
🕵️ Review Console Component
Primary Responsibility
Provide human-in-the-loop validation for edge cases and continuous improvement through active learning feedback.
Architecture Patterns
Embedded Mode (Default)
Integrated directly into API Server as /review endpoint
Lightweight Alpine.js + TailwindCSS frontend
No additional deployment complexity
Standalone Mode (Advanced)
Separate Streamlit application (src/review_console.py)
Rich UI with session management and batch operations
Ideal for dedicated review teams
Core Workflows
Candidate Generation
Query tickets within configurable date range (REVIEW_DAYS_BACK)
Filter by similarity thresholds (REVIEW_SIM_LOWER to REVIEW_SIM_UPPER)
Apply department isolation - only consider pairs from the same department
Exclude already-labeled pairs from current session
Rank by duplicate probability (highest confidence first)
Human Feedback Loop
graph LR
A[Generate Candidates] --> B[Present to Human]
B --> C{Human Decision}
C -->|Approve| D[Execute Merge + Label]
C -->|Deny| E[Label as Non-Duplicate]
D --> F[Update Training Data]
E --> F
F --> A
Loading
Session Management
Persistence: Track processed pairs within browser session
Deduplication: Avoid showing same pair twice in one session
Progress Tracking: Visual feedback on review completion
Configuration Parameters
Variable
Purpose
Default
REVIEW_USER
Attribution for human labels
anonymous
REVIEW_SIM_LOWER
Minimum similarity for candidates
0.65
REVIEW_SIM_UPPER
Maximum similarity (below auto-merge)
0.90
REVIEW_MAX
Maximum candidates per session
100
REVIEW_DAYS_BACK
Historical window for ticket selection
60
🔄 Inter-Component Communication
Data Flow Architecture
graph TD
A[Freshservice API] --> B[Trainer]
B --> C[Shared Volume<br/>/shared/snapshots/]
C --> D[API Server]
D --> E[Review Console]
E --> F[Human Reviewer]
F --> D
D --> A
Loading
Shared Volume Contract
The only direct integration between components is the shared volume: