Own project · Python · Open Data · Legal Tech

viniciusdsandrade/leis

An independent edition of the open archive of Brazilian law as plain text, focused on municipal legislation, with every law checked against its official source and an automatic audit on every change.

Derived from ctresb/leis.

  • 45,981 laws added
  • 455 commits to the project
  • Oct 21, 2026 first commit

See every delivery Repository on GitHub

The project

The leis archive gathers Brazilian legislation, federal, state and municipal, as plain text with a structured header and a link to the official source of every law, ready for search, public auditing and AI tooling. This edition started as a fork of ctresb/leis, from which it inherits the base archive and the format, and now follows its own path.

New collections, fixes and audits land here first; whatever the original project publishes can be merged later, without the work waiting on it. The focus is municipal law, the least covered part of the legal system, starting with Campinas.

What this edition adds

Laws that came in through this edition, counted in the repository on every site update.

  • 45,951 laws

    Campinas (SP)

    From 1893 to 2026: municipal charter, charter amendments, complementary laws, ordinary laws, master plans, tax codes, legislative decrees, resolutions and decrees.

  • 30 laws

    Nova Friburgo (RJ)

    From 2007 to 2024: municipal charter and charter amendments.

Every delivery, in business terms

Click a delivery to see the problem, what was done and the value delivered. The link at the end of each one leads to the work on GitHub.

  1. Campinas legislation, checked law by law The archive had no laws from Campinas, a city of more than 1 million people; it now holds more than 18,000, each checked against the city council registry.
    The problem
    The archive covered federal and state legislation and was starting on municipalities, but it had no law at all from Campinas, a city of more than 1 million people. Anyone who needed one of its municipal laws had to download the PDF from the city council's system, one law at a time.
    What was done
    The laws come from the city council legislative system, collected year by year and by type, converted from PDF to text and checked against the official registry by id, number and date. The collection covers ordinary laws from 1903 to 2026, complementary laws, the municipal charter with its amendments, the master plans, the tax codes of 1964, 1969, 1973 and 1985 and more than a thousand council resolutions. Anything that could not be confirmed was held for review, with the reason recorded.
    Value delivered
    More than a century of Campinas legislation as searchable plain text, with a link to the source of every law, ready for search, auditing and AI tooling.
  2. Text true to the publication, without stamps or broken sentences The PDFs carry headers, sheet counters and notices in the middle of the law; the converter now strips them and rejoins the sentences that page breaks split.
    The problem
    The official PDFs repeat the council header and a sheet counter on every page, carry copy notices and library covers and, in some cases, only hold an appendix as a scanned image. Converted as they were, these elements ended up in the middle of articles, split sentences and cross references to other laws, and left appendices out.
    What was done
    The converter recognizes and removes headers, sheet counters, page numbers from printed books and stamps, moves notices into the law's metadata instead of its text, rejoins a sentence split by a page break and keeps in one paragraph a citation that the PDF broke across lines. Scanned appendices go through optical character recognition, and the rules come with automated tests.
    Value delivered
    Every law stays true to the published text, free of layout noise, so search and automated analysis do not trip over repeated headers or broken sentences.
  3. When in doubt, a law is held back instead of going in wrong Checks stop a law from going in with another law's text or date; when there is documentary proof, the held law is recovered.
    The problem
    The council's registry has laws with another law's PDF attached, dates that contradict the publication year and PDFs that only carry the summary or the correction. Published as they came, these cases would put into the archive a law carrying another law's text or date.
    What was done
    Before publishing, the pipeline compares the heading of the text with the number and date in the registry and holds for review, with the reason recorded, any law whose text does not match, whose date disagrees with the year and the publication or whose first article cannot be found. When proof exists, the law is recovered: a versioned record, checked by hash, points to the right PDF for laws the council's system swapped, and the first article check now accepts the way character recognition reads old documents. That brought 11 held laws back into the archive.
    Value delivered
    Every published law really is the law in the registry, and what is still missing is documented with its reason instead of hidden.
  4. An automatic audit on every change to the archive A repository of 1.5 million files gained continuous integration that audits every batch and runs the script tests before a change lands.
    The problem
    The archive holds about 21 GB in 1.5 million files and had no continuous integration: the audits and the script tests only ran when someone ran them on their own machine. A faulty batch could reach the main branch without anyone noticing.
    What was done
    A continuous integration workflow audits, on every push and every proposed change, the changed batch and the whole municipal archive, with the IBGE municipality registry checked by hash, verifies that the progress report is up to date and runs the 61 script tests. Since the repository is too large for a regular checkout, CI downloads only the code and the municipal files.
    Value delivered
    Content and code errors are stopped before they reach the published archive, without relying on anyone remembering to check.
  5. Other contributors' collections, integrated and fixed The fork brought in collections from six cities gathered by other contributors and fixed the defects that triage found in them and in the original archive.
    The problem
    Other contributors had collected the legislation of Salvador, Rio de Janeiro, Belo Horizonte, Porto Alegre, Nova Prata and Uberlândia, but that work sat outside the archive. Part of it, and part of the original archive, had conversion defects: Word's page number field at the end of the text, articles stuck in the same paragraph and one decree glued to the end of another.
    What was done
    The fork merged more than 34,000 laws from those collections, keeping each contributor's authorship in the history, and triaged the content: it removed Word's page field from 425 laws of the original archive and from 13 Nova Friburgo amendments, split the stuck articles in 88 Rio laws, opened a paragraph before every provision in 1,454 Nova Prata laws and separated two Salvador decrees that came in a single file. The fixes went into the converters, with tests and checks.
    Value delivered
    An archive larger and cleaner than the sum of its parts: scattered work comes together, and every defect found is fixed at the source so it does not come back in the next batch.

Figures updated on Nov 24, 2026.

How the work is done

  • Official source, checked

    Every law comes from the council's official system and only goes in after being checked against the registry by id, number and date.

  • When in doubt, hold it back

    Text that does not match the registry, a contradictory date or a PDF without the law is held for review with the reason recorded, instead of going in wrong.

  • Reproducible from scratch

    Every batch is generated by the pipeline from the cached PDFs, and regenerating the archive yields identical files: no fix is made by hand.

  • Audited before publishing

    The archive audits and the script tests run in continuous integration on every change, and a batch only lands with zero errors.

The same care in your system

The habits behind this archive carry over to backends that move money: check every record against its source, hold back what does not add up and audit every change.

Talk to Vinícius Home