This is a code bundle for Internal Tool for Device Management. The original project is available at https://www.figma.com/design/78fzmJPe6YSG6LYX2zs6Yi/Internal-Tool-for-Device-Management.
Follow these steps faithfully to configure the Supabase backend and edge functions for the internal tool.
Before anything else, install the necessary node modules:
npm installYou must create a .env file at the root of the project with credentials from your Supabase Dashboard.
- Go to your Supabase Dashboard.
- Select your active project.
- In the left sidebar, navigate to Project Settings > API.
Create a new file named exactly .env in the same directory as this README and fill in the following values using the dashboard:
# 1. Project URL (Found under Project Settings -> API -> "Project URL")
SUPABASE_URL=https://[YOUR_PROJECT_ID].supabase.co
# 2. Service Role Key (Found under Project Settings -> API -> "Project API Keys" -> service_role secret)
# ⚠️ Keep this secret! This grants admin bypass rules to your database for the Edge Function backend.
SUPABASE_SERVICE_ROLE_KEY=ey...
# 3. Project ID (Found in the URL of your Supabase dashboard or the prefix of your Project URL)
VITE_SUPABASE_PROJECT_ID=[YOUR_PROJECT_ID]
# 4. Anon Key (Found under Project Settings -> API -> "Project API Keys" -> anon public)
VITE_SUPABASE_ANON_KEY=ey...
# Optional Configuration Overrides
KV_TABLE_NAME=kv_store
EDGE_FN_NAME=edge-functionOnce your .env is populated, run the automated bootstrap command. This script securely links your local code to your Supabase project, creates and pushes the necessary database tables (migrations), and securely bundles and deploys your Edge Function API.
npm run bootstrapIf you encounter permission errors during bootstrap, run these commands to fix file permissions:
# Make scripts executable
chmod -R +x scripts/
# Fix file ownership (replace $USER with your username if needed)
chown -R $USER:$USER .The bootstrap script attempts to fix these permissions automatically on Unix-like systems (Linux/macOS).
Notes:
- The scripts call the Supabase CLI via
npx supabase .... You can also install the Supabase CLI globally. - The scripts will create a migration SQL file in
supabase/migrations/and then apply it to your database using the CLI. - The edge function source is copied from
src/supabase/functions/serverintosupabase/functions/<EDGE_FN_NAME>before deployment. Verify the generated function code if you customized server internals. - The base path for API routes is automatically set to
/${EDGE_FN_NAME}based on your environment configuration. - If the edge function already exists, the deployment script will skip creation and proceed with updating the existing function.