This guide walks you through setting up the NDI registration platform from scratch on Cloudflare.
- Bun (v1.0+) or Node.js 18+
- Wrangler CLI
- Cloudflare account with Workers paid plan (for D1)
# Clone with submodules
git clone --recursive git@github.com:info-evry/astro-ndi.git
cd astro-ndi
# Install dependencies
bun installbunx wrangler d1 create ndi-dbCopy the database_id from the output and update wrangler.toml:
[[d1_databases]]
binding = "DB"
database_name = "ndi-db"
database_id = "YOUR_DATABASE_ID"bunx wrangler kv namespace create CONFIGCopy the id from the output and update wrangler.toml:
[[kv_namespaces]]
binding = "CONFIG"
id = "YOUR_KV_ID"Run migrations to create the database schema:
# Apply schema
bunx wrangler d1 execute ndi-db --remote --file=./db/schema.sql
# Apply migrations in order
bunx wrangler d1 execute ndi-db --remote --file=./db/migrate-001-settings.sql
bunx wrangler d1 execute ndi-db --remote --file=./db/migrate-002-attendance.sql
# ... continue with remaining migrationsOr create the schema manually:
bunx wrangler d1 execute ndi-db --remote --command="
CREATE TABLE IF NOT EXISTS teams (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
description TEXT,
password_hash TEXT NOT NULL,
is_organisation INTEGER DEFAULT 0,
created_at TEXT DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS members (
id INTEGER PRIMARY KEY AUTOINCREMENT,
team_id INTEGER NOT NULL,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
email TEXT NOT NULL UNIQUE,
bac_level INTEGER DEFAULT 0,
food_diet TEXT,
is_leader INTEGER DEFAULT 0,
created_at TEXT DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (team_id) REFERENCES teams(id)
);
CREATE TABLE IF NOT EXISTS settings (
key TEXT PRIMARY KEY,
value TEXT NOT NULL
);
"# Set the admin authentication token
bunx wrangler secret put ADMIN_TOKEN
# Enter a secure random token when promptedEdit wrangler.toml to customize:
[vars]
ADMIN_EMAIL = "your-admin@example.com"
REPLY_TO_EMAIL = "contact@example.com"
MAX_TEAM_SIZE = "15"
MAX_TOTAL_PARTICIPANTS = "200"
MIN_TEAM_SIZE = "1"bun run deploy- Visit your Worker URL (shown after deploy)
- Access
/adminand enter your admin token - Verify the dashboard loads correctly
Run the database schema and migrations:
bunx wrangler d1 execute ndi-db --remote --file=./db/schema.sqlThe Astro Cloudflare adapter expects a KV binding for sessions. Either:
- Add a KV binding named
SESSIONin wrangler.toml - Or add an empty
.assetsignoreto public/ to suppress the warning
Verify ADMIN_TOKEN secret is set:
bunx wrangler secret list- See deploy.md for deployment workflow
- Configure GitHub Actions for CI/CD