# RoastRoute

RoastRoute is a coffee subscription platform for managing recurring coffee deliveries, customer preferences, roast schedules, and subscription billing. It is designed for small roasting teams that need a practical way to sell subscriptions, track orders, and keep customers matched with the coffees they actually like.

## Overview

Customers can create a subscription, choose their preferred roast profile and grind type, set delivery frequency, and update shipment preferences from their account. Operators can manage coffees, inventory, upcoming shipments, and subscription status from an admin workflow.

## Features

- Customer subscription signup and account management
- Weekly, biweekly, and monthly delivery schedules
- Roast profile, grind type, and bag size preferences
- Coffee catalog with origin, tasting notes, roast level, and inventory
- Upcoming shipment generation
- Subscription pause, resume, and cancellation flows
- Basic order history and delivery status tracking
- Environment-based configuration for local and production deployments

## Install

Clone the repository:

```bash
git clone https://github.com/example/roastroute.git
cd roastroute
```

Install dependencies:

```bash
npm install
```

Create a local environment file:

```bash
cp .env.example .env
```

Run database migrations:

```bash
npm run db:migrate
```

Start the development server:

```bash
npm run dev
```

The app will be available at:

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

## Usage

Start the app locally and create an admin account:

```bash
npm run dev
npm run admin:create
```

Seed sample coffees and subscription plans:

```bash
npm run db:seed
```

Run the test suite:

```bash
npm test
```

Build for production:

```bash
npm run build
```

Start the production server:

```bash
npm start
```

## Configuration

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

```env
APP_URL=http://localhost:3000
DATABASE_URL=postgres://roastroute:password@localhost:5432/roastroute

SESSION_SECRET=change-me

STRIPE_SECRET_KEY=sk_test_example
STRIPE_WEBHOOK_SECRET=whsec_example

SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=orders@example.com
SMTP_PASSWORD=change-me
SMTP_FROM="RoastRoute <orders@example.com>"

DEFAULT_CURRENCY=usd
DEFAULT_TIMEZONE=America/New_York
SHIPMENT_CUTOFF_DAY=tuesday
```

Common configuration options:

- `APP_URL`: Public URL for the application.
- `DATABASE_URL`: PostgreSQL connection string.
- `SESSION_SECRET`: Secret used to sign user sessions.
- `STRIPE_SECRET_KEY`: Stripe API key for subscription billing.
- `STRIPE_WEBHOOK_SECRET`: Stripe webhook signing secret.
- `SMTP_*`: Email delivery settings for order and account notifications.
- `DEFAULT_CURRENCY`: Currency used for plans and invoices.
- `DEFAULT_TIMEZONE`: Timezone used for shipment scheduling.
- `SHIPMENT_CUTOFF_DAY`: Last day customers can update preferences before the next roast cycle.