Skip to content

Valter — Legal Knowledge Backend

The legal knowledge backend for the Diego Sens ecosystem — serving Brazilian STJ jurisprudence via REST API and Model Context Protocol (MCP).

Valter is a specialized backend that transforms raw legal data from Brazil’s Superior Tribunal de Justica (STJ) into structured, verifiable legal knowledge. It combines four purpose-built data stores — PostgreSQL for documents and metadata, Qdrant for semantic vector search, Neo4j for a knowledge graph of legal relationships, and Redis for caching — to deliver hybrid search with knowledge-graph boosting, anti-hallucination verification, and graph analytics across tens of thousands of court decisions.

Unlike general-purpose legal search engines that treat decisions as isolated text blobs, Valter connects decisions through a knowledge graph based on the FRBR ontology. Criteria, legal devices, precedents, and ministers are linked as first-class graph entities, enabling queries like “which legal arguments have the highest success rate for this minister in this category” or “how has the application of this criterion evolved over the last five years.” Every claim returned by the system is traceable to a specific graph node or verified against real tribunal data.

Valter is MCP-native: 28 tools are exposed via the Model Context Protocol, allowing LLMs like Claude and ChatGPT to query jurisprudence, verify references, analyze divergences, and compose arguments directly. The same capabilities are available through a REST API for traditional frontend consumption.

MetricValue
STJ decisions in knowledge graph~28,000
Relations between legal entities207,000+
STJ metadata records810,225
Classified document features2,119
Semantic vectors (768-dim)~3,673
MCP tools for LLM integration28
Graph analytics endpoints12
Data stores4 (PostgreSQL, Qdrant, Neo4j, Redis)
REST API routers11
Ingestion workflow endpoints17
  • Getting Started — Docker setup, first API call, first MCP connection
  • Architecture Overview — Modular monolith, dependency rule, 4 runtimes
  • Technology Stack — Python, FastAPI, 4 databases, and why each was chosen
  • API Reference — REST endpoints for search, verification, graph analytics, and ingestion
  • MCP Tools — All 28 tools available to Claude, ChatGPT, and other MCP clients
  • Features — Hybrid search, graph analytics, anti-hallucination, and more
  • Architecture Decisions — ADRs documenting key choices and their rationale
  • Glossary — Legal and technical terms used throughout the project

Valter is one of three projects that form the sens.legal ecosystem:

ProjectRoleStackStatus
ValterLegal knowledge backend — jurisprudence from STJ, served via REST API and MCPPython, FastAPI, PostgreSQL, Qdrant, Neo4j, RedisIn production
LeciLegislation backend — Brazilian statutes and norms as a complementary data sourcePlannedIntegration planned for v2.0
JucaFrontend for lawyers — the interface through which legal professionals interact with the ecosystemNext.jsIn development

Valter acts as the knowledge engine: Juca calls Valter’s REST API for search and analysis, while Claude and ChatGPT connect through MCP to use the same capabilities as tools in their reasoning process. When Leci is integrated, Valter will be able to cross-reference jurisprudence with the specific legislative provisions being applied, closing the loop between how courts interpret the law and what the law actually says.