|
| 1 | +# IPFS Integration - Implementation Summary |
| 2 | + |
| 3 | +This document summarizes the IPFS/IPNS integration implemented per the Real-Currents IPFS Integration plan. |
| 4 | + |
| 5 | +## What Was Implemented |
| 6 | + |
| 7 | +### Phase 2: Gandi Node.js Server (Security Guard + Gateway) |
| 8 | + |
| 9 | +- **`server.js`** – Custom HTTP server that: |
| 10 | + - Serves `/ipfs/<cid>/...` – Immutable IPFS gateway |
| 11 | + - Serves `/ipns/<name>/...` – Mutable IPNS gateway (with 5-min cache) |
| 12 | + - `POST /api/deploy` – CAR upload (authenticated via `x-api-key`) |
| 13 | + - `POST /api/ipns/publish` – IPNS publish (authenticated) |
| 14 | + - `GET /api/ipfs/current` – Returns current CID for IPNS key (for footer links) |
| 15 | + - Falls through to Next.js for all other routes |
| 16 | + |
| 17 | +- **Dependencies added**: `ipfs-http-client`, `mime-types` |
| 18 | + |
| 19 | +- **Scripts updated**: |
| 20 | + - `dev` – Uses custom server (with Quarto render) |
| 21 | + - `start` – Production server; `start:static` – Original static server |
| 22 | + |
| 23 | +### Phase 3: GitHub Actions |
| 24 | + |
| 25 | +- **`.github/workflows/deploy.yml`** – Runs on push to `main`: |
| 26 | + 1. Build (Quarto + Next.js) |
| 27 | + 2. Deploy to Gandi via Git |
| 28 | + 3. Package `out/` as CAR |
| 29 | + 4. Upload CAR to `/api/deploy` |
| 30 | + 5. Publish IPNS `xr-baseline-0` → new CID |
| 31 | + |
| 32 | +### Phase 4: Next.js Configuration |
| 33 | + |
| 34 | +- **`next.config.mjs`** – Added `trailingSlash: true`, `images.unoptimized: true` (static export already configured) |
| 35 | + |
| 36 | +### Phase 6: Content Integration |
| 37 | + |
| 38 | +- **`src/components/IpfsLinks.tsx`** – Client component that fetches current CID and shows: |
| 39 | + - Latest Version (IPNS) – `/ipns/xr-baseline-0` |
| 40 | + - Immutable Snapshot (IPFS) – `/ipfs/<cid>` when available |
| 41 | + |
| 42 | +- **`src/app/layout.tsx`** – Footer includes `IpfsLinks`, `metadataBase` for canonical URLs |
| 43 | + |
| 44 | +## Next Steps (Manual) |
| 45 | + |
| 46 | +### Phase 1: Worker Node Setup (VPS) |
| 47 | + |
| 48 | +1. Install Kubo (IPFS) on your VPS |
| 49 | +2. Create IPNS key: `ipfs key gen xr-baseline-0 --type=ed25519` |
| 50 | +3. Install and configure Caddy with Basic Auth |
| 51 | +4. Point `ipfs-api.real-currents.com` to the VPS |
| 52 | + |
| 53 | +### Configure Secrets |
| 54 | + |
| 55 | +**GitHub** (Settings → Secrets and variables → Actions): |
| 56 | + |
| 57 | +- `GANDI_GIT_URL` – Gandi Git remote URL |
| 58 | +- `DEPLOY_SECRET` – Strong random secret (same as Gandi env) |
| 59 | + |
| 60 | +**Gandi** (or `.env` for local): |
| 61 | + |
| 62 | +- `IPFS_NODE_HOST`, `IPFS_USER`, `IPFS_PASS` – Worker node credentials |
| 63 | +- `DEPLOY_SECRET` – Same as GitHub secret |
| 64 | + |
| 65 | +See `.env.example` for the full list. |
| 66 | + |
| 67 | +## URL Structure |
| 68 | + |
| 69 | +| Pattern | Handler | Purpose | |
| 70 | +|---------|---------|---------| |
| 71 | +| `/xr/baseline-0`, `/`, etc. | Next.js | Live site | |
| 72 | +| `/ipfs/<cid>/...` | IPFS Gateway | Immutable snapshot | |
| 73 | +| `/ipns/xr-baseline-0/...` | IPNS Gateway | Stable pointer to latest | |
| 74 | + |
| 75 | +## Testing Locally |
| 76 | + |
| 77 | +Without the Worker node, IPFS/IPNS routes return 503. To test: |
| 78 | + |
| 79 | +```bash |
| 80 | +# With env vars set (copy .env.example to .env) |
| 81 | +npm run dev |
| 82 | +# Then: curl http://localhost:3000/ipns/xr-baseline-0 |
| 83 | +``` |
| 84 | + |
| 85 | +With the Worker configured, the IPFS and IPNS gateways will work as expected. |
0 commit comments