VICTOR SAAD
EnquireContato
All buildsTodos os projetos
Python · Claude · searchbusca

SPTC Normas

SPTC Normas

The rules of São Paulo's forensic police in one place: ordinances, service orders, resolutions and standard procedures, searchable by subject, with answers that cite the article and a robot that watches the Official Gazette.

As normas da Polícia Técnico-Científica de SP num lugar só: portarias, ordens de serviço, resoluções e POPs, com busca pelo assunto, respostas que citam o artigo e um robô de olho no Diário Oficial.

PythonFastAPIPostgreSQLfastembedClaudeNext.jssystemdCloudflare Tunnel
Open the appAbrir o app →
SPTC Normas home: search box, themes and the latest rules
The live app: search, themes and the newest rules first.
O app no ar: busca, temas e as normas mais novas primeiro.

Why

Por quê

A forensic expert had built a small app to collect these rules, but it froze: adding a new rule meant touching code. Meanwhile new acts keep coming out in the Official Gazette, and finding the one that answers a question in the middle of a case still meant opening PDF after PDF.

Um perito tinha feito um app pequeno para juntar essas normas, mas ele parou no tempo: incluir uma norma nova exigia mexer no código. Enquanto isso, atos novos continuam saindo no Diário Oficial, e achar o que responde uma dúvida no meio de um caso ainda era abrir PDF atrás de PDF.

What is in it

O que tem nele

  • 86 rules split into 1,033 passages, one per article, across 14 themes, migrated from the old app with its data fixed on the way in.
  • Search by meaning, not just words: Portuguese full-text search and vector search over the same passages, fused into one ranking.
  • Ask a question: Claude answers only from the passages found, cites each sentence with its source, and warns when a rule was revoked or amended.
  • An Official Gazette robot: every working day it searches the state gazette for new acts of the forensic police and suggests the relevant ones. Nothing goes in on its own; the curator decides.
  • Maintained by the people who use it: upload a PDF, link rules that revoke or amend each other, edit themes, with every change logged and reversible.
  • 86 normas divididas em 1.033 trechos, um por artigo, em 14 temas, migradas do app antigo com os dados corrigidos na entrada.
  • Busca pelo sentido, não só pela palavra: busca textual em português e busca vetorial nos mesmos trechos, juntas num ranking só.
  • Pergunte: o Claude responde só com os trechos encontrados, cita a fonte de cada frase e avisa quando a norma foi revogada ou alterada.
  • Um robô do Diário Oficial: todo dia útil ele procura no DOE-SP os atos novos da Polícia Científica e sugere os relevantes. Nada entra sozinho; quem cuida do acervo decide.
  • Mantido por quem usa: subir um PDF, ligar normas que revogam ou alteram outras, editar os temas, com toda mudança registrada e reversível.

How it is built

Como foi feito

A FastAPI backend over PostgreSQL. Text comes out of PDFs, scanned ones through OCR, and out of the gazette's HTML, then is cut by article. Embeddings run locally on the CPU with fastembed, so search costs nothing per query. The site is a static Next.js export served by the same process, in its own isolated container on the homelab, sandboxed by systemd and published through a Cloudflare Tunnel.

Um backend FastAPI sobre PostgreSQL. O texto sai dos PDFs, os escaneados por OCR, e do HTML do Diário Oficial, e é cortado por artigo. Os embeddings rodam localmente na CPU com fastembed, então a busca não custa nada por consulta. O site é um export estático do Next.js servido pelo mesmo processo, num container isolado só dele no homelab, protegido pelo systemd e publicado por um túnel da Cloudflare.

Want to talk about this? I'm happy to walk through how it was built.Quer conversar sobre isso? Mostro com prazer como foi construído.