Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ NEXT_PUBLIC_SUPABASE_URL="https://your-project.supabase.co"
NEXT_PUBLIC_SUPABASE_ANON_KEY="your-anon-key"
SUPABASE_SERVICE_ROLE_KEY="your-service-role-key"

# Cohere (Vision) API Key
# Anthropic (Vision) API
ANTHROPIC_API_KEY=""
# Optional: override default model used by /api/vision-detect
# Defaults to 'claude-sonnet-4-20250514' if unset
ANTHROPIC_MODEL=""

# Cohere (fallback) API Key
COHERE_API_KEY=""
# Optional: override Cohere model used as fallback (defaults to 'command-r')
COHERE_MODEL=""
NEXT_PUBLIC_MERCHANT_ID_DEFAULT="a1b2c3d4-e5f6-7890-abcd-ef1234567890"

# MINLP Service Configuration
Expand Down
142 changes: 142 additions & 0 deletions MERGE_PLAN.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# MERGE_PLAN.txt
# Current branch kept: frontend
# Other branch to replace from: backend
# Action meanings:
# KEEP <path> -> keep file contents from frontend
# REPLACE <path> -> replace file with version from backend
#
# Review and edit as needed, then apply with:
# bash scripts/apply-merge-plan.sh frontend backend
#
KEEP .env.example
KEEP .gitignore
KEEP .vscode/launch.json
KEEP .vscode/settings.json
KEEP README.md
KEEP README_DEMO.md
KEEP app/[page]/layout.tsx
KEEP app/[page]/opengraph-image.tsx
KEEP app/[page]/page.tsx
REPLACE app/api/minlp/explain/route.ts
REPLACE app/api/minlp/solve/route.ts
REPLACE app/api/products/[handle]/route.ts
REPLACE app/api/revalidate/route.ts
REPLACE app/api/sync-products/route.ts
KEEP app/api/vision-detect/route.ts
KEEP app/cart/page.tsx
KEEP app/checkout/page.tsx
KEEP app/checkout/success/page.tsx
REPLACE app/dashboard/page.tsx
KEEP app/error.tsx
KEEP app/favicon.ico
KEEP app/globals.css
KEEP app/layout.tsx
KEEP app/merchant/[merchantId]/page.tsx
KEEP app/opengraph-image.tsx
KEEP app/page.tsx
KEEP app/product/[handle]/page.tsx
KEEP app/robots.ts
KEEP app/search/[collection]/opengraph-image.tsx
KEEP app/search/[collection]/page.tsx
KEEP app/search/children-wrapper.tsx
KEEP app/search/layout.tsx
KEEP app/search/loading.tsx
KEEP app/search/page.tsx
KEEP app/sitemap.ts
KEEP components/camera-scanner.tsx
KEEP components/carousel.tsx
KEEP components/cart/actions.ts
KEEP components/cart/add-to-cart.tsx
KEEP components/cart/cart-context.tsx
KEEP components/cart/delete-item-button.tsx
KEEP components/cart/edit-item-quantity-button.tsx
KEEP components/cart/modal.tsx
KEEP components/cart/open-cart.tsx
KEEP components/cart/supabase-cart-context.tsx
REPLACE components/dashboard/DashboardClient.tsx
KEEP components/grid/index.tsx
KEEP components/grid/three-items.tsx
KEEP components/grid/tile.tsx
KEEP components/icons/logo.tsx
KEEP components/label.tsx
KEEP components/layout/footer-menu.tsx
KEEP components/layout/footer.tsx
KEEP components/layout/navbar/cart-button.tsx
KEEP components/layout/navbar/index.tsx
KEEP components/layout/navbar/mobile-menu.tsx
KEEP components/layout/navbar/scanner-button.tsx
KEEP components/layout/navbar/search.tsx
KEEP components/layout/navbar/tarazoo-navbar.tsx
KEEP components/layout/product-grid-items.tsx
KEEP components/layout/search/collections.tsx
KEEP components/layout/search/filter/dropdown.tsx
KEEP components/layout/search/filter/index.tsx
KEEP components/layout/search/filter/item.tsx
KEEP components/loading-dots.tsx
KEEP components/logo-square.tsx
KEEP components/opengraph-image.tsx
KEEP components/price.tsx
KEEP components/product/gallery.tsx
KEEP components/product/product-context.tsx
KEEP components/product/product-description.tsx
KEEP components/product/variant-selector.tsx
KEEP components/prose.tsx
KEEP components/providers.tsx
KEEP components/setup/shopify-setup.tsx
KEEP components/welcome-toast.tsx
REPLACE docs/shopify-setup.md
KEEP fonts/Inter-Bold.ttf
KEEP frontend/.next/cache/webpack/client-development-fallback/0.pack.gz
KEEP frontend/.next/cache/webpack/client-development-fallback/index.pack.gz
KEEP frontend/.next/cache/webpack/client-development/0.pack.gz
KEEP frontend/.next/cache/webpack/client-development/index.pack.gz
KEEP frontend/.next/cache/webpack/client-development/index.pack.gz.old
KEEP frontend/.next/server/app-paths-manifest.json
KEEP frontend/.next/server/pages-manifest.json
KEEP frontend/.next/server/server-reference-manifest.js
KEEP frontend/.next/server/server-reference-manifest.json
KEEP frontend/.next/types/cache-life.d.ts
KEEP frontend/.next/types/package.json
KEEP frontend/.next/types/routes.d.ts
KEEP frontend/.next/types/validator.ts
KEEP lib/constants.ts
KEEP lib/shopify-supabase-sync.ts
KEEP lib/shopify/config.ts
KEEP lib/shopify/fragments/cart.ts
KEEP lib/shopify/fragments/image.ts
KEEP lib/shopify/fragments/product.ts
KEEP lib/shopify/fragments/seo.ts
KEEP lib/shopify/index.ts
KEEP lib/shopify/mock-data.ts
KEEP lib/shopify/mutations/cart.ts
KEEP lib/shopify/queries/cart.ts
KEEP lib/shopify/queries/collection.ts
KEEP lib/shopify/queries/menu.ts
KEEP lib/shopify/queries/page.ts
KEEP lib/shopify/queries/product.ts
KEEP lib/shopify/types.ts
REPLACE lib/supabase.ts
KEEP lib/type-guards.ts
KEEP lib/utils.ts
KEEP license.md
KEEP middleware.ts
KEEP next.config.mjs
KEEP package.json
REPLACE packages/shared/types.ts
KEEP pnpm-lock.yaml
KEEP postcss.config.mjs
KEEP public/manifest.json
REPLACE scripts/add-google-bottle.js
REPLACE scripts/setup-supabase.js
REPLACE scripts/test-checkout.js
REPLACE scripts/test-shopify-connection.js
REPLACE services/minlp/main.py
REPLACE services/minlp/requirements.txt
REPLACE supabase/fix-rls.sql
REPLACE supabase/migrations/001_initial_schema.sql
REPLACE supabase/migrations/002_seed_data.sql
REPLACE supabase/migrations/003_shopify_integration.sql
REPLACE supabase/new-update.sql
REPLACE supabase/setup-all.sql
REPLACE supabase/shopify-setup.sql
KEEP tsconfig.json
42 changes: 18 additions & 24 deletions app/api/sync-products/route.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
'use server';

