Tax-aware portfolio analysis tool that turns messy brokerage statements and portfolio exports into actionable, tax-smart insights. Privacy-focused architecture with secure file handling and guest-first experience.
π Live at taxrebalancer.com
| Problem | How TaxRebalancer Solves It |
|---|---|
| Tax-aware rebalancing is hard β translating holdings to a tax-smart plan without spreadsheets | Dedicated harvest algorithm that computes tax-optimal sell sequences with ST/LT classification |
| Brokerage exports are messy β PDFs/CSVs/Excel with inconsistent formats | Secure upload pipeline with format detection and validation (PDF statements, Excel/CSV/JSON portfolios) |
| Privacy concerns β users worry about sensitive financial data | Signed URL uploads with time-limited access, strict validation, no permanent server storage of raw files |
| Onboarding friction β requiring signup kills conversion | Guest mode with admin-configurable limitsβtry before creating an account |
| Multi-portfolio management β needs access controls | Ownership rules and portfolio service layer with user-scoped access |
- Harvest Algorithm β Tax-lot selection with FIFO or tax-optimized ordering
- ST/LT Classification β Gain/loss categorization based on holding period
- Cross-Offset Calculation β Net short-term losses against long-term gains (and vice versa)
- Tax Budget Enforcement β Stop selling when max tax budget reached
- Raise Cash Mode β Liquidate positions to raise a target amount
- Signed URL Uploads β Backend requests time-limited signed URLs via Cloud Functions
- XHR PUT with Progress β Direct upload to cloud storage with progress tracking
- Strict Validation β PDF statements (β€25MB), portfolio files (Excel/CSV/JSON β€10MB)
- PII Redaction β Built-in service for sensitive data removal
- Try Before Signup β Full functionality with guest limits
- Admin-Configurable β Guest portfolio limits, rebalance counts controlled via admin panel
- Seamless Upgrade β Guest data persists to localStorage, can be migrated on registration
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite, Tailwind CSS |
| State | React Context (Auth, Guest, Parser, Admin) |
| Auth | Firebase Authentication |
| Database | Cloud Firestore |
| Functions | Firebase Cloud Functions (signed URLs, parsing) |
| Hosting | Firebase Hosting |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β REACT FRONTEND β
β Home β Dashboard β GuestDashboard β Analysis β Admin β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ
β CONTEXT PROVIDERS β
β AuthContext β GuestContext β ParserContext β AdminContext β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ
β FIREBASE SERVICES β
β Auth β Firestore β Cloud Functions β Storage β
ββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ
β SIGNED URL UPLOAD FLOW β
β getSignedUploadUrl() β XHR PUT β Progress β Validation β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The harvest algorithm (src/lib/harvestAlgorithm.js) implements:
// Input
{
previewRows, // Portfolio holdings with lots
securities, // Security metadata
longTermRate, // Tax rate for LT gains
shortTermRate, // Tax rate for ST gains
dispositionMethod, // 'default' (tax-optimized) or 'fifo'
maxTaxBudget, // Stop when budget exhausted
raiseCash, // Target cash to raise
}
// Output
{
proposedTrades, // Which lots to sell
stGain, stLoss, // Short-term totals
ltGain, ltLoss, // Long-term totals
estimatedTax, // Projected tax liability
cashRaised, // Total cash generated
}Tax Lot Selection Logic:
- Default Mode β Sell losses first (prefer LT), then gains (prefer LT)
- FIFO Mode β Sell strictly by trade date
- Cross-Offset β Net ST losses against LT gains to minimize tax
- Budget Enforcement β Stop when cumulative tax exceeds budget
βββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Client βββββΆβ Cloud Function βββββΆβ Cloud Storage β
β (Browser) β β getSignedUploadUrlβ β (Signed PUT) β
βββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β
β 1. Request URL β
βββββββββββββββββββββΆβ
β β
β 2. Signed URL + β
β expiration β
ββββββββββββββββββββββ
β β
β 3. XHR PUT with β
β progress β
βββββββββββββββββββββββββββββββββββββββΆβ
Validation Rules:
- Statement PDFs:
application/pdf, max 25MB - Portfolio files: Excel/CSV/JSON, max 10MB
- Content-Type verification
- Size limits enforced client + server side
# Clone and install
git clone https://github.com/Mitzseen/portfolio-rebalancer.git
cd portfolio-rebalancer
npm install
# Set up Firebase
cp .env.example .env
# Add your Firebase config keys
# Run development server
npm run devportfolio-rebalancer/
βββ src/
β βββ components/
β β βββ ui/ # Reusable primitives
β β βββ SecureFileUploadModal.jsx # Upload with validation
β β βββ PortfolioAnalysis.jsx # Results display
β βββ contexts/
β β βββ AuthContext.jsx # Firebase auth state
β β βββ GuestContext.jsx # Guest user management
β β βββ ParserContext.jsx # File parsing state
β β βββ AdminContext.jsx # Admin settings
β βββ hooks/
β β βββ useDataParser.jsx # PDF/Excel parsing
β β βββ useStreamingUpload.jsx # Progress tracking
β βββ lib/
β β βββ harvestAlgorithm.js # Core rebalancing engine
β β βββ signedUploadService.js # Signed URL flow
β β βββ piiRedactionService.js # Sensitive data removal
β β βββ firebase.js # Firebase config
β βββ pages/
β βββ GuestDashboard.jsx # Guest experience
β βββ Dashboard.jsx # Registered user
β βββ Analysis.jsx # Results page
βββ functions/
β βββ src/
β βββ index.ts # Cloud Function exports
β βββ parserEngine.ts # PDF/Excel parsing
βββ public/
βββ assets/ # Static images
| Decision | Rationale |
|---|---|
| Signed URL uploads | Safer than direct uploads, time-limited access, scales better |
| Guest mode first | Reduce friction, let users validate value before commitment |
| Admin-configurable limits | Business flexibility without code deploys |
| Harvest algorithm isolated | Clean separation of tax logic from UI concerns |
| Educational approach | Explain why each trade is recommended |
- Built a tax-aware portfolio analysis tool with React + Firebase supporting PDF/Excel statement uploads and tax-optimized trade recommendations
- Implemented signed URL upload pipeline via Cloud Functions for secure, time-limited file handling with progress tracking
- Designed guest vs registered user flow with admin-configurable limits to reduce onboarding friction
- Built harvest algorithm implementing tax-lot selection with ST/LT classification, cross-offset calculations, and budget enforcement
- Architected context-based state management separating auth, guest, parser, and admin concerns for maintainability
Proprietary β All Rights Reserved
This software is proprietary and actively used in a commercial product at taxrebalancer.com. You may view the source code for educational purposes only. See LICENSE for full terms.
Built by a FINRA-licensed engineer (Series 7/63) who understands both the finance domain and the engineering required to ship reliable software.