Remove static JSON files and seed step; migrate site settings to Postgres

All content (recipes + imprint/privacy settings) now lives exclusively in
Postgres. The app no longer requires a seed step on first deploy.

Changes:
- helpers.php: load_site_settings() returns defaults when site_settings
  table is empty instead of throwing DatabaseUnavailableException; removes
  legacy JSONB migration path
- data/recipes.json, data/site.json: deleted (content already in DB)
- scripts/db-seed.php: deleted (no longer needed)
- docker-compose.yml: remove RUN_DB_SEED env var and data/ volume mount
- docker/entrypoint.sh: remove RUN_DB_SEED seed block
- docs/COOLIFY.md: update deployment guide to reflect seedless workflow
- .claude/launch.json: add dev server configurations for preview tool

Fresh deploys now start with placeholder legal pages and an empty recipe
list; the admin fills in real content via /admin.php without any CLI step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-18 09:53:39 +02:00
co-authored by Claude Sonnet 4.6
parent 792cbe18c1
commit 86fbd8e4bb
20 changed files with 154 additions and 512 deletions
+7 -7
View File
@@ -4,8 +4,8 @@ This document summarizes architectural knowledge, conventions, and learnings for
## 1. Project Architecture & Stack
- **Backend:** Vanilla PHP. No heavy frameworks.
- **Database:** PostgreSQL required (`DATABASE_URL` in `.env`). Normalized tables in `scripts/schema.sql`; `load_recipes()` / `save_recipe()` in `helpers.php`. No runtime JSON recipe file. One-time import: `php scripts/db-seed.php` from `data/recipes.json`.
- **Site settings (legal pages):** Flat-file `data/site.json` via `load_site_settings()` / `save_site_settings()` — not in Postgres.
- **Database:** PostgreSQL required (`DATABASE_URL` in `.env`). Normalized tables in `scripts/schema.sql`; `load_recipes()` / `save_recipe()` and `load_site_settings()` / `save_site_settings()` in `helpers.php`. No runtime JSON files. One-time import: `php scripts/db-seed.php` from `scripts/seed-data.php`.
- **Site settings (legal pages):** Stored in Postgres table `site_settings`; no flat-file fallback.
- **Admin Panel (`admin.php`):** Lightweight CMS. Textareas use one line per array element (`ingredients`, `steps`, `step_videos`, `step_timers`).
- **Frontend:** Server-rendered PHP (`index.php`, `recipe.php`, …), Vanilla JS/CSS. Profile/favorites via `assets/fc-local.js`.
- **Config:** `config.php` loads `.env`, `get_db_connection()`. Never commit `.env` (see `.gitignore`).
@@ -27,13 +27,14 @@ This document summarizes architectural knowledge, conventions, and learnings for
## 5. PostgreSQL — Schema & Data Flow
### Relational schema (`scripts/schema.sql`)
Created by `ensure_recipe_schema()` on first DB use. Legacy JSONB `recipes.data` is migrated once automatically.
Created by `ensure_recipe_schema()` on first DB use. Legacy JSONB/file fallbacks are not supported.
| Table | Role |
|-------|------|
| `recipes` | slug, hero, times, servings, nutrition columns, featured, coming_soon |
| `recipe_translations` | title, description, category, difficulty (en/de) |
| `recipe_tags`, `recipe_ingredients`, `recipe_utensils`, `recipe_steps` | Ordered lists per language |
| `site_settings` | imprint/privacy fields per language |
PHP still exposes the same nested arrays (`i18n`, `nutrition`, …) via `hydrate_recipes_from_db()`.
@@ -41,7 +42,7 @@ PHP still exposes the same nested arrays (`i18n`, `nutrition`, …) via `hydrate
1. `DATABASE_URL` required → `require_database()` or HTTP 503 (`maintenance/db-unavailable.php`).
2. `load_recipes()` → SQL → PHP arrays for templates.
3. Admin: `save_recipe()`, `delete_recipe()`, `clear_featured_recipes()`.
4. One-time import: `php scripts/db-seed.php` from `data/recipes.json` (not read at runtime).
4. One-time import: `php scripts/db-seed.php` from `scripts/seed-data.php`.
### `config.php` functions
- `load_env()` — parses `.env`.
@@ -123,9 +124,8 @@ See `.agents/TODO.md` (e.g. PWA & offline support). README `Local Postgres (Dock
| File | Purpose |
|------|---------|
| `config.php` | `.env`, Firebase config, PDO |
| `helpers.php` | `init_db`, `load_recipes`, `save_recipes`, site settings |
| `data/recipes.json` | Seed + fallback + admin backup |
| `data/site.json` | Imprint/privacy settings |
| `helpers.php` | `init_db`, `load_recipes`, `save_recipe`, site settings |
| `scripts/seed-data.php` | Seed arrays for recipes and site settings |
| `docker-compose.dev.yml` | Local Postgres |
| `scripts/db-check.php` | Connection + seed smoke test |
| `partials/head.php` | Firebase init via `get_firebase_config()` |