# Tally ↔ Claude AI Integration

Extract data from TallyPrime, classify transactions with Claude AI, build Tally
import XML, and push entries back to TallyPrime on Port 9000.

## Files

```
tally-claude/
├── config.py               # API keys + Tally connection (edit COMPANY_NAME)
├── requirements.txt        # pip packages
├── main.py                 # Orchestrator — run this
├── api_server.py           # Optional Flask bridge for the browser dashboard
├── extract/
│   ├── tally_reader.py     # Pull ledgers/vouchers over HTTP
│   └── odbc_connect.py     # Optional read-only ODBC connector
├── ai/
│   ├── claude_processor.py # Claude API calls
│   └── prompts.py          # Accounting system prompt
├── builder/
│   ├── xml_generator.py    # Build Tally <ENVELOPE> XML
│   └── validator.py        # Validate Dr/Cr before push
└── push/
    └── tally_importer.py   # POST to Port 9000
```

## Setup

```bash
pip install -r requirements.txt
export ANTHROPIC_API_KEY="sk-ant-your-key-here"     # Mac/Linux
set ANTHROPIC_API_KEY=sk-ant-your-key-here          # Windows CMD
```

Edit `config.py` → set `COMPANY_NAME` to match your Tally company exactly.

## Enable the Tally gateway

In TallyPrime: **F1 → Settings → Connectivity** → "TallyPrime acts as" = **Both**,
Port **9000**, enable **Allow Server to use ODBC**, accept and restart.
Test by opening <http://localhost:9000> in your browser.

## Run

```bash
python -m extract.tally_reader     # test: prints your ledger names
python main.py                     # run the sample batch
python main.py bank.csv            # classify + push a CSV (date, description, amount)
```

## Browser dashboard (no install)

The QuickBooks-style dashboard at **azizsaif.com/Murtuzabhai-tally** runs entirely
in your browser — upload a Tally CSV or bank statement, view year/month/date
Dr–Cr, and download a Tally-import CSV. Nothing is uploaded to any server.

To let that dashboard push straight into Tally, run `python api_server.py` locally
and use the "Push to Tally (localhost)" button.
