# swayam1705/signal architecture

> Architecture diagram of the GitHub repository swayam1705/signal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/swayam1705/signal
- Repository: https://github.com/swayam1705/signal

## Overview

#### 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: [`backend/api/routes.py`](https://github.com/swayam1705/signal/blob/main/backend/api/routes.py) (Query & artifact routes), [`backend/rag/orchestration/pipeline.py`](https://github.com/swayam1705/signal/blob/main/backend/rag/orchestration/pipeline.py) (SignalOrchestrator), [`frontend/src/App.tsx`](https://github.com/swayam1705/signal/blob/main/frontend/src/App.tsx) (Product shell), [`backend/rag/retrieval/hybrid.py`](https://github.com/swayam1705/signal/blob/main/backend/rag/retrieval/hybrid.py) (Hybrid retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Product UI"]
  node_ui_entry["React/Vite entry<br/>frontend entry<br/>[main.tsx]"]
  node_product_shell["Product shell<br/>React application<br/>[App.tsx]"]
  node_ui_results["Result &amp; latency views<br/>UI components<br/>[ResultPanel.tsx]"]
  node_api_client["API client<br/>frontend service<br/>[api.ts]"]
end

subgraph group_api["API runtime"]
  node_fastapi_entry["FastAPI application<br/>backend entry<br/>[main.py]"]
  node_routes["Query &amp; artifact routes<br/>HTTP boundary<br/>[routes.py]"]
  node_container["Dependency container<br/>composition root<br/>[container.py]"]
  node_speech["Speech providers<br/>speech adapter<br/>[providers.py]"]
end

subgraph group_rag["RAG pipeline"]
  node_orchestrator["SignalOrchestrator<br/>RAG control flow<br/>[pipeline.py]"]
  node_query_intelligence["Query intelligence<br/>safety &amp; analysis"]
  node_retrieval["Hybrid retrieval<br/>retrieval layer<br/>[hybrid.py]"]
  node_reranker["Lightweight reranker<br/>evidence ranking<br/>[lightweight.py]"]
  node_context["Context builder<br/>context boundary<br/>[context.py]"]
  node_generation["Generation providers<br/>LLM adapter<br/>[providers.py]"]
  node_guardrails["Grounding guardrails<br/>evidence verifier<br/>[grounding.py]"]
  node_embeddings["Embedding providers<br/>embedding adapter<br/>[providers.py]"]
end

subgraph group_data["Index &amp; evaluation"]
  node_qdrant[("Qdrant vector store<br/>vector index<br/>[qdrant_store.py]")]
  node_active_index["Active index manifest<br/>index metadata<br/>[manifest.json]"]
  node_ingestion["Ingestion pipeline<br/>offline indexing<br/>[ingest.py]"]
  node_evaluation["Evaluation &amp; benchmark<br/>offline reporting<br/>[evaluate.py]"]
  node_evaluation_index["Evaluation artifacts<br/>report index<br/>[index.json]"]
end

node_ui_entry -->|"mounts"| node_product_shell
node_product_shell -->|"renders"| node_ui_results
node_product_shell -->|"uses"| node_api_client
node_api_client -->|"HTTP / stream"| node_routes
node_fastapi_entry -->|"hosts"| node_routes
node_routes -->|"resolves services"| node_container
node_routes -->|"voice requests"| node_speech
node_speech -->|"transcript"| node_orchestrator
node_container -->|"assembles"| node_orchestrator
node_orchestrator -->|"analyzes &amp; checks"| node_query_intelligence
node_orchestrator -->|"embeds query"| node_embeddings
node_embeddings -->|"query vector"| node_retrieval
node_retrieval -->|"vector search"| node_qdrant
node_retrieval -->|"candidate evidence"| node_reranker
node_reranker -->|"selected evidence"| node_context
node_context -->|"bounded context"| node_generation
node_generation -->|"structured answer"| node_guardrails
node_guardrails -->|"grounded answer or refusal"| node_orchestrator
node_ingestion -->|"persists vectors"| node_qdrant
node_ingestion -->|"writes manifest"| node_active_index
node_evaluation -->|"writes reports"| node_evaluation_index
node_routes -->|"serves review data"| node_evaluation_index

