diff --git a/README.md b/README.md index 8875daf2..0fdb9fe8 100644 --- a/README.md +++ b/README.md @@ -1,628 +1,121 @@ -# Astro Starter Kit: Basics +# Webstack Builders Corporate Website -@TODO: See NOTES.md, this file is split between here and there. Consider using Nightwatch instead of Playwright for e2e testing. +Production corporate website built with [Astro](https://astro.build), deployed on Vercel. This repo reflects how I approach production systems: strict code boundaries, layered quality gates, GDPR-compliant data handling, and tested infrastructure from the markdown pipeline through to transactional email. -@TODO: See here for utility components like shortcodes: +## What's Different About This Repo -## Contributing & Git Workflow +Most Astro sites are content-only. This one runs a full backend (Astro Actions, Turso/SQLite, Sentry, GDPR consent tracking, transactional email) alongside a content pipeline with 30+ remark/rehype plugins, all enforced by custom ESLint rules, multi-tier testing, and 12 CI/CD workflows. -This repository uses branch protection and automated quality checks. See [docs/GIT_WORKFLOW.md](./docs/GIT_WORKFLOW.md) for complete details. +## Architecture Highlights -**Quick Start:** +### Strict Client/Server Code Segregation -```bash -# Create a feature branch (required - cannot commit to main) -git checkout -b feature/your-feature-name - -# Make changes and commit (hooks will run automatically) -git commit -m "Your message" - -# Push and create a Pull Request -git push -u origin feature/your-feature-name -``` - -**Branch Naming:** - -- `feature/*` - New features -- `bugfix/*` - Bug fixes -- `hotfix/*` - Critical production fixes -- `infrastructure/*` - DevOps/CI/CD changes -- `maintenance/*` - Dependency updates, refactoring -- `content/*` - Content updates - -**Pre-commit Checks:** - -- Unit tests must pass -- Branch name must follow conventions -- Cannot commit directly to main - -### Local Development Server - -Use the helper script below to start Astro with `.env.development` automatically loaded: - -```bash -npm run dev:env -``` - -The underlying `npm run dev` command remains unchanged for CI and Vercel; `dev:env` is just a convenience for local shells so API routes that depend on `process.env` (cron handlers, email providers, etc.) behave the same way they do in production. - -## Astro DB Workflows - -Astro DB schemas now live under `db/config.ts`. Applying those migrations requires `npx astro db push`; the regular `astro build` command never pushes schema changes for you. Keep local and remote pushes separate to avoid promoting unfinished changes: - -- **Local development / CI** – Point Astro DB at the file-based database via `ASTRO_DB_REMOTE_URL="file:./.astro/content.db"` and run `npx astro db push`. For convenience the `build:ci` script exports `ASTRO_DATABASE_FILE=./.astro/content.db` before invoking `astro build`, so `npm run build:ci` is the go-to command anywhere you need a build that reads the local snapshot (including GitHub Actions). -- **Production Turso push** – Export your Turso connection details (`ASTRO_DB_REMOTE_URL` + `ASTRO_DB_APP_TOKEN`) and run `npx astro db push --remote`. The merge-to-main workflow should be the only automation that executes this command. -- **Vercel deployments** – Set the build command to `npm run build -- --remote` so the build pipeline talks to Turso in read-only mode while still leaving schema promotion to the dedicated workflow. - -> `ASTRO_DATABASE_FILE` is evaluated before Astro loads `.env.*`, so put it directly in the shell invocation (e.g., `ASTRO_DATABASE_FILE=./.astro/content.db npm run build`) or reuse the provided `npm run build:ci` helper. Dropping the variable into `.env.development` or `.env.production` will not satisfy the build hook. - -### Build scripts - -- `npm run build` – Runs `astro build --remote`, hitting the production Turso database in read-only mode. Use this for Vercel deployments and any workflows that need to mirror production infrastructure. -- `npm run build:ci` – Exports `ASTRO_DATABASE_FILE=./.astro/content.db` before delegating to `npm run build`, forcing the build to read from the local SQLite snapshot. Use this for local testing and the `Test` GitHub workflow so schema changes stay isolated until the Turso push workflow runs. - -## Fork PR Preview Deployments - -Preview deployments are intentionally restricted to pull requests from branches within this repository (non-fork PRs). - -Reason: our deployment pipeline runs in a privileged GitHub Actions context (it uses repository secrets for Vercel and has write permissions for checks/comments). Running those steps against forked PR commits would risk executing untrusted code with access to secrets. - -If we ever need fork PR preview deployments, implement a safer design first, such as: -- Dual-checkout + `working-directory` (trusted checkout for local actions/tooling, untrusted checkout in a separate path for deploy input) -- Artifact-based deploy (build/test in the untrusted workflow, upload a signed artifact, deploy the artifact in the trusted workflow) - -## Coding Standards - -### Component Architecture - -**Script Organization:** - -- Layouts (`src/layouts`) and pages (`src/pages`) must not contain `