Heliopt
The operating system for solar installers, from site visit to regulator dossier.
- SaaS platforms
- Document AI
- Multi-agent systems
- Security & governance
- Role
- Founder, architect and sole engineer
- Client
- Own product (SoluGent), with installer design partners
- Timeline
- Mar - Oct 2026
- Status
- Live in productionheliopt.com
Recorded from the running app on sample data: 3D roof with sun simulation by season and hour, near-shade loss per row, then auto-fill on the satellite plan.
- commits in 7.5 months
- 1,703
- commits in 7.5 months
- pull requests merged
- 352
- pull requests merged
- automated tests
- ~6,100
- automated tests
- Postgres RLS policies
- 307
- Postgres RLS policies
- bill fields read correctly by vision AI
- 323 / 330
- bill fields read correctly by vision AI
The problem
Tunisian solar installers run projects worth millions of dinars on Excel, WhatsApp and paper. Pricing a quote means modelling the national utility's banded tariffs, levies and subsidy rules. Filing a grid connection means a 40 to 80 page dossier of official forms, cable calculations to NFC 15-100, single-line diagrams and about 25 annexes, retyped for every job.
One missing page bounces the file. Payback estimates were off by years. Stock, visits and commissions lived in separate tools.
Architecture
Quote in the browser
Tariff, sizing and NFC 15-100 engines run as pure, tested TypeScript in the browser. Reads and writes go straight to Postgres, where Row-Level Security enforces the tenant boundary, not app code.
- Service
- Data
- AI model
- External
Hard problems I solved
Tariff math checked against the official workbook
Payback figures depend on banded utility tariffs, levies, VAT bands and subsidy rules. Installers complained estimates were wrong, and the only reference is the national agency's Excel workbook, which ships with a single cached scenario.
Approach. Golden tests against the official PROFITPV workbook: inputs written with openpyxl, recalculated headlessly in LibreOffice, results read back as new oracle cases. Then an audit of five real bills against the engine.
Found and fixed a 16% under-estimate (a missing levy, a stale rate, missing VAT) and an earlier payback error of about 3 years.
An electrical engine that cannot contradict itself
A utility reviewer rejects a dossier whose string layout breaks the inverter's voltage window or its per-tracker current limit. A solver that says 'no layout exists' when the real issue is the equipment is just as wrong.
Approach. The stringing solver enumerates only exact series by parallel divisors, filters on the layout-dependent limits, and reports layout-independent problems (power ratio, current at 85 degrees C) as violations instead of hiding them.
PDF generation that cannot leak
Puppeteer's request interception misses WebSockets, WebRTC and prefetches. In testing, 4 STUN datagrams from the print browser reached a test attacker.
Approach. The browser never gives Chromium an authenticated route. It POSTs self-contained HTML; Chromium runs behind a dead proxy with WebRTC forced to proxied-only, and the function verifies fonts loaded and printed pages equal the engine's sheet count.
Multi-tenant security in the database
A multi-agent security audit returned 45 verified findings, two critical: a storage bucket readable across tenants and an unauthenticated AI endpoint that anyone could use to run up paid calls.
Approach. Storage policies scoped through can_access_project(), company-aware is_member_of and role_in helpers, JWT plus ownership plus rate limits on AI functions. A later RBAC audit impersonated each role inside Postgres and closed 6 more holes.
Both criticals fixed in production. A guard test catches PostgREST's silent 'success' on RLS-filtered writes.
An MCP connector that actually triggers OAuth in Claude.ai
The MCP SDK turns thrown errors into JSON-RPC errors with HTTP 200, but Claude.ai only starts its OAuth flow on an HTTP 401 with WWW-Authenticate.
Approach. Auth is pre-checked before the SDK runs, while initialize and tools/list stay public so the connector page renders. Tokens are stored as SHA-256 hashes, and each call executes as a 5-minute user JWT under RLS.
Vision AI that copies, code that judges
Language models misread and 'helpfully' compute values on noisy bill photos, and a wrong number ends up in a legal document.
Approach. The prompt forbids computing or guessing, the response is schema-constrained at temperature 0 with store:false, and normalisation plus plausibility checks live in tested code. The edge copy of the prompt is byte-identical to the app copy, enforced by a test.
Measured on 5 real bills x 3 runs: 323 of 330 values correct, about 2 seconds per bill.
Code
Only exact divisor layouts survive the layout-dependent limits; ranking prefers balanced trackers, then the optimal string length. Returning null is a real answer: change the equipment.
export function proposeStringing(panel: PanelElectricalSpec, inverter: InverterElectricalSpec,
moduleCount: number): StringConfig | null {
const nsMin = minModulesInSeries(panel, inverter).value;
const nsMax = maxModulesInSeries(panel, inverter).value;
const npMaxPerMppt = maxStringsPerMppt(panel, inverter).value;
const availableInputs = inverter.nbMppt * inverter.nbInputsPerMppt;
// The band the MPPT tracks best, kept inside the band the inverter survives.
const nsTarget = Math.min(Math.max(optimalModulesInSeries(panel, inverter).value, nsMin), nsMax);
const survivors: StringConfig[] = [];
for (let np = 1; np <= moduleCount; np++) {
if (moduleCount % np !== 0) continue;
const ns = moduleCount / np;
if (ns < nsMin || ns > nsMax) continue;
if (np > availableInputs) continue;
if (stringsOnBusiestMppt(np, inverter.nbMppt) > npMaxPerMppt) continue;
survivors.push({ ns, np });
}
if (survivors.length === 0) return null; // a real answer: change the equipment
survivors.sort((a, b) =>
trackerImbalance(a.np, inverter.nbMppt) - trackerImbalance(b.np, inverter.nbMppt) ||
Math.abs(a.ns - nsTarget) - Math.abs(b.ns - nsTarget) ||
b.ns - a.ns);
return survivors[0];
}/** Measured 2026-09-29 on five real bills, three runs each:
* 3.5 Flash-Lite, photo 1600 px 323 of 330 values right, about 2 s a bill */
export const MODELS = ["gemini-3.5-flash-lite", "gemini-3.8-flash"] as const;
export const SYSTEM_INSTRUCTION = `You read photos of Tunisian STEG electricity bills.
Copy values exactly as printed. Never compute, correct or guess a value: if it is not legible,
answer an empty string. Only the ELECTRICITY section counts ... Ignore the gas section.`;
export function buildRequestBody(imageBase64: string, mimeType: string, model: string = MODELS[0]) {
return {
model,
system_instruction: SYSTEM_INSTRUCTION,
input: [{ type: "text", text: "Read this bill." },
{ type: "image", data: imageBase64, mime_type: mimeType }],
generation_config: { temperature: 0, thinking_level: "low", max_output_tokens: 4096 },
response_format: { type: "text", mime_type: "application/json", schema: RESPONSE_SCHEMA },
store: false, // nothing of a client's bill is kept on the provider's side
};
}server.setRequestHandler(CallToolRequestSchema, async (req) => {
const ctx = await authenticate(authHeader); // PAT or OAuth token, sha256-matched
const token = authHeader!.slice('Bearer '.length).trim();
const limit = checkRateLimit(createHash('sha256').update(token).digest('hex'));
if (limit) throw new McpError('rate_limited', `Try again in ${limit.retryAfter}s`, limit.retryAfter);
const tool = tools.find((t) => t.name === req.params.name);
if (!tool) throw new McpError('not_found', `Unknown tool: ${req.params.name}`);
if (!ctx.scopes.includes(tool.requiredScope))
throw new McpError('forbidden', `Token lacks required scope: ${tool.requiredScope}`);
const result = await tool.handler(tool.parse(req.params.arguments ?? {}), ctx);
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
});
// auth.ts: the data client is a 5-minute JWT for that user, so Postgres RLS applies unchanged
function mintUserJwt(userId: string): string {
return jwt.sign({ sub: userId, role: 'authenticated', aud: 'authenticated',
iss: `${env('SUPABASE_URL')}/auth/v1` },
env('SUPABASE_JWT_SECRET'), { expiresIn: '5m' });
}What I built
Estimation engine
- Utility bill calculator for residential, commercial and medium-voltage tariffs
- PV sizing from real bills, satellite yield (EU PVGIS) and 25-year projection with financing
- Hour-by-hour medium-voltage net-metering ledger per time-of-use period
- Battery and solar water-pumping sizing from official reference guides
Regulatory documents
- Official forms filled by overlaying data on the utility's own sheets
- Pre-filing check that runs the regulator's own verification list
- Cable sizing, protections and stringing to NFC 15-100
- Single-line diagrams, layout plans and string plans generated on A3
Field and sales
- CRM, lead intake, 40-field technical visit form with photos
- Quote composer, proformas, invoices, stock ledger and commissions
- 3D roof editor with sun simulation and near-shade loss
- Daily digest and target alerts via scheduled jobs
AI and platform
- Bill photo and datasheet PDF to structured values (Gemini vision)
- AI activity reports where code computes the facts and the model writes prose
- MCP server so Claude and ChatGPT can query a company's data
- Multi-organisation tenancy, 5 roles, French and English UI
Screens
Panel layout on satellite imagery, filled by the utility's rules, with near-shade loss per row.
Single-line diagram generated from the equipment and stringing engine, printed on A3.
Regulator dossier: 25 generated sheets, 32 automated checks before filing.
Feasibility study: PVGIS yield, 25-year savings and payback from the tariff engine.
Quote composer with per-line VAT, discounts and budget rescaling.
Project cockpit: phases, gated approvals, tasks and margin.
Stack
Frontend
- React 18
- TypeScript
- Vite
- TanStack Query
- Three.js
- Leaflet
- Tailwind (OKLCH tokens)
Backend
- Supabase Postgres
- Row-Level Security
- 14 Deno Edge Functions
- pg_cron
- Vercel functions
AI
- Gemini vision (JSON schema)
- MiniMax
- MCP SDK
- OAuth 2.1 + PKCE
Documents
- puppeteer-core
- @sparticuz/chromium
- pdf-lib
- SheetJS
Quality
- Vitest
- Playwright visual regression
- WCAG contrast gate
- PostHog
How it was built
Built solo with an AI-native workflow: I write the spec and plan (70 design specs, 61 plans in the repo), Claude Code implements one pull request per task, and nothing merges without tests and a browser walk-through on the PR preview. The project started from a Lovable scaffold (43 bot commits on day one); everything after that is in my git history.