click node_ui_entry "https://github.com/swayam1705/signal/blob/main/frontend/src/main.tsx"
click node_product_shell "https://github.com/swayam1705/signal/blob/main/frontend/src/App.tsx"
click node_ui_results "https://github.com/swayam1705/signal/blob/main/frontend/src/components/ResultPanel.tsx"
click node_api_client "https://github.com/swayam1705/signal/blob/main/frontend/src/services/api.ts"
click node_fastapi_entry "https://github.com/swayam1705/signal/blob/main/backend/main.py"
click node_routes "https://github.com/swayam1705/signal/blob/main/backend/api/routes.py"
click node_container "https://github.com/swayam1705/signal/blob/main/backend/core/container.py"
click node_speech "https://github.com/swayam1705/signal/blob/main/backend/speech/providers.py"
click node_orchestrator "https://github.com/swayam1705/signal/blob/main/backend/rag/orchestration/pipeline.py"
click node_query_intelligence "https://github.com/swayam1705/signal/blob/main/backend/services/query_intelligence.py"
click node_retrieval "https://github.com/swayam1705/signal/blob/main/backend/rag/retrieval/hybrid.py"
click node_reranker "https://github.com/swayam1705/signal/blob/main/backend/rag/reranking/lightweight.py"
click node_context "https://github.com/swayam1705/signal/blob/main/backend/rag/orchestration/context.py"
click node_generation "https://github.com/swayam1705/signal/blob/main/backend/rag/generation/providers.py"
click node_guardrails "https://github.com/swayam1705/signal/blob/main/backend/rag/guardrails/grounding.py"
click node_embeddings "https://github.com/swayam1705/signal/blob/main/backend/rag/embeddings/providers.py"
click node_qdrant "https://github.com/swayam1705/signal/blob/main/backend/rag/vector/qdrant_store.py"
click node_active_index "https://github.com/swayam1705/signal/blob/main/data/index/manifest.json"
click node_ingestion "https://github.com/swayam1705/signal/blob/main/scripts/ingest.py"
click node_evaluation "https://github.com/swayam1705/signal/blob/main/scripts/evaluate.py"
click node_evaluation_index "https://github.com/swayam1705/signal/blob/main/reports/evaluations/index.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ui_entry,node_product_shell,node_ui_results,node_api_client toneBlue
class node_fastapi_entry,node_routes,node_container,node_speech toneAmber
class node_orchestrator,node_query_intelligence,node_retrieval,node_reranker,node_context,node_generation,node_guardrails,node_embeddings toneMint
class node_qdrant,node_active_index,node_ingestion,node_evaluation,node_evaluation_index toneRose
```

## Components

### Product UI

- [React/Vite entry](https://github.com/swayam1705/signal/blob/main/frontend/src/main.tsx): frontend entry · `frontend/src/main.tsx`
- [Product shell](https://github.com/swayam1705/signal/blob/main/frontend/src/App.tsx): React application · Presents answers, inspection, judge, performance, and architecture views. · `frontend/src/App.tsx`
- [Result & latency views](https://github.com/swayam1705/signal/blob/main/frontend/src/components/ResultPanel.tsx): UI components · `frontend/src/components/ResultPanel.tsx`
- [API client](https://github.com/swayam1705/signal/blob/main/frontend/src/services/api.ts): frontend service · Uses relative API traffic, including streamed query stages. · `frontend/src/services/api.ts`

### API runtime

- [FastAPI application](https://github.com/swayam1705/signal/blob/main/backend/main.py): backend entry · `backend/main.py`
- [Query & artifact routes](https://github.com/swayam1705/signal/blob/main/backend/api/routes.py): HTTP boundary · Accepts text, NDJSON streaming, and voice queries; exposes review artifacts. · `backend/api/routes.py`
- [Dependency container](https://github.com/swayam1705/signal/blob/main/backend/core/container.py): composition root · Selects local or production adapters and assembles the pipeline. · `backend/core/container.py`
- [Speech providers](https://github.com/swayam1705/signal/blob/main/backend/speech/providers.py): speech adapter · Validates and transcribes voice before shared query orchestration. · `backend/speech/providers.py`

### RAG pipeline

- [SignalOrchestrator](https://github.com/swayam1705/signal/blob/main/backend/rag/orchestration/pipeline.py): RAG control flow · Coordinates measured stages and bounded recovery. · `backend/rag/orchestration/pipeline.py`
- [Query intelligence](https://github.com/swayam1705/signal/blob/main/backend/services/query_intelligence.py): safety & analysis · `backend/services/query_intelligence.py`
- [Hybrid retrieval](https://github.com/swayam1705/signal/blob/main/backend/rag/retrieval/hybrid.py): retrieval layer · Merges cosine vector search and BM25 results. · `backend/rag/retrieval/hybrid.py`
- [Lightweight reranker](https://github.com/swayam1705/signal/blob/main/backend/rag/reranking/lightweight.py): evidence ranking · `backend/rag/reranking/lightweight.py`
- [Context builder](https://github.com/swayam1705/signal/blob/main/backend/rag/orchestration/context.py): context boundary · Bounds selected evidence for generation. · `backend/rag/orchestration/context.py`
- [Generation providers](https://github.com/swayam1705/signal/blob/main/backend/rag/generation/providers.py): LLM adapter · Uses extractive local fallback or OpenAI-compatible JSON generation. · `backend/rag/generation/providers.py`
- [Grounding guardrails](https://github.com/swayam1705/signal/blob/main/backend/rag/guardrails/grounding.py): evidence verifier · Verifies claims and exact citations; unsupported output is refused. · `backend/rag/guardrails/grounding.py`
- [Embedding providers](https://github.com/swayam1705/signal/blob/main/backend/rag/embeddings/providers.py): embedding adapter · Uses deterministic local hashing or multilingual E5. · `backend/rag/embeddings/providers.py`

### Index & evaluation

- [Qdrant vector store](https://github.com/swayam1705/signal/blob/main/backend/rag/vector/qdrant_store.py): vector index · `backend/rag/vector/qdrant_store.py`
- [Active index manifest](https://github.com/swayam1705/signal/blob/main/data/index/manifest.json): index metadata · Checked-in development-fixture index metadata. · `data/index/manifest.json`
- [Ingestion pipeline](https://github.com/swayam1705/signal/blob/main/scripts/ingest.py): offline indexing · Normalizes, deduplicates, chunks, and persists source records. · `scripts/ingest.py`
- [Evaluation & benchmark](https://github.com/swayam1705/signal/blob/main/scripts/evaluate.py): offline reporting · Produces immutable artifacts exposed for inspection. · `scripts/evaluate.py`
- [Evaluation artifacts](https://github.com/swayam1705/signal/blob/main/reports/evaluations/index.json): report index · `reports/evaluations/index.json`

## Connections

- 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
