Skip to content

Developer Onboarding & Local Setup

Welcome to the Planovi Backend engineering team. This guide walks you through setting up your local workstation to develop, test, and debug Supabase Edge Functions.


Prerequisites

Before starting, ensure your workstation has the following tools installed:

ToolMinimum VersionInstallation Command / Link
Denov1.38.0+irm https://deno.land/install.ps1 | iex (Windows) or curl -fsSL https://deno.land/install.sh | sh
Supabase CLIv1.120.0+scoop bucket add supabase https://github.com/supabase/scoop-bucket.git && scoop install supabase
Docker DesktopLatestRequired for running local Supabase database and Edge Runtime containers
Node.jsv18.0.0+Required for building the documentation portal (docs/)

1. Clone & Environment Configuration

Clone the repository and inspect the Edge Functions directory:

Terminal window
git clone https://github.com/PA-IDEAS/planovi-backend.git
cd planovi-backend

Create a local environment secrets file:

Terminal window
# In supabase/
cp supabase/.env.example supabase/.env.local

Populate the following development variables in supabase/.env.local:

Terminal window
SUPABASE_URL=http://127.0.0.1:54321
SUPABASE_ANON_KEY=your-local-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-local-service-role-key
GEMINI_API_KEY=your-gemini-test-key
INCHARGE_USERNAME=test_user
INCHARGE_PASSWORD=test_password

2. Running Local Edge Functions

Start the Local Supabase Stack

Terminal window
# Starts local PostgreSQL, Auth, Storage, and Kong gateway
supabase start

Serve Edge Functions Locally

To run all 35 Edge Functions with hot-reload enabled:

Terminal window
supabase functions serve --env-file ./supabase/.env.local --no-verify-jwt

[!TIP] The --no-verify-jwt flag is helpful during local backend development so you can invoke functions directly using curl or Postman without generating real user JWTs.


3. Invoking Functions Locally

You can test any function by sending an HTTP POST request to http://localhost:54321/functions/v1/<function-name>:

Example: Testing ingest-telemetry

Terminal window
curl -i --location --request POST 'http://localhost:54321/functions/v1/ingest-telemetry' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-local-anon-key>' \
--data '{
"device_id": "test_inverter_01",
"coop_id": "00000000-0000-0000-0000-000000000000",
"metrics": {
"solar_power_kw": 10.5,
"voltage_l1": 230.1
}
}'

Example: Testing Health Endpoint (main)

Terminal window
curl -i http://localhost:54321/functions/v1/main

4. Running the Documentation Portal Locally

To launch the interactive documentation site locally:

Terminal window
cd docs
npm install
npm run dev

Navigate to http://localhost:4321 in your browser. All architecture diagrams, search indexes, and function guides will be available with hot-reloading.