Logo Lanfrica

Francesscodes/SunFi-Solar-Intelligence-for-African-SMEs

Domain:

environment and energy

Record type:

software
Creator:
Fra
Host:
AI-powered solar sizing, cost analysis, and verified vendor matching for small and medium businesses across Africa. SUNFi Solar Engine — Backend Documentation File: `solarLogic.js` Version: 1.0 Project: SUNFi — AI-Powered Solar Advisory Platform **Author:** Backend Developer The Problem: "Helping Nigerian SMEs transition from expensive diesel generators to cost-effective solar solutions." Key Features: Dynamic Solar Sizing Algorithm. 10-Year Financial ROI Projection (Solar vs. Diesel). Vendor Matching based on Geography and System Capacity. Automated Quote Request Persistence. Tech Stack: Node.js, FileSystem (FS) API for data persistence, JSON. Last Updated:** February 2026 Overview `solarLogic.js` is the core backend engine for the SUNFi platform. It handles all business logic for the solar advisory workflow — from validating a user's monthly energy bill, to sizing the appropriate solar system, matching verified vendors, saving quote requests to disk, and generating admin analytics. This module is written in plain Node.js and exports seven functions. It has two external dependencies at runtime: - `vendors_enhanced.json` — the local vendor database (loaded via `require()` inside `getMatchingVendors` and `saveQuoteRequest`) - `quote_requests.json` — a file-based store for submitted quote requests (read/written by `saveQuoteRequest` and `getSystemAnalytics`) All sizing calculations run entirely client-side using deterministic formulas — no ML model or external API is needed for the core recommendation engine. Function Reference | Function | Arguments | Returns | |---|---|---| | `validateInput(monthlyBill)` | `monthlyBill` *(number)* — the SME's combined monthly electricity + diesel cost in Naira | `{ isValid, type, message }` — a validation result object (see Error Handling section) | | `calculateSolarSizing(monthlyBill)` | `monthlyBill` *(number)* — validated monthly bill in Naira | `sizingResult` — a deeply nested object with consumption, system size, components, costs, financials, and a plain-language explanation (see Data Models section) | | `formatNaira(amount)` | …