# Fenland Property Holdings — Platform

Two sides in one place:

- **Acquisitions** — deal pipeline, appraisal (yield, cashflow, interest cover, or
  profit for buy-to-sell), underwriting (scenarios, bridge, debt sizing, five-year
  cash flow, IRR, bid sensitivity, conditions before bidding), sold-price comparables from HM Land Registry, and legal
  pack review by Claude.
- **Asset management** — portfolio dashboard, property pages (tenancy, compliance,
  inspections, valuations, ledger), cash tracker (income and costs by month, with
  the agent statements behind them), debt and covenant tracking, and scheduled reports.

## Run it

Double-click `start.cmd`, or:

    npm install
    npm start

Then open http://localhost:4310. Needs Node 22 or later.

## Connect Claude

Copy `.env.example` to `.env`, paste an Anthropic API key after `ANTHROPIC_API_KEY=`
and restart. Settings shows the connection status. Without a key everything works
except legal pack review and report commentary.

## Where things live

| Path | What |
|---|---|
| `server.js` | Web server, API routes, report scheduler |
| `lib/claude.js` | Claude calls: legal pack review prompt and schema, report commentary |
| `lib/auth.js` | Sign-in: users, password hashing, sessions |
| `lib/landreg.js` | Land Registry Price Paid lookup |
| `lib/seed.js` | Sample data (invented) |
| `public/js/calc.js` | Every calculation: SDLT, appraisal, yields, LTV, interest cover, alerts, reports |
| `public/js/views/` | Screens |
| `public/css/tokens.css` | Design system tokens, copied unchanged |
| `data/` | Records (`db.json`) and uploaded pack documents. Back this folder up. |

## Things to know

- **Sign-in.** Add a user with `npm run user -- add <username>` and every page and
  API call then needs a session. With no users (the default on this machine) it runs
  open, and only listens on this machine. Hosting it is covered in `DEPLOY.md`.
- **SDLT** uses England rates from 1 April 2025 with the 5% surcharge on residential.
  Each deal can override the figure; update `calc.js` when rates change.
- **Covenant tests** use standard definitions (balance over latest valuation; passing
  rent over interest). Check them against each facility agreement.
- **Scheduled reports** are produced five days after a period closes, checked when
  the platform starts and every six hours while it runs. They are archived in the
  platform; nothing is emailed.
- **Legal pack reviews** are a first pass for the acquisitions team, not legal advice.
  One review handles up to 22 MB of PDFs.
