Solar ROI C&I Proposal Generator for Egypt — Next.js 14 + TypeScript + Prisma + PDFKit
# SolarROI Egypt — C&I Proposal Generator
A full-stack Next.js + TypeScript SaaS app for Egyptian Commercial & Industrial solar integrators. Input project parameters, run deterministic financial analysis, and download a branded 3-page PDF proposal.
---
## Tech Stack
| Layer | Technology |
|---|---|
| Framework | Next.js 14 (App Router) |
| Language | TypeScript |
| Styling | Tailwind CSS v3 + shadcn/ui |
| ORM | Prisma (SQLite dev → Postgres prod) |
| Forms | react-hook-form + Zod |
| Charts | Recharts (client-side cashflow chart) |
| PDF | PDFKit (server-side, 3-page branded proposal) |
| Deployment | Vercel |
---
## Quick Start
```bash
# 1. Install dependencies
npm install
# 2. Set up environment
cp .env.example .env
# Edit .env and set DATABASE_URL if needed (default: SQLite)
# 3. Create / migrate the database
npx prisma generate
npx prisma db push
# 4. Start dev server
npm run dev
```
Open
localhost.
---
## Environment Variables
| Variable | Description | Default |
|---|---|---|
| `DATABASE_URL` | Prisma connection string | `file:./dev.db` (SQLite) |
To switch to Postgres:
1. Change `provider = "sqlite"` → `provider = "postgresql"` in `prisma/schema.prisma`
2. Set `DATABASE_URL` to your Postgres connection string
3. Run `npx prisma db push`
---
## Financial Model
All calculations live in `lib/financialEngine.ts` — a pure TypeScript function with no side effects.
### Inputs
| Parameter | Description |
|---|---|
| `systemSizeKwp` | System capacity in kWp |
| `region` | Solar resource zone (see yields below) |
| `capexPerKwp` | Capital cost in EGP/kWp |
| `oAndMPercent` | Annual O&M as % of total CAPEX |
| `tariffValue` | Electricity avoided tariff in EGP/kWh |
| `escalationRate` | Annual tariff escalation (fraction) |
| `financingMode` | `"cash"` or `"loan"` |
| `loanParams` | `{ loanShare, interestRate, tenorYears }` — loan mode only |
| `analysisPeriod` | Default 25 years |
| `discountRate` | Default 11% (set per EPC profile) |
# …