How swayam1705/signal works
Purpose and entry points
SIGNAL is an inspectable voice/text RAG system: retrieve evidence, generate structured answers, verify sentence-level support/citations, or safely refuse. The FastAPI backend starts at backend/main.py; HTTP routes are in backend/api/routes.py. The React/Vite UI starts at frontend/src/main.tsx and composes its product shell in frontend/src/App.tsx.
Runtime composition and dependency wiring
Configuration selects local deterministic versus production adapters, including provider credentials, model dimensions, CORS, and dataset/index compatibility. A container assembles providers and the orchestration pipeline rather than exposing direct implementation coupling.
• backend/core/config.py
• backend/core/container.py
• backend/models/schemas.py
Python 3.12+ hosts the API and RAG runtime; Node 20+ hosts/builds the frontend. Docker Compose runs backend/frontend and mounts data/; Nginx proxies relative API traffic.
• docker-compose.yml
• Dockerfile
• frontend/nginx.conf
Request and voice boundary
Text requests enter /api/query or NDJSON stage streaming at /api/query/stream; voice is validated/transcribed then enters the same orchestrator through /api/query/voice. Speech is isolated behind a provider adapter, with ElevenLabs Scribe available only when configured.
• backend/api/routes.py
• backend/speech/providers.py
• frontend/src/services/api.ts
RAG orchestration pipeline
SignalOrchestrator is the principal control flow: query intelligence and safety checks precede embedding/retrieval; retrieved evidence is reranked, bounded into context, generated into a structured response, and grounded. It emits measured stage callbacks for streaming and permits bounded recovery rather than unbounded retries.
• backend/rag/orchestration/pipeline.py
• backend/rag/orchestration/context.py
• backend/services/query_intelligence.py
Indexing, retrieval, and ranking
Ingestion converts fixture or Hugging Face MSMARCO-XI records into normalized, deduplicated, stably identified chunks and persists manifest/chunk data plus Qdrant state. At query time, cosine vector retrieval and BM25 are hybrid-merged, then a deterministic feature-based relevance reranker selects evidence. The checked-in active index is development-fixture data.
• scripts/ingest.py
• backend/rag/chunking/strategies.py
• backend/rag/retrieval/hybrid.py
• backend/rag/reranking/lightweight.py
• backend/rag/vector/qdrant_store.py
• data/index/manifest.json
Provider and evidence-trust boundaries
Embedding and generation providers expose local fallbacks and production adapters: deterministic hashing/extractive behavior locally; sentence-transformers multilingual E5 and OpenAI-compatible JSON generation in production. Guardrails assess material-query evidence, injection/unsafe conditions, claims, exact citations, and grounding; unsupported output becomes refusal.
• backend/rag/embeddings/providers.py
• backend/rag/generation/providers.py
• backend/rag/guardrails/engine.py
• backend/rag/guardrails/grounding.py
Inspection, evaluation, and product UI
The frontend presents query results, stage timing, system truth, judge, performance, and architecture views; it is a consumer of the backend API, not the RAG execution host. Offline scripts generate immutable evaluation and benchmark artifacts, which API routes expose for review.
• frontend/src/pages/HomePage.tsx
• frontend/src/components/LatencyWaterfall.tsx
• frontend/src/components/ResultPanel.tsx
• scripts/evaluate.py
• scripts/benchmark.py
• reports/evaluations/index.json
Main entry points: routes.py Query & artifact routes · pipeline.py SignalOrchestrator · App.tsx Product shell · hybrid.py Hybrid retrieval
Components 21
Product UI
- React/Vite entry
frontend/src/main.tsx - Product shell · Presents answers, inspection, judge, performance, and architecture views.
frontend/src/App.tsx - Result & latency views
frontend/src/components/ResultPanel.tsx - API client · Uses relative API traffic, including streamed query stages.
frontend/src/services/api.ts
API runtime
- FastAPI application
backend/main.py - Query & artifact routes · Accepts text, NDJSON streaming, and voice queries; exposes review artifacts.
backend/api/routes.py - Dependency container · Selects local or production adapters and assembles the pipeline.
backend/core/container.py - Speech providers · Validates and transcribes voice before shared query orchestration.
backend/speech/providers.py
RAG pipeline
- SignalOrchestrator · Coordinates measured stages and bounded recovery.
backend/rag/orchestration/pipeline.py - Query intelligence
backend/services/query_intelligence.py - Hybrid retrieval · Merges cosine vector search and BM25 results.
backend/rag/retrieval/hybrid.py - Lightweight reranker
backend/rag/reranking/lightweight.py - Context builder · Bounds selected evidence for generation.
backend/rag/orchestration/context.py - Generation providers · Uses extractive local fallback or OpenAI-compatible JSON generation.
backend/rag/generation/providers.py - Grounding guardrails · Verifies claims and exact citations; unsupported output is refused.
backend/rag/guardrails/grounding.py - Embedding providers · Uses deterministic local hashing or multilingual E5.
backend/rag/embeddings/providers.py
Index & evaluation
- Qdrant vector store
backend/rag/vector/qdrant_store.py - Active index manifest · Checked-in development-fixture index metadata.
data/index/manifest.json - Ingestion pipeline · Normalizes, deduplicates, chunks, and persists source records.
scripts/ingest.py - Evaluation & benchmark · Produces immutable artifacts exposed for inspection.
scripts/evaluate.py - Evaluation artifacts
reports/evaluations/index.json
Connections 22
- React/Vite entry → Product shell: mounts
- Product shell → Result & latency views: renders
- Product shell → API client: uses
- API client → Query & artifact routes: HTTP / stream
- FastAPI application → Query & artifact routes: hosts
- Query & artifact routes → Dependency container: resolves services
- Query & artifact routes → Speech providers: voice requests
- Speech providers → SignalOrchestrator: transcript
- Dependency container → SignalOrchestrator: assembles
- SignalOrchestrator → Query intelligence: analyzes & checks
- SignalOrchestrator → Embedding providers: embeds query
- Embedding providers → Hybrid retrieval: query vector
- Hybrid retrieval → Qdrant vector store: vector search
- Hybrid retrieval → Lightweight reranker: candidate evidence
- Lightweight reranker → Context builder: selected evidence
- Context builder → Generation providers: bounded context
- Generation providers → Grounding guardrails: structured answer
- Grounding guardrails → SignalOrchestrator: grounded answer or refusal
- Ingestion pipeline → Qdrant vector store: persists vectors
- Ingestion pipeline → Active index manifest: writes manifest
- Evaluation & benchmark → Evaluation artifacts: writes reports
- Query & artifact routes → Evaluation artifacts: serves review data