NOTE: This is still under development!!!
TaxLens is a local web app that helps review the Internal Revenue Code for tax planning ideas.
It does three main things:
- Reads a local Title 26 XML file.
- Saves the tax code sections into a local SQLite database.
- Sends sections to OpenAI or Claude and saves the planning strategies it finds.
The app runs on your computer. The database is local. API calls only happen when you click Run Analysis.
Install these first:
- Python 3.11 or newer
- A local copy of the Title 26 XML file, or network access to download it from the U.S. Code site
- Either an OpenAI API key or a Claude API key
By default, TaxLens expects the XML file in this repo folder:
C:\Users\mick0\OneDrive\Documents\Code & Dev\GitHub\Tax-Lens\usc26.xml
If your XML file is somewhere else, you can change that later in .env.
Important files:
main.py: starts the web app and API.parser.py: reads the Title 26 XML file.tax_code_updater.py: checks the House U.S. Code release date and downloads Title 26 XML when needed.db.py: creates and reads the SQLite database.analyzer.py: sends tax code sections to OpenAI or Claude.frontend/index.html: browser interface..env.template: example settings file.requirements.txt: Python packages needed by the app.CHANGELOG.md: dated record of repo changes.completed-upgrades.md: implemented upgrades moved out of future planning.assessment.md: detailed repo assessment that must stay current when the repo changes.AGENTS.md: repo instructions for future Codex work.
Generated local files:
.env: your local settings and API key. Do not commit this.taxlens.db: local SQLite database. Do not commit this.taxlens.log: local app log. Do not commit this.usc26.xml: downloaded Title 26 XML file. Do not commit this.TaxCodeReleaseDate.txt: last downloaded House release date. Do not commit this.future-upgrades.md: local planning list for possible upgrades. Do not commit this.
From the repo folder:
cd "C:\Users\mick0\OneDrive\Documents\Code & Dev\GitHub\Tax-Lens"Run:
python -m venv .venvActivate it:
.\.venv\Scripts\Activate.ps1If activation is blocked, run this once:
Set-ExecutionPolicy -Scope CurrentUser RemoteSignedThen activate again:
.\.venv\Scripts\Activate.ps1Run:
pip install -r requirements.txtThis installs FastAPI, Uvicorn, XML parsing support, OpenAI support, Claude support, and environment file support.
Copy the template:
Copy-Item .env.template .envOpen it:
notepad .envUse OpenAI:
LLM_PROVIDER=openai
OPENAI_API_KEY=your_openai_key_here
OPENAI_MODEL=gpt-4o
Use Claude:
LLM_PROVIDER=claude
ANTHROPIC_API_KEY=your_claude_key_here
CLAUDE_MODEL=claude-3-5-sonnet-20241022
Leave the unused API key blank or keep the placeholder.
The default setting is:
XML_PATH=usc26.xml
To download the current Title 26 XML file, run:
python .\tax_code_updater.pyThe updater checks the House U.S. Code download page. It reads the current release date at the top of the page. It compares that value to TaxCodeReleaseDate.txt.
If the dates do not match, it downloads the Title 26 XML zip, extracts usc26.xml into this repo folder, writes the new date to TaxCodeReleaseDate.txt, and deletes the zip file.
If your XML file is somewhere else, update XML_PATH.
Example:
XML_PATH=C:\Users\mick0\Documents\Data\usc26.xml
The default database setting is:
DB_PATH=taxlens.db
That is fine for normal local use.
Run:
uvicorn main:app --reloadOpen this in your browser:
http://localhost:8000
When the app starts, it creates the local SQLite database.
If taxlens.db is empty and the XML file exists, the app parses the XML file and saves the tax code sections.
This can take a little time on the first run. Later runs are faster because the sections are already cached.
You can also click Parse XML in the browser to parse the XML manually.
Click Run Analysis in the browser.
The app will:
- Pull unanalyzed tax code sections from SQLite.
- Send a batch to the selected LLM provider.
- Save any returned strategies into
taxlens.db. - Update the browser counts as findings are added.
The default batch size is 50 sections.
Full Title 26 analysis can cost money through the selected LLM API. A rough GPT-4o estimate is $5-15, depending on token volume and current pricing.
The browser UI lets you:
- View total sections, analyzed sections, and findings.
- Filter findings by strategy type.
- Search findings by keyword.
- Open a detailed strategy panel.
- Open the related Cornell LII tax code page.
- Start XML parsing.
- Check for a new Title 26 XML release.
- Start LLM analysis.
These are mainly useful for testing or automation:
GET /api/statsGET /api/findings?type=&keyword=§ion=GET /api/findings/{id}POST /api/analyze?batch=50POST /api/parsePOST /api/tax-code/updateGET /api/sections
Example:
Invoke-RestMethod http://localhost:8000/api/statsUse these files to keep the project easy to resume:
CHANGELOG.md: update this whenever repo behavior, docs, config, or workflow changes.assessment.md: update this every time a repo change is made. It is the detailed current state of the repo.future-upgrades.md: local only list of possible upgrades. It is ignored by Git.completed-upgrades.md: tracked list of upgrades after they are implemented and verified.
When an upgrade is completed, move it from future-upgrades.md to completed-upgrades.md, then log the change in CHANGELOG.md.
If uvicorn is not recognized, make sure the virtual environment is active and packages are installed:
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtIf the app shows zero sections, check that the XML file exists:
Test-Path ".\usc26.xml"If that returns False, run:
python .\tax_code_updater.pyThen click Parse XML in the browser, or restart the app.
If analysis returns no findings, check:
LLM_PROVIDERis set toopenaiorclaude.- The matching API key is set.
- The API key has billing enabled.
taxlens.logfor errors.
If port 8000 is already in use, run on another port:
uvicorn main:app --reload --port 8001Then open:
http://localhost:8001