agora-webapp

Agora Marketplace

A modern B2B SaaS marketplace built with SvelteKit 5, Supabase, and TypeScript. Agora enables startups to discover, compare, and purchase business services across multiple categories.

Features

Product Comparison System

Tech Stack

Project Structure

src/
├── lib/
│   ├── components/          # Reusable UI components
│   │   ├── ComparisonBar.svelte
│   │   ├── ComparisonTable.svelte
│   │   ├── ProductCard.svelte
│   │   ├── ProductDetailView.svelte
│   │   └── ...
│   ├── services/            # Business logic and API calls
│   │   ├── products.ts
│   │   ├── cart.ts
│   │   ├── bookmarks.ts
│   │   └── ...
│   ├── stores/              # Svelte stores
│   │   └── comparison.ts    # Comparison state management
│   └── helpers/             # Utility functions and types
├── routes/
│   ├── (buyer)/             # Buyer-specific routes
│   │   ├── cart/
│   │   ├── bookmarks/
│   │   ├── dashboard/
│   │   └── orders/
│   ├── (seller)/            # Seller-specific routes
│   │   └── seller/
│   ├── marketplace/         # Product browsing
│   ├── compare/             # Product comparison
│   ├── products/[id]/       # Product detail pages
│   └── api/                 # API endpoints
└── supabase/
    └── migrations/          # Database schema migrations

Key Components

ComparisonTable

Displays up to 3 products side-by-side with:

ComparisonBar

Persistent bottom bar that:

ProductCard

Reusable product card with:

Database Schema

Core Tables

State Management

Comparison Store

Manages product comparison state with:

Cart State

Key Features Implementation

Optimistic UI Updates

All user actions (bookmark, cart, compare) use optimistic updates:

  1. Update local state immediately
  2. Make API call
  3. Revert on error

Server-Side Data Loading

Cart quantities and bookmarks loaded server-side for:

Category-Specific Metrics

Each category has unique metrics stored in:

Score Calculation

Products scored on 4 dimensions:

Development

Prerequisites

Initial Setup

Prerequisites

Installation Steps

1. Clone Repository

git clone <repository-url>
cd agora-webapp

2. Install Dependencies

npm install
# or
pnpm install

3. Configure Environment Variables

Create a .env file in the project root with the following content:

# supabase configuration
SUPABASE_URL=https://sbfpxgsgabkgbutzhgwm.supabase.co
SUPABASE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNiZnB4Z3NnYWJrZ2J1dHpoZ3dtIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjIxODg0ODMsImV4cCI6MjA3Nzc2NDQ4M30.45pNssaz8rTmgOE-QL_ks0RMEEych7OzaFORdJHcEQA
PUBLIC_SUPABASE_URL=https://sbfpxgsgabkgbutzhgwm.supabase.co
PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNiZnB4Z3NnYWJrZ2J1dHpoZ3dtIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjIxODg0ODMsImV4cCI6MjA3Nzc2NDQ4M30.45pNssaz8rTmgOE-QL_ks0RMEEych7OzaFORdJHcEQA

Note: These are public credentials that connect you to a shared demo Supabase instance. The database is already set up with sample data. You can create your own account and test all features safely.

4. Start Development Server

npm run dev

The app will be available at http://localhost:5173

5. Sign in to Test account

  1. Navigate to sign in
  2. Sign in with email/password (email: ryanliu847@gmail.com, password: testing)

Troubleshooting

Issue: “Failed to fetch” errors

Issue: Authentication not working

Issue: RLS policy errors

Issue: Products not showing

Issue: Infinite loops in browser

Development Workflow

  1. Make changes to components/routes
  2. Hot reload automatically updates browser
  3. Check types: npm run check
  4. Lint code: npm run lint
  5. Test features in browser
  6. Commit changes with descriptive messages

Testing Accounts

For development, create these test accounts:

Add products to cart, create bookmarks, and test comparison features.

Important Notes

Svelte 5 Runes

This project uses Svelte 5 with runes ($state, $derived, $effect). Key considerations:

Infinite Loop Prevention

Watch for these patterns:

Cart Quantity Display

Cart quantities are:

Scripts

Contributing

When adding new features:

  1. Follow existing patterns for state management
  2. Use optimistic updates for user actions
  3. Fetch initial data server-side when possible
  4. Test for infinite $effect loops
  5. Ensure cart/bookmark state is consistent across pages

License

MIT