RentLedger 🏠
Automated HRA Rent Receipt Generator & Verification System for Indian Employees
📌 The Problem
Millions of salaried employees in India need monthly rent receipts to claim HRA (House Rent Allowance) exemption during ITR filing. Every March, employees scramble to collect 12 months of receipts — landlords forget, WhatsApp messages get lost, and HR departments get flooded with incomplete, handwritten paper documentation.
RentLedger automates this entire financial compliance workflow.
🚀 What It Does
- Auto-Generates Legal PDFs: Creates legally formatted rent receipts instantly using ReportLab.
- Automated Email Delivery: Directly emails the generated PDF receipt to the tenant’s (and optionally landlord’s) inbox via Gmail SMTP.
- Smart Gap Detection: Automatically detects missing months in a lease cycle and generates all missing gaps in one click.
- QR Code HR Verification: Embeds a unique QR code on every PDF. HR departments can scan it to hit a public verification endpoint, proving authenticity without exposing sensitive data.
- Enterprise-Grade Security:
- Data Masking: Landlord PANs and tenant mobile numbers are masked in API responses to prevent data leakage.
- Rate Limiting: Protects endpoints against spam and bot abuse.
- Anti-Fraud IDOR Protection: Validates new landlord name entries against existing PAN records to prevent database spoofing.
- Year-End HRA Bundle: Exports a clean summary text block for instant HR submission.
🛠 Tech Stack
| Component |
Technology |
| Backend API |
Python 3.11, Flask, Flask-CORS |
| Database |
SQLite3 |
| PDF Engine |
ReportLab |
| Email Delivery |
Python smtplib (Gmail SMTP API) |
| Security |
Flask-Limiter, Regex validation |
| QR Generation |
qrcode[pil] |
| Testing |
pytest (22 passing unit tests) |
💻 Local Setup & Installation
git clone https://github.com/AaryanSpace/rentledger
cd rentledger
pip install -r requirements.txt
python app.py # Start Flask API
python scheduler.py # Start auto-scheduler (separate terminal)
API Endpoints
| Method |
Endpoint |
Description |
| GET |
/ |
API info and endpoint list |
| POST |
/tenants |
Register a new tenant |
| GET |
/tenants |
List all tenants |
| POST |
/receipts/generate |
Generate receipt for specific month & send email |
| POST |
/receipts/generate-all-missing |
Auto-generate & email all missing receipts |
| GET |
/receipts/<tenant_id> |
List all receipts for a tenant |
| GET |
/receipts/download/<id>/<month> |
Download PDF receipt |
| GET |
/summary/<tenant_id>/<year> |
Year-end HRA summary |
| GET |
/verify/<receipt_id> |
Public HR QR verification route |
| GET |
/email/test |
Verifies SMTP server connection |
Example Usage
1. Register a Tenant
curl -X POST http://localhost:5000/tenants \
-H "Content-Type: application/json" \
-d '{
"tenant_name": "Your Sweet Name",
"tenant_email": "[email protected]",
"tenant_mobile": "9876543210",
"landlord_name": "Ramesh Kumar",
"landlord_pan": "ABCDE1234F",
"property_address": "123 MG Road, Bangalore - 560001",
"monthly_rent": 17500,
"lease_start": "2025-06"
}'
2. Generate All Missing Receipts (Core Automation)
curl -X POST http://localhost:5000/receipts/generate-all-missing \
-H "Content-Type: application/json" \
-d '{"tenant_id": 1}'
3. Get Year-End Summary
curl http://localhost:5000/summary/1/2024
Run Tests
pytest tests/ -v
Runs 22 unit tests covering PAN validation, mobile validation, month validation, rent validation, and tenant payload verification
Project Structure
rentledger/
├── app.py # Flask REST API + Rate Limiting
├── pipeline.py # Core business logic + validation
├── pdf_gen.py # ReportLab PDF + QR Code generator
├── email_service.py # SMTP automated email dispatcher
├── database.py # SQLite CRUD operations
├── scheduler.py # Monthly cron-style automation
├── frontend/
│ └── index.html # Responsive Client UI
├── tests/
│ └── test_pipeline.py# 22 pytest unit tests
├── data/receipts/ # Generated PDF receipts
├── .env.example # Environment variable template
└── requirements.txt
Why This Exists
“Built to solve a real problem I saw around me — every salaried person in India needs this every March and there was no free, automated, offline tool to do it.”
RentLedger — Because chasing landlords for receipts is not a March tradition.
评论