import { NextRequest, NextResponse } from 'next/server';
import { syncShopifyToSupabase } from 'lib/shopify-supabase-sync';
import { syncShopifyToSupabase, syncShopifyProductByHandle } from 'lib/shopify-supabase-sync';

export async function POST(request: NextRequest) {
export async function POST(req: NextRequest) {
try {
const { searchParams } = new URL(req.url);
const handle = searchParams.get('handle');
if (handle) {
const result = await syncShopifyProductByHandle(handle);
if (!result.success) {
return NextResponse.json({ error: 'Sync failed', details: result }, { status: 500 });
}
return NextResponse.json({ success: true, count: result.count || 0 });
}
const result = await syncShopifyToSupabase();

if (result.success) {
return NextResponse.json({
success: true,
message: `Synced ${result.count} products from Shopify`,
products: result.products
});
} else {
return NextResponse.json(
{ success: false, error: result.error },
{ status: 500 }
);
if (!result.success) {
return NextResponse.json({ error: 'Sync failed', details: result }, { status: 500 });
}
} catch (error) {
console.error('Sync API error:', error);
return NextResponse.json(
{ success: false, error: 'Sync failed' },
{ status: 500 }
);
return NextResponse.json({ success: true, count: result.count || 0 });
} catch (e: any) {
return NextResponse.json({ error: 'Unexpected error', details: e?.message || String(e) }, { status: 500 });
}
}

export async function GET(request: NextRequest) {
// Trigger sync on GET for easy testing
return POST(request);
}
Loading