Преглед изворни кода

feat: simplify and consolidate project configuration #15

- Updated frontend .env.example with complete Supabase configuration
  - Added VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY
  - Clarified relationship between VITE_SUPABASE_URL and VITE_API_URL
  - Set default VITE_FRONTEND_URL to localhost for development

- Created backend .env.example for Supabase Edge Functions
  - Organized configuration into logical sections
  - Added clear comments and instructions for obtaining credentials
  - Included all required environment variables

- Updated CLAUDE.md with simplified configuration instructions
  - Added Quick Setup section with step-by-step instructions
  - Clarified the relationship between duplicate environment variables
  - Documented that VITE_API_URL is derived from VITE_SUPABASE_URL

This resolves the issue of duplicated configuration keys and missing
.env.example files, making the project setup more straightforward.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Claude пре 5 месеци
родитељ
комит
ed034fe219
3 измењених фајлова са 105 додато и 26 уклоњено
  1. 40 24
      CLAUDE.md
  2. 8 2
      shopcall.ai-main/.env.example
  3. 57 0
      supabase/.env.example

+ 40 - 24
CLAUDE.md

@@ -400,47 +400,63 @@ supabase functions serve
 
 ## Environment Configuration
 
+### Quick Setup
+
+1. **Frontend**: Copy `shopcall.ai-main/.env.example` to `.env` and fill in your values
+2. **Backend**: Copy `supabase/.env.example` to `.env` and fill in your values
+3. **Database**: Configure pg_cron settings in Supabase Dashboard (see below)
+
 ### Frontend `.env` (shopcall.ai-main)
+
+Required environment variables:
+
 ```bash
-# Supabase Configuration
-VITE_SUPABASE_URL=https://ztklqodcdjeqpsvhlpud.supabase.co
-VITE_SUPABASE_ANON_KEY=<anon_key>
+# Supabase Configuration (from Supabase Dashboard → Settings → API)
+VITE_SUPABASE_URL=https://YOUR_PROJECT.supabase.co
+VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
 
-# Backend API Base URL (Supabase Edge Functions)
-VITE_API_URL=https://ztklqodcdjeqpsvhlpud.supabase.co/functions/v1
+# Backend API Base URL (typically VITE_SUPABASE_URL + /functions/v1)
+VITE_API_URL=https://YOUR_PROJECT.supabase.co/functions/v1
 
 # Frontend URL (for OAuth callbacks)
-VITE_FRONTEND_URL=https://shopcall.ai
+VITE_FRONTEND_URL=http://localhost:8080  # or https://yourdomain.com for production
 ```
 
-### Supabase Edge Functions `.env`
+**Note**: `VITE_API_URL` is derived from `VITE_SUPABASE_URL` by appending `/functions/v1`
+
+### Supabase Edge Functions `.env` (supabase)
+
+Required environment variables:
+
 ```bash
-# OAuth Configuration
-SHOPIFY_API_KEY=<shopify_api_key>
-SHOPIFY_API_SECRET=<shopify_api_secret>
-SHOPRENTER_CLIENT_ID=<shoprenter_client_id>
-SHOPRENTER_CLIENT_SECRET=<shoprenter_client_secret>
+# Supabase Configuration (from Supabase Dashboard → Settings → API)
+SUPABASE_URL=https://YOUR_PROJECT.supabase.co
+SUPABASE_ANON_KEY=your_supabase_anon_key
+SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
 
-# Scheduled Sync Security
-INTERNAL_SYNC_SECRET=<random_secure_secret_for_scheduled_sync>
+# Frontend URL (same as VITE_FRONTEND_URL in frontend .env)
+FRONTEND_URL=http://localhost:8080  # or https://yourdomain.com for production
 
-# Email Configuration
-RESEND_API_KEY=<resend_api_key>
+# E-commerce Platform OAuth Credentials
+SHOPIFY_API_KEY=your_shopify_api_key
+SHOPIFY_API_SECRET=your_shopify_api_secret
+SHOPRENTER_CLIENT_ID=your_shoprenter_client_id
+SHOPRENTER_CLIENT_SECRET=your_shoprenter_client_secret
 
-# Frontend URL
-FRONTEND_URL=https://shopcall.ai
+# Internal Security (generate with: openssl rand -hex 32)
+INTERNAL_SYNC_SECRET=your_random_secure_secret
 
-# Supabase Configuration
-SUPABASE_URL=<supabase_project_url>
-SUPABASE_ANON_KEY=<supabase_anon_key>
-SUPABASE_SERVICE_ROLE_KEY=<supabase_service_role_key>
+# Email Configuration (from https://resend.com/api-keys)
+RESEND_API_KEY=your_resend_api_key
 ```
 
 ### Supabase Database Settings (for pg_cron)
+
 Configure in Supabase Dashboard → Project Settings → Database → Custom Postgres Configuration:
+
 ```
-app.internal_sync_secret = '<same_as_INTERNAL_SYNC_SECRET_above>'
-app.supabase_url = 'https://ztklqodcdjeqpsvhlpud.supabase.co'
+app.internal_sync_secret = 'same_as_INTERNAL_SYNC_SECRET_above'
+app.supabase_url = 'https://YOUR_PROJECT.supabase.co'
 ```
 
 ## Deployment

+ 8 - 2
shopcall.ai-main/.env.example

@@ -1,9 +1,15 @@
+# Supabase Configuration
+# Get these from your Supabase project: Settings → API
+VITE_SUPABASE_URL=https://YOUR_PROJECT.supabase.co
+VITE_SUPABASE_ANON_KEY=your_supabase_anon_key_here
+
 # Backend API Base URL (Supabase Edge Functions)
+# Automatically derived from VITE_SUPABASE_URL + /functions/v1
 # For production: https://YOUR_PROJECT.supabase.co/functions/v1
 # For local dev: http://localhost:54321/functions/v1
-VITE_API_URL=https://ztklqodcdjeqpsvhlpud.supabase.co/functions/v1
+VITE_API_URL=https://YOUR_PROJECT.supabase.co/functions/v1
 
 # Frontend URL (for OAuth callbacks and redirects)
 # For production: https://yourdomain.com
 # For local dev: http://localhost:8080
-VITE_FRONTEND_URL=https://shopcall.ai
+VITE_FRONTEND_URL=http://localhost:8080

+ 57 - 0
supabase/.env.example

@@ -0,0 +1,57 @@
+# =============================================================================
+# Supabase Edge Functions Environment Configuration
+# =============================================================================
+
+# -----------------------------------------------------------------------------
+# Supabase Configuration
+# -----------------------------------------------------------------------------
+# Get these from: Supabase Dashboard → Settings → API
+SUPABASE_URL=https://YOUR_PROJECT.supabase.co
+SUPABASE_ANON_KEY=your_supabase_anon_key_here
+SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key_here
+
+# -----------------------------------------------------------------------------
+# Frontend Configuration
+# -----------------------------------------------------------------------------
+# URL where your frontend is hosted (used for OAuth redirects)
+# For production: https://yourdomain.com
+# For local dev: http://localhost:8080
+FRONTEND_URL=http://localhost:8080
+
+# -----------------------------------------------------------------------------
+# E-commerce Platform OAuth Credentials
+# -----------------------------------------------------------------------------
+
+# Shopify App Credentials
+# Get these from: Shopify Partner Dashboard → Apps → Your App
+SHOPIFY_API_KEY=your_shopify_api_key
+SHOPIFY_API_SECRET=your_shopify_api_secret
+
+# ShopRenter App Credentials
+# Get these from: ShopRenter App Store → Your App
+SHOPRENTER_CLIENT_ID=your_shoprenter_client_id
+SHOPRENTER_CLIENT_SECRET=your_shoprenter_client_secret
+
+# WooCommerce OAuth (configured per-store, no global credentials needed)
+
+# -----------------------------------------------------------------------------
+# Internal Security
+# -----------------------------------------------------------------------------
+# Secret key for scheduled sync authentication (generate with: openssl rand -hex 32)
+INTERNAL_SYNC_SECRET=your_random_secure_secret_here
+
+# -----------------------------------------------------------------------------
+# Email Configuration
+# -----------------------------------------------------------------------------
+# Resend API Key for sending emails
+# Get this from: https://resend.com/api-keys
+RESEND_API_KEY=your_resend_api_key_here
+
+# -----------------------------------------------------------------------------
+# Database Configuration (for pg_cron scheduled sync)
+# -----------------------------------------------------------------------------
+# These should also be set in Supabase Dashboard:
+# Settings → Database → Custom Postgres Configuration
+#
+# app.internal_sync_secret = 'same_as_INTERNAL_SYNC_SECRET_above'
+# app.supabase_url = 'https://YOUR_PROJECT.supabase.co'