# Installation & Setup Guide

This guide walks you through the steps to get your GroupCord instance running in a professional production environment.

## 📋 Prerequisites

- Node.js (v20+)
- Discord & GroupMe Developer Accounts
- (Optional) Cloudflare Account for worker/D1 hosting.
- (Optional) Docker for GHCR-based orchestration.

## 🛠️ Step 1: Database Orchestration

GroupCord supports three database modes:

1.  **Cloudflare D1 (Recommended for Cloud)**: No connection string needed. Use the `DB` binding.
2.  **Postgres (Recommended for Docker)**: `DATABASE_URL="postgresql://user:pass@id:5432/db"`
3.  **Local SQLite**: `DATABASE_URL="./data/groupcord.db"`

## 🤖 Step 2: Environment Setup

Populate your `.env` with the following critical keys:

```bash
BASE_URL="https://your-domain.com"
SESSION_SECRET="..." # CRITICAL: Long random string
DATABASE_URL="..." # (Optional if using D1)

# Platform Keys
DISCORD_CLIENT_ID="..."
DISCORD_CLIENT_SECRET="..."
DISCORD_BOT_TOKEN="..."
GROUPME_CLIENT_ID="..."
```

## 🐳 Step 3: Docker Orchestration (GHCR)

GroupCord is officially distributed via `ghcr.io`. To launch with Postgres:

```bash
# Populate .env then launch
docker-compose up -d
```
The compose file will automatically pull the latest image from GitHub and link it to a Postgres 16 instance.

## 🌩️ Step 4: Cloudflare Pages

1. Connect your repository to **Cloudflare Pages**.
2. Build Command: `npm run build`.
3. Output Directory: `build/client`.
4. Ensure the `DB` D1 binding is configured in the Pages dashboard.

---
*GroupCord: Bridging the platforms with professional-grade orchestration.* 🛡️🥂
