Open source contribution · Python · Open Data · Legal Tech
ctresb/ leis
Open source repository of Brazilian legislation in plain text and standard format, with scrapers and automated legal data auditing.
- 2 PRs under review
- 14 commits to the project
- +251.8k lines added
- 1.0k GitHub stars
The project
The leis project compiles and publishes Brazilian legislation (federal, state, and municipal) in clean, versioned text formats, enabling fast searches, public audits, and integration with AI tooling.
Using automated Python data pipelines, it extracts, normalizes, and validates legal documents directly from official legislative sources across the country, ensuring legal accuracy and historical integrity.
How each PR was made
-
One problem per PR
Each PR fixes a single thing with the smallest possible change. That keeps reviews simple, lowers the risk of side effects and lets one change be reverted without taking others with it.
-
The problem becomes a test
Fixes come with automated tests that cover the case that used to fail, so the problem cannot come back unnoticed.
-
The project's own bar
Formatting, static analysis and the full test suite run in the project's continuous integration, and a change only lands after the maintainer's review.
-
Written for the reviewer
Each PR description explains the problem, the change and how it was tested, so the maintainer can decide with confidence.
Every PR, in business terms
These PRs are under review by the maintainers and have not been merged yet. Click one to see the problem, the proposal and the expected value.
-
#6opened Oct 21, 2026Under review Historic archive of Campinas organic laws and statutory amendments The archive lacked historical organic laws and statutory amendments for Campinas; the PR proposes adding 3,068 statutes with header cleanup and optical scanning.
- The problem
- The repository had no records of Campinas complementary statutes, master plans, and organic law amendments dating back to the nineties. Older digitized documents had repeated header stamps across every page that corrupted the text flow and broke downstream legal analysis. Furthermore, capitalized introductory texts continued causing incorrect line breaks, and scanned documents without optical character recognition dropped entire technical appendices.
- What the PR proposes
- The PR proposes integrating 3,068 historic enactments, including 600 complementary statutes, the complete municipal charter, and all 54 constitutional amendments. The ingestion tool now cleans recurring page headers, seamlessly rejoins sentences interrupted by pagination, and guards capitalized citations. Optical character recognition is integrated to fully recover technical attachments previously trapped as raw images.
- Expected value
- Delivers over three decades of core municipal statutes for Campinas in clean text format, ensuring complete historical coverage with verified annexes.
-
#5opened Oct 21, 2026Under review Campinas municipal laws ingestion and chunked legislative scraping The repository lacked recent municipal laws from Campinas and broke mid-sentence citations; the PR proposes adding 489 statutes and protecting legal terms.
- The problem
- The project compiles Brazilian statutes for public search and automated auditing, but the municipality of Campinas was entirely missing from the collection. Additionally, the PDF conversion pipeline broke paragraphs whenever statutory terms appeared, splitting valid cross-references and triggering false duplicate alerts. The scraping tool also lacked fine-grained scoping, requiring broad base scans instead of targeted year-by-year updates.
- What the PR proposes
- The PR proposes adding 489 municipal statutes passed between 2022 and 2024, retrieved from the official city council portal and verified through integrity test suites. The parser now recognizes prepositions and articles preceding statutory names, preserving smooth sentence continuity. The scraping script gains filtering options by year and document type, recording partial indices without overwriting the master catalog.
- Expected value
- Provides three complete years of Campinas municipal legislation in clean format while eliminating broken citations across legal documents.
Figures updated on Oct 21, 2026.
The same care in your system
The habits behind these PRs carry over to backends that move money: reproduce the problem before fixing it, prove the fix with a test and keep sensitive data from leaking.