# Harvest Hub

Harvest Hub is a farmers-market marketplace for connecting local growers, makers, and food producers with nearby shoppers. Vendors can list seasonal products, manage pickup availability, and track orders, while customers can browse market stalls, reserve items, and pay ahead for pickup.

## Features

- Vendor storefronts with profiles, location, certifications, and market schedule
- Product listings for produce, baked goods, dairy, flowers, pantry goods, and prepared foods
- Seasonal inventory tracking with stock limits and availability windows
- Customer search by category, vendor, market date, pickup location, and dietary tags
- Cart and checkout flow with pickup time selection
- Order management for vendors, including fulfillment status and customer notes
- Market manager dashboard for vendor approvals, featured stalls, and reporting
- Email notifications for order confirmations, cancellations, and pickup reminders
- Configurable payment provider support
- Responsive design for shoppers browsing from mobile devices at the market

## Install

### Prerequisites

- Node.js 20+
- PostgreSQL 15+
- pnpm 9+

### Setup

```bash
git clone https://github.com/example/harvest-hub.git
cd harvest-hub
pnpm install
cp .env.example .env
```

Create a local PostgreSQL database:

```bash
createdb harvest_hub
```

Run database migrations and seed sample data:

```bash
pnpm db:migrate
pnpm db:seed
```

Start the development server:

```bash
pnpm dev
```

The app will be available at:

```text
http://localhost:3000
```

## Usage

### Customer Flow

1. Browse available markets or search for vendors near your location.
2. Add products to the cart from one or more vendors.
3. Choose an available pickup date and time.
4. Complete checkout.
5. Pick up the order at the selected market stall.

### Vendor Flow

1. Sign in to the vendor dashboard.
2. Create or update product listings.
3. Set stock quantities, pricing, and pickup availability.
4. Review incoming orders.
5. Mark orders as packed, ready, or completed.

### Common Commands

```bash
pnpm dev          # Start the local development server
pnpm build        # Build the production application
pnpm start        # Run the production server
pnpm lint         # Run lint checks
pnpm test         # Run the test suite
pnpm db:migrate   # Apply database migrations
pnpm db:seed      # Seed local demo data
```

## Configuration

Harvest Hub is configured with environment variables. Copy `.env.example` to `.env` and update the values for your environment.

| Variable | Required | Description |
| --- | --- | --- |
| `DATABASE_URL` | Yes | PostgreSQL connection string |
| `APP_URL` | Yes | Public URL of the application |
| `SESSION_SECRET` | Yes | Secret used to sign user sessions |
| `PAYMENT_PROVIDER` | No | Payment provider name, such as `stripe` or `manual` |
| `STRIPE_SECRET_KEY` | No | Stripe secret key when Stripe payments are enabled |
| `STRIPE_WEBHOOK_SECRET` | No | Stripe webhook signing secret |
| `EMAIL_FROM` | No | Sender address for transactional emails |
| `SMTP_HOST` | No | SMTP server hostname |
| `SMTP_PORT` | No | SMTP server port |
| `SMTP_USER` | No | SMTP username |
| `SMTP_PASSWORD` | No | SMTP password |
| `DEFAULT_MARKET_TIMEZONE` | No | Timezone used for market schedules, defaults to `America/New_York` |

Example:

```env
DATABASE_URL=postgres://localhost:5432/harvest_hub
APP_URL=http://localhost:3000
SESSION_SECRET=replace-with-a-long-random-value
PAYMENT_PROVIDER=manual
DEFAULT_MARKET_TIMEZONE=America/New_York
```

For production deployments, set `APP_URL`, `SESSION_SECRET`, `DATABASE_URL`, payment credentials, and email settings through your hosting provider's secret manager.