Skip to content

sens.legal Ecosystem

sens.legal is a legal AI platform composed of three specialized projects. Each project has a distinct responsibility, and they communicate via REST APIs.

graph TB
subgraph "Frontend Layer"
Juca["Juca<br/>Frontend Hub<br/>Next.js 16 · React 19<br/>Block System · SSE · Auth"]
end
subgraph "Backend Layer"
Valter["Valter<br/>STJ Jurisprudence Agent<br/>FastAPI · Python 3.12+<br/>23.4K decisions · 28 MCP tools"]
Leci["Leci<br/>Federal Legislation Agent<br/>Next.js · Drizzle ORM<br/>PostgreSQL + pgvector"]
end
Juca -->|"X-API-Key<br/>REST API"| Valter
Juca -.->|"Future<br/>REST API"| Leci
Valter --- VDB["PostgreSQL · Qdrant<br/>Neo4j Aura · Redis<br/>Cloudflare R2"]
Leci --- LDB["PostgreSQL + pgvector"]
AttributeValue
RoleFrontend hub + lightweight orchestrator
StackNext.js 16, React 19, TypeScript 5, Tailwind v4
StatusActive development — targeting v0.3
HostingRailway (Docker)

Responsibilities:

  • Render all UI via the Block System (11 block types)
  • Manage user sessions (SQLite)
  • Detect user intent and route to appropriate backend agent
  • Stream real-time progress via SSE
  • Handle authentication (NextAuth v5 — Google OAuth + magic links)
  • Generate PDF exports from briefing sessions

Does NOT handle:

  • Legal document search (delegated to Valter)
  • LLM processing (delegated to Valter)
  • Knowledge graph queries (delegated to Valter)
  • Citation verification (delegated to Valter)
  • Legislation lookup (will be delegated to Leci)
AttributeValue
RoleBackend agent for STJ jurisprudence
StackPython 3.12+, FastAPI, PostgreSQL, Qdrant, Neo4j Aura, Redis
StatusProduction — fully deployed
URLhttps://valter-api-production.up.railway.app
AuthX-API-Key header with scopes (read/write/admin)
RepositorySeparate repo (/Dev/Valter/)

Key capabilities:

  • 23,400+ STJ decisions indexed and searchable
  • 28 MCP tools across 3 categories (7 knowledge, 13 graph, 8 workflow)
  • Knowledge Graph: 28.5K nodes, 207K edges in Neo4j Aura
  • 4 runtimes: REST API (port 8000), MCP stdio, MCP HTTP/SSE (port 8001), ARQ worker
  • Full ingest pipeline: Download → Extract → Transform → Enrich → Index

Key API endpoints used by Juca:

EndpointMethodPurpose
/v1/retrievePOSTSearch STJ jurisprudence (hybrid: BM25 + semantic + KG)
/v1/verifyPOSTVerify citation accuracy against source documents
/v1/graph/optimal-argumentPOSTGenerate optimal legal arguments (for/against)
/v1/graph/divergenciasGET/POSTAnalyze minister/court divergences
/v1/graph/temporal-evolutionGETTemporal trends in decision patterns
/v1/similar_casesPOSTFind similar cases based on features
/v1/factual/*VariousFactual analysis endpoints
/healthGETHealth check (returns 200 when operational)
AttributeValue
RoleBackend agent for federal legislation
StackTypeScript, Next.js 16, Drizzle ORM, PostgreSQL + pgvector
Statusv0.1-pre — DB schema only, no API routes
RepositorySeparate repo (/Dev/leci/)

Current state: Leci has a database schema with 6 tables but no API surface yet:

TablePurpose
regulation_typesTypes of legal regulations
regulationsRegulation metadata
document_nodesStructural nodes of legal documents
embeddingsVector embeddings for semantic search
suggestionsAI-generated suggestions
revisionsRevision history (the only sanctioned way to mutate legal text)

Key design principle: apply_revision() is the only function that can modify legal text, ensuring a complete audit trail.

Integration timeline: Planned for Juca v0.6+, contingent on Leci developing its REST API.

Current approach: Juca communicates with Valter via direct REST API calls. The adapter layer (src/lib/adapters/) provides a unified interface so the orchestrator doesn’t need to know which backend agent it’s calling.

Authentication: Valter uses API key authentication via the X-API-Key header. Juca stores the key in VALTER_API_KEY environment variable. The auth model for multi-user scenarios is a pending decision.

🚧 Planned Feature — MCP (Model Context Protocol) integration is planned for richer tool interaction between Juca and backend agents. Valter already supports MCP with 28 tools.

All three projects follow these conventions:

ConventionValue
Branch namingfeature/[issue]-[description]-[agent] (e.g., -claude, -codex)
Commit formatfeat(scope):, fix(scope):, docs:, chore:
AI agentsClaude Code (local) + Codex (cloud) — never on the same branch
Local buildsProhibited — delegate to CI/Railway
DocumentationStarlight (Astro) with en-US + pt-BR