|
| 1 | +# DealLens |
| 2 | + |
| 3 | +Commercial real estate underwriting engine with full Excel export. |
| 4 | + |
| 5 | +DealLens is a web-based CRE underwriting platform that runs institutional-grade financial analysis across five deal types and outputs fully linked Excel proformas with live formulas. The math engine is deterministic Python (not LLM-generated), validated against real proformas to within 25 basis points. |
| 6 | + |
| 7 | +## What It Does |
| 8 | + |
| 9 | +You input deal assumptions (manually or by uploading an Offering Memorandum PDF). The engine runs a 120-month DCF model and returns IRR, equity multiples, DSCR, cash flow projections, GP/LP waterfall distributions, and a downloadable Excel workbook where every cell traces to an assumption. |
| 10 | + |
| 11 | +Five deal types, each with its own underwriting logic: |
| 12 | + |
| 13 | +- **Ground-Up Development** — Construction draws (S-curve/sigmoid), lease-up vacancy ramp, perm loan takeout, hold period through stabilization and exit |
| 14 | +- **Value-Add** — In-place NOI with renovation CapEx by unit, post-reno rent lifts, stabilized exit cap |
| 15 | +- **Stabilized Refinance** — Cash-out refi with DSCR-constrained loan sizing, rate modeling, origination fee as closing cost |
| 16 | +- **Acquisition / Disposition** — Full-cycle buy-hold-sell with exit cap sensitivity, levered vs unlevered returns (mode toggle on the Refinance engine) |
| 17 | +- **Fix and Flip** — Short-hold rehab with bridge loan, holding costs, ARV-based exit, monthly IRR |
| 18 | + |
| 19 | +Engine capabilities: |
| 20 | + |
| 21 | +- Constraint-based debt sizing (binding constraint of LTV, LTC, DSCR, or debt yield) |
| 22 | +- N-tier IRR-based European-style waterfall with GP catchup and preferred returns |
| 23 | +- Monte Carlo simulation (1,000 runs across rent growth, cap rate, and cost variance) |
| 24 | +- Scenario presets (Conservative Lender / Aggressive Sponsor / Institutional LP) |
| 25 | +- Six methodology toggles (monthly vs annual DCF, exit cap vs terminal value, S-curve vs linear draws, etc.) |
| 26 | +- AI-powered OM extraction (uploads a PDF, extracts deal assumptions via Claude Sonnet) |
| 27 | +- Live market rates via FRED API (Treasuries, SOFR, credit spreads) |
| 28 | +- Excel export with live formulas across all deal types (zero frozen values) |
| 29 | + |
| 30 | +## Architecture |
| 31 | + |
| 32 | +``` |
| 33 | +Frontend: Next.js + TypeScript + Tailwind CSS |
| 34 | +Backend: FastAPI + Python (numpy, scipy, XlsxWriter) |
| 35 | +Database: Supabase (PostgreSQL + Auth + Storage, RLS enforced) |
| 36 | +AI: Claude Sonnet via OpenRouter (OM extraction only, not used for math) |
| 37 | +``` |
| 38 | + |
| 39 | +The frontend and backend are in a single monorepo. The frontend lives in `frontend/`, the backend in `backend/`. Each has its own `.env.example`. |
| 40 | + |
| 41 | +## Running Locally |
| 42 | + |
| 43 | +### Prerequisites |
| 44 | + |
| 45 | +- Node.js 18+ |
| 46 | +- Python 3.11+ |
| 47 | +- A Supabase project (free tier works) |
| 48 | +- An OpenRouter API key (for OM extraction, optional) |
| 49 | +- A FRED API key (for market rates widget, optional) |
| 50 | + |
| 51 | +### Backend |
| 52 | + |
| 53 | +```bash |
| 54 | +cd backend |
| 55 | +python -m venv venv |
| 56 | +source venv/bin/activate |
| 57 | +pip install -r requirements.txt |
| 58 | +cp .env.example .env # Fill in your Supabase and API keys |
| 59 | +uvicorn app.main:app --host 0.0.0.0 --port 8001 |
| 60 | +``` |
| 61 | + |
| 62 | +### Frontend |
| 63 | + |
| 64 | +```bash |
| 65 | +cd frontend |
| 66 | +npm install |
| 67 | +cp .env.example .env.local # Fill in your backend URL and Supabase keys |
| 68 | +npm run dev |
| 69 | +``` |
| 70 | + |
| 71 | +### Database |
| 72 | + |
| 73 | +The `supabase/migrations/` directory contains all SQL migrations for tables, RLS policies, triggers, and indexes. If you have the Supabase CLI installed: |
| 74 | + |
| 75 | +```bash |
| 76 | +supabase db push |
| 77 | +``` |
| 78 | + |
| 79 | +See [`docs/SUPABASE_SETUP.md`](docs/SUPABASE_SETUP.md) for a full walkthrough of creating a Supabase project from scratch. |
| 80 | + |
| 81 | +## Testing |
| 82 | + |
| 83 | +```bash |
| 84 | +cd backend |
| 85 | +pytest |
| 86 | +``` |
| 87 | + |
| 88 | +387 tests covering all five deal types, loan sizing, waterfall distributions, Excel export parity, and edge cases. The test suite runs on every push. |
| 89 | + |
| 90 | +## Excel Export |
| 91 | + |
| 92 | +Every deal type produces a multi-tab Excel workbook with live formulas. Tabs include Assumptions, Proforma/Cash Flow, Loan Summary, Returns, and a conditional Waterfall tab. No frozen values. Change an assumption in the workbook and every downstream calculation updates natively in Excel. |
| 93 | + |
| 94 | +The export uses XlsxWriter with the `formulas` library for parity testing between Python-computed values and Excel formula results. |
| 95 | + |
| 96 | +## Why This Exists |
| 97 | + |
| 98 | +Most CRE professionals underwrite deals in personal Excel models. Those models are hard to audit, easy to break, and impossible to standardize across deal types. DealLens was built to replicate the rigor of an institutional Excel proforma in a web-native platform, then give the user a real Excel file they can hand to a lender, LP, or investment committee. |
| 99 | + |
| 100 | +The engine was calibrated against reference proformas built by a real estate principal. Every formula in the codebase exists because it matched a cell in a validated Excel model. |
| 101 | + |
| 102 | +## Project Status |
| 103 | + |
| 104 | +This project is no longer actively maintained. It was built as a solo founder project between January and May 2026. The engine is complete, tested, and functional. You are welcome to fork it, extend it, or use the engine in your own projects. |
| 105 | + |
| 106 | +## License |
| 107 | + |
| 108 | +[MIT](LICENSE) |
0 commit comments