Skip to content

ragavpn/EGA-Internal-Tool

Repository files navigation

Internal Tool for Device Management

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.

Running the code

Setup and Deployment Guide

Follow these steps faithfully to configure the Supabase backend and edge functions for the internal tool.

Step 1: Install Dependencies

Before anything else, install the necessary node modules:

npm install

Step 2: Configure Environment Variables

You must create a .env file at the root of the project with credentials from your Supabase Dashboard.

  1. Go to your Supabase Dashboard.
  2. Select your active project.
  3. 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-function

Step 3: Bootstrap the Backend

Once 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 bootstrap

Troubleshooting Permission Issues

If 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/server into supabase/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.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors