Skip to content

Mitzseen/taxrebalancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

93 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TaxRebalancer

React Firebase Vite Live License: Proprietary

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


🎯 Problems TaxRebalancer Solves

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

✨ Key Features

Tax-Aware Analysis

  • 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

Secure File Handling

  • 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

Guest Experience

  • 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

πŸ› οΈ Tech Stack

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

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     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      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“Š Core Algorithm

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:

  1. Default Mode β€” Sell losses first (prefer LT), then gains (prefer LT)
  2. FIFO Mode β€” Sell strictly by trade date
  3. Cross-Offset β€” Net ST losses against LT gains to minimize tax
  4. Budget Enforcement β€” Stop when cumulative tax exceeds budget

πŸ” Secure Upload Pipeline

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   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

πŸš€ Quick Start

# 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 dev

πŸ“ Project Structure

portfolio-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

🎯 Product Decisions

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

πŸ“ˆ Resume-Ready Bullets

  • 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

πŸ“„ License

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.

About

Tax-aware portfolio rebalancing tool with PDF/Excel statement parsing, harvest algorithm for tax-lot optimization, and signed URL upload pipeline. Live at taxrebalancer.com

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors