How femathrl0/lexai works
Lexai is a worker-facing application for helping people understand labor-case documents: it promises plain-language explanations with cited evidence, not legal advice. The documented user workflow is document upload, reading and classification, legal-evidence retrieval, explanation, quality verification, and streamed results; the sampled worker pipeline is explicitly still a skeleton that publishes statuses rather than performing those analysis stages. A separate major branch prepares and validates jurisprudence for indexing. Several analysis and integration links below rely on README descriptions because their implementation was not sampled.
Main entry points: pipelines.py Task pipelines · backend/main.py FastAPI endpoints · worker/main.py Worker queue entry · automatic_review.py Automated review
Components 18
User experience
- Upload and results UI
frontend/src/App.tsx
API and worker
- FastAPI endpoints
backend/main.py - Redis task queues
- Worker queue entry
worker/main.py - Task pipelines
worker/pipelines.py
Document analysis
- Document reading
worker/leitura - Classification and models
worker/modelos - Evidence retrieval
worker/evidencia/recuperador.py - Explanation and checks
worker/evidencia/explicador.py - Legal vector index
worker/evidencia/indices/pgvector_store.py
Jurisprudence ingestion
- Jurisprudence preparation
worker/ingestao/jurisprudencia - Corpus audit and review
worker/ingestao/jurisprudencia/audit.py - Automated review
worker/ingestao/jurisprudencia/automatic_review.py - Definitive chunking
worker/ingestao/jurisprudencia/chunking_definitivo.py - Corpus embeddings
worker/ingestao/jurisprudencia/embeddings_definitivos.py - Embedding backbone
worker/ingestao/jurisprudencia/embeddings_backbone.py
Contracts and persistence
- Typed event contracts
contratos/base.py
Other components
- Document user
Connections 20
- Document user → Upload and results UI: uploads document
frontend/src/App.tsx - Upload and results UI → FastAPI endpoints: submits upload
frontend/src/App.tsx - FastAPI endpoints → Redis task queues: enqueues task
backend/main.py - FastAPI endpoints → Worker queue entry: subscribes to task channel
backend/main.py - Worker queue entry → Redis task queues: reads task queues
- Worker queue entry → Task pipelines: dispatches tasks
- Task pipelines → Redis task queues: publishes task events
worker/pipelines.py - Task pipelines → Typed event contracts: publishes typed events
worker/pipelines.py - Task pipelines → Document reading: announces reading stage
- Task pipelines → Classification and models: announces classification stage
- Task pipelines → Evidence retrieval: announces retrieval stage
- Task pipelines → Explanation and checks: announces writing stage
- Evidence retrieval → Legal vector index: retrieves evidence
- Jurisprudence preparation → Corpus audit and review: runs audit stage
worker/ingestao/jurisprudencia/automatic_review.py - Jurisprudence preparation → Automated review: runs review stage
worker/ingestao/scripts/rodar_pipeline_base_reduzida.py - Automated review → Corpus audit and review: uses audit utilities
worker/ingestao/jurisprudencia/automatic_review.py - Automated review → Definitive chunking: passes reviewed corpus
worker/ingestao/jurisprudencia/chunking_definitivo.py - Definitive chunking → Corpus embeddings: provides chunks
worker/ingestao/jurisprudencia/embeddings_definitivos.py - Corpus embeddings → Embedding backbone: generates vectors
worker/ingestao/jurisprudencia/embeddings_definitivos.py - Embedding backbone → Legal vector index: checks index compatibility
worker/ingestao/jurisprudencia/embeddings_backbone.py