Skip to main content

Solution Architecture — Retrieva

The Solution Architecture Document: how the whole system fits together, the non-functional targets, the threat model, and the decision log. This page indexes the detailed design docs (it does not duplicate them) and adds the cross-cutting views (C4, NFR, threats, ADR log). Owner: SA/TL. Reviewed at the architecture-spine + security gates. Certification evidence: BC02 (concevoir & développer) + BC03 (déployer & sécuriser).

1. Business context​

Retrieva is a DORA-compliance RAG platform: vendor/contract documents → AI-generated DORA gap-analysis report → conversational Q&A, with the ICT third-party register modelled as a graph (the concentration graph). It runs on the ktayl-solution IS (self-hosted k3s) and is the RNCP39583 certification deliverable. Public at retrieva.online.

2. C4 — Context (who/what it talks to)​

                         ┌──────────────┐
Analyst / │ │ JWT auth (own login/register)
Compliance ─▶│ Retrieva │◀── no external IdP dependency
user │ (SPA + API) │
└──────┬───────┘
┌─────────────────────┼─────────────────────┐
▼ ▼ ▼
AI platform (ai ns) datastores (same ns) observability
LiteLLM gateway ──▶ EU MongoDB (→Postgres Langfuse (app traces)
providers (governed) RTV-45) · Redis/Valkey Prometheus/Grafana
Qdrant (vectors) · Qdrant collection
markitdown/docling (per-tenant)

Trust boundary: Retrieva calls only the governed LiteLLM gateway + Qdrant + its own datastores + Langfuse + the controller MinIO (media) — enforced by a default-deny egress NetworkPolicy (security/data-protection, llm-guardrails).

3. C4 — Container (the pieces, one cluster)​

The view below is generated from code — docs/diagrams/retrieva_container.py (mingrammer diagrams + Graphviz). Edit the .py and re-run to refresh — no hand-drawn drift. It shows the target datastore (PostgreSQL, post-RTV-45) and Authentik SSO as planned (today the backend uses its own JWT auth). Full-resolution SVG →

Retrieva C4 container view

Text version
 ingress-nginx (retrieva.online via Cloudflare tunnel; retrieva-dev.* via Tailscale)
│ /api,/socket.io → backend │ / → frontend
▼ ▼
retrieva-backend (Express 5, :3007) retrieva-frontend (Next.js 16, :3000)
├─ RAG pipeline, auth (JWT), authz (RBAC + tenant) runtime-injected API URL (env-agnostic image)
├─ MongoDB (app data; → PostgreSQL+Drizzle, RTV-45)
├─ Redis/Valkey (cache/queues)
├─ Qdrant (ai ns) — per-tenant vector collection
└─ LiteLLM gateway (ai ns) — generation + embeddings (EU/governed)

Detail: overview · rag-pipeline · multi-tenancy · concentration-graph · ai-infrastructure.

4. C4 — Deployment (how it runs)​

Two envs (dev retrieva-dev / prod retrieva), same image. CI builds+proves (Harbor dev + ghcr prod SHA, cosign+SBOM) → Kargo (git Warehouse: backend+frontend pinned to one commit SHA) promotes dev→prod via a CODEOWNERS-gated PR → ArgoCD reconciles (minicloud-gitops/services/retrieva/). Deploy artefact is migrating to the GAP wrapper chart (RTV-57). Secrets via ESO→Vault; never in the image. Tight per-namespace ResourceQuotas (maxSurge:0 rollouts).

5. Non-functional requirements (register)​

NFRTargetHow met / measured
Availabilityprod backend+frontend ≥ 2 replicas; Mongo/Redis singletons (RWO)ArgoCD selfHeal + PDB; datastore HA = RTV-45 follow-up
LatencyRAG answer p95 reasonable for interactive Q&ALangfuse trace timings; streaming responses (300s ingress timeout)
Scale / capacityfits retrieva ns quota (req 1 CPU / 2Gi, limit 6 CPU / 6Gi, 16 pods)minicloud-gitops/services/retrieva/.../quota.yaml
Durability / RPOapp data + vectors on Longhorn; backups platform-levelLonghorn PVC + Velero/MinIO (platform DR)
SecurityJWT auth, RBAC+tenant isolation, PII stays in-cluster/EU, secrets in Vault§6 threat model + security/
AI governancegeneration/embeddings via LiteLLM only; EU residency; vision cost-gatedegress netpol + llm-model-selection; prod vision-spend watch
Observabilityapp traces + RED metrics + costLangfuse (dedicated project) + Prometheus/Grafana
ComplianceDORA register integrity; GDPR residency; RGAA accessibilitydora-tprm-domain-model · cert BC02/BC03

6. Threat model (STRIDE-lite → mitigation)​

ThreatVectorMitigation
Spoofingstolen token / weak authJWT access+refresh, rotation (jwt-secret-rotation); short-lived access tokens
Tamperingcross-tenant data accesstenant-scoped queries + per-tenant Qdrant collection (multi-tenancy, authorization-model)
Repudiationno audit trailapp audit logging + Langfuse trace per request (user/session tagged)
Information disclosurePII → external LLM; secret leakdefault-deny egress → LiteLLM only (EU/governed); Presidio masking at the gateway; secrets via ESO→Vault, never logged/committed
DoSunbounded ingest / LLM spendingress body-size + timeouts; vision captioning gated (ingest-only, per-doc cap) + a prod spend alert
Elevation of privilegeRBAC bypasshierarchical RBAC + domain roles + SoD (authorization-model; RTV-51→56)
Prompt injection / jailbreakmalicious doc/queryLLM guardrails (llm-guardrails); gateway red-team gate

7. ADR decision log (the why)​

ADRDecisionStatusOwner
dora-tprm-domain-modelthe graph IS the DORA register (arrangement-centric)AcceptedSA
datastore-postgresqlMongoDB → PostgreSQL + Drizzle (recursive-CTE concentration query stays typed) — RTV-45Accepted (pending impl)SA/DBA
authorization-modelhierarchical RBAC + domain roles + SoD (supersedes ad-hoc) — RTV-51→56Accepted (pending impl)SA/SEC
llm-model-selectiontiered models via LiteLLM; EU/governed for prodAcceptedSA
semantic-chunkingsemantic chunking for retrieval qualityAcceptedSA
multimodal-ingestionDocling/VLM figure captioning, cost-gated (RTV-14)AcceptedSA
prompt-managementLangfuse label-routed prompts, Git fallbackAcceptedSA
deployment (gitops)GAP wrapper chart + Kargo git-Warehouse — RTV-57PendingDO/SA
identity (minicloud-gitops ADR)Retrieva ships own JWT auth; platform workforce = AuthentikAcceptedSA/SEC
ADR-AGENT-01 (agentic-assessment-orchestrator §8)deterministic LangGraph supervisor + a CrewAI crew over A2A, human-gated (Path A — amends RTV-76, keeps determinism) — RTV-77AcceptedSA/TL
ADR-AGENT-02 (agentic-assessment-orchestrator §8)A2A libs: crewai[a2a]/a2a-sdk (crew server) + @a2a-js/sdk (supervisor client), Spec v1.0 — RTV-79AcceptedSA/TL
ADR-AGENT-03 (agentops-hitl-workspace §7)AgentOps HITL frontend — first-class Approval Center, separated run/approval state machines, socket.io transport, backend-owned resume — RTV-84AcceptedSA/TL

8. Risks / trade-offs​

  • Single-instance Mongo/Redis (RWO) = no datastore HA yet → accepted for now; revisit with RTV-45.
  • Dual-image git-Warehouse coupling (backend+frontend promoted together) → deliberate (avoids mixed-Freight); the cost is no independent frontend-only promotion.
  • Self-hosted everything trades managed-service convenience for sovereignty — the platform thesis.

9. Evolution roadmap​

RTV-45 (Mongo→Postgres) → RTV-57 (wrapper chart) → RTV-51→56 (authz redesign) → datastore HA. See the Retrieva board (#2).