Files
worldwideview/ROADMAP.md
Silvertakana c4207bd6e1 feat(core): migrate to Prisma 7 and unify PostgreSQL architecture (#56)
* feat(cloud): implement Postgres DB adapter, fix static build crashes, and containerize NextAuth/Stripe integrations

* test(marketplace): fix mocks and assertions for multi-tenant Postgres architecture

* feat: rsa jwt license key verification and state integration

* feat: add internal workspace validation route for Edge Functions

* refactor: clean up hub routes and finalize db proxy/adapter for multi-tenant cloud deploy

* feat(cloud): finalize multi-tenant Prisma extensions and workspace routing

* fix(db): correct Prisma 7 better-sqlite3 adapter initialization [Patch]

- update better-sqlite3 adapter instantiation to use configuration object ({ url }) required by Prisma 7 instead of raw Database instance [Patch]
- fix PrismaClientConstructorValidationError by generating client with adapter support [Patch]

* fix(auth): support dynamic origins for local proxies and multi-tenant subdomains [Patch]

- prioritize forwarded headers and request host over hardcoded envOrigin in getRequestOrigin to support subdomain routing [Patch]
- allow ALLOWED_DEV_ORIGIN in marketplace install redirect checks to fix local network development login flows [Patch]

* fix(marketplace): enable dynamic CORS reflection for marketplace API [Patch]

- remove explicit origin array, replacing with origin header reflection to allow marketplace hosted on any domain or local IP [Patch]

- remove global wildcard CORS headers from next.config.ts to harden security against broader app injection [Patch]

* feat(db): create initial postgresql migration

* refactor(db): update remaining files for postgresql

* feat(db): unify database adapter to PostgreSQL-only [Minor]

- replace SQLite adapter with PostgreSQL PrismaPg [Minor]
- remove better-sqlite3 dependencies [Patch]
- finalize docs and implementation plan [Patch]

* fix: resolve prisma client generation and script execution issues with tsx and type module

* feat(db): port tenant isolation logic to new PostgreSQL adapter

* docs: add rule for transparent and narrated agent actions

* BREAKING CHANGE(core): migrate to PostgreSQL and add auto-migration pipeline [Major]

- unified database adapter to exclusively use PostgreSQL [Major]
- implement auto-migration pipeline to pipe legacy SQLite data to Postgres [Major]
- add sqlite to runner stage to support extraction pipeline [Patch]

* feat(core): migrate to Prisma 7 and unify PostgreSQL architecture [Minor]

- removed legacy Prisma SQLite driver and all Better-Sqlite dependencies [Minor]
- updated schema to utilize purely postgresql providers [Patch]
- modified migration scripts to seamlessly convert local sqlite DBs to PostgreSQL containers using keinos/sqlite3 [Minor]
- updated deployment scripts, Coolify pipelines, and Nginx proxy support [Patch]
- injected Prisma Client Extensions for multi-tenant Row Level Security isolation [Minor]
- stabilized PrismaClient initialization utilizing the official adapter-pg runtime pattern [Patch]
- bumped version to 2.1.0

* fix(core): resolve TypeScript compilation errors for CI [Patch]

- fixed NextResponse.json() 3-arg calls to use 2-arg ResponseInit form [Patch]
- replaced invalid 'developer' TrustTier with 'unverified' in parseWwvManifest and load-unpacked route [Patch]
- removed non-existent pluginManager.hotReload() call in DevModeSubscriber, replaced with disable/reload cycle [Patch]
- updated Stripe API version from '2024-04-10' to '2026-04-22.dahlia' to match installed SDK [Patch]
- excluded local-scripts/ from tsconfig to prevent debug scripts from breaking CI [Patch]

* fix(ci): resolve pnpm version conflict in GitHub Actions [Patch]

- removed explicit version: 9 from pnpm/action-setup@v4 — v4 auto-reads packageManager from package.json [Patch]
- updated build job DATABASE_URL from SQLite to PostgreSQL format [Patch]

* fix(docker): add explicit Prisma generator output path for Docker builds [Patch]

- Prisma 7 changed default output location, causing COPY --from=builder to fail
- added output = '../src/generated/prisma' to generator block for consistency

* fix(prisma): update client import path and resolve CI type errors [Patch]

- updated PrismaClient import in db.ts to point to custom generated output path
- resolved implicit 'any' error in marketplace check-updates route
- verified clean local build with tsc --noEmit

* chore(deps): sync Prisma versions to 7.6.0 [Patch]
2026-05-09 22:44:30 +12:00

162 lines
7.9 KiB
Markdown

# WorldWideView — Implementation Roadmap
Each stage is **self-contained and demo-able**. Any stage can be shipped independently.
---
## Stage 1: Plugin SDK & Manifest Schema ✅
**Demo:** "Here's the schema that defines a plugin. Our existing aviation plugin has a manifest file."
- [x] `plugin.json` manifest files for each existing plugin
- [x] Manifest validation logic (`validateManifest()`)
- [x] `type` field on `WorldPlugin` interface (`"data-layer" | "extension"`)
- [x] `capabilities` field on `WorldPlugin` interface
- [x] `@worldwideview/wwv-plugin-sdk` npm package — shared types published to npm
---
## Stage 2: Marketplace Browse UI (Static Catalog) ✅
**Demo:** "Open the marketplace, see all available plugins with categories and search."
- [x] `worldwideview-marketplace` repo (Next.js)
- [x] Browse page — grid of plugin cards with icons, descriptions, categories
- [x] Search + category filter
- [x] Plugin detail page (readme, version history, install count)
---
## Stage 3: Prisma ORM & Local Database ✅
**Demo:** "Run `pnpm run dev` on a fresh clone with a valid DATABASE_URL. App works seamlessly."
- [x] Prisma (`prisma` + `@prisma/client`)
- [x] Schema: `InstalledPlugin`, `Setting`, `User`, `AviationHistory`, `NpmCache`
- [x] PostgreSQL default: `DATABASE_URL` required
- [x] `predev` script: `prisma migrate deploy`
- [x] DB auto-creates on first run — zero manual setup
---
## Stage 4: Bridge API & One-Click Install ✅
**Demo:** "Click 'Install' on marketplace → plugin appears in your local WWV instance."
- [x] `GET /api/marketplace/install-redirect` — session-based redirect install flow
- [x] `GET /api/marketplace/grant-token` — issues marketplace JWT without install
- [x] `GET /api/marketplace/status` — list installed plugins (session or JWT auth)
- [x] `POST /api/marketplace/uninstall` — delete installed plugin record
- [x] `GET /api/marketplace/load` — serve valid manifests to client at startup
- [x] `GET /api/auth/setup-status` — CORS-enabled connection test endpoint
- [x] `src/lib/marketplace/marketplaceToken.ts` — `issueMarketplaceToken()` / `verifyMarketplaceToken()`
- [x] `src/lib/marketplace/auth.ts` — `validateMarketplaceAuth()` (session → JWT → legacy token)
- [x] `src/lib/marketplace/registryClient.ts` — Ed25519 registry verification + 5-min cache
- [x] Marketplace: `InstanceConfig`, `InstallButton`, `useInstalledPlugins`, `InstalledPluginCard`, Manage page
- [x] NPM-driven submission: Admin enters package name → marketplace fetches + parses `"worldwideview"` block from `package.json`
- [x] `NpmCache` table — decouples marketplace from live NPM registry
---
## Stage 5: AI & Sharing Features (Immediate User Value)
**Demo:** "Chat with the AI to explore the globe, record a narrated briefing, and share the view via a URL."
- [ ] Unified Data Format schema (WWVDocument) with snapshot radius bounding
- [ ] Base64url view link sharing (`#v=...`)
- [ ] Shared `ActionExecutor` core for Animation & Copilot
- [ ] Animation Engine (TrackScheduler, Player, overlays, TTS voice)
- [ ] MCP Server (tools wrapping the action vocabulary)
- [ ] Hybrid Spatial Awareness (Pre-computed summaries + MCP spatial query tools)
---
## Stage 6: Publisher Workflow
**Demo:** "A plugin author submits their plugin. After review, it appears in the catalog."
- [ ] Marketplace user accounts (Supabase Auth — email/password + GitHub OAuth)
- [ ] Publisher submission form (upload bundle, fill metadata, declare capabilities)
- [ ] Admin review queue (approve/reject with notes)
- [ ] Version management (semver, changelogs)
- [ ] Publisher dashboard (install counts, download analytics)
- [ ] Publisher namespaces (`publisher.plugin-name`)
---
## Stage 7: Cloud Platform & Accounts
**Demo:** "User registers, gets [user].app.worldwideview.dev, installs plugins from marketplace."
- [ ] `app.worldwideview.dev` — auth/register/dashboard
- [ ] Auto-provisioning on signup (tenant DB row → instance live immediately)
- [ ] RLS tenant isolation in PostgreSQL
- [ ] Cloud edition adapters (`auth.ts`, `storage.ts`, `tenant.ts`)
- [ ] Runtime settings store + setup wizard
- [ ] License key validation with RSA public key
- [ ] Tier gating (free/pro/enterprise feature flags)
- [ ] Cloudflare Turnstile + nginx rate limiting for bot prevention
- [ ] SSO: marketplace redirects to `app.worldwideview.dev` for login
---
## Stage 8: Built-In Data Services
**Demo:** "Aviation and maritime data with full history, served from api.worldwideview.dev."
- [ ] `api.worldwideview.dev` — aviation/maritime polling + persistence
- [ ] Redesign aviation as declarative plugin pointing to `api.worldwideview.dev`
- [ ] Redesign maritime the same way
- [ ] History/timeline with `%t` parameter substitution
- [ ] Snapshot capture (pro tier — counts toward storage quota)
- [ ] API key proxy with per-tenant-per-plugin rate limiting and response caching
---
## Stage 9: Trust Tiers, Extensions & Polish
**Demo:** "Install a verified extension plugin that adds cockpit view to aviation."
- [x] Ed25519-signed plugin registry (`GET /api/registry` on marketplace)
- [x] Server-side trust stamping at install time
- [x] Trust tier badges (`TrustBadge` component — Official / Verified / Unverified)
- [x] Unverified plugin warning dialog (`UnverifiedPluginDialog` + `useMarketplaceSync`)
- [ ] Extension plugin type support in `PluginManager`
- [ ] Activation events and contribution points
- [ ] Capability enforcement at runtime (`PluginPermissionError`)
- [ ] Web Worker sandboxing for unverified plugins (`comlink`)
- [ ] Reviews & ratings system
- [ ] Extension packs (bundles of related plugins)
- [ ] Auto-update mechanism (local: manual opt-in; cloud: automatic CDN swap)
- [ ] Plausible/Umami self-hosted analytics
---
## Stage 10: Infrastructure & Monetization
**Demo:** "Buy Pro, paste license key, unlock snapshot history and higher rate limits."
- [ ] Coolify on ThinkPad T480s — deploy all services
- [ ] Uptime Kuma monitoring (all subdomains)
- [ ] Stripe Checkout for license purchase
- [ ] Storage quota enforcement (cloud only)
- [ ] Stripe Connect for marketplace revenue split on paid plugins
- [ ] Cloudflare R2 as CDN for plugin bundles (`cdn.worldwideview.dev`)
---
## Resolved Architectural Decisions
| Decision | Resolution |
|---|---|
| **License** | EL2.0 for WorldWideView core; Open Source for marketplace |
| **Shared types** | `@worldwideview/plugin-sdk` npm package (MIT) |
| **Hosting** | Coolify (ThinkPad T480s). Landing page on Vercel (static export) |
| **Database** | PostgreSQL, Prisma ORM |
| **Tenant isolation** | Row-Level Security (RLS) in shared PostgreSQL |
| **User settings** | Runtime settings store in DB, not `.env` |
| **Bot prevention** | Email verification + Cloudflare Turnstile + rate limiting |
| **Plugin execution** | Client-side (browser), not server-side |
| **Plugin architecture** | VS Code model — activation events, contribution points, namespaces |
| **Server-side compute** | Not supported — third-party backends handle compute |
| **Auth** | Auth.js on `app.worldwideview.dev`. `Credentials` (local), `@auth/supabase-adapter` (cloud). Marketplace uses SSO redirect |
| **Instance provisioning** | Auto-provision on signup — just a DB row insert |
| **API proxy** | `apikey` plugins routed through cached proxy, per-tenant-per-plugin rate limits |
| **History** | Third-party `historyUrl` with `%t` (all tiers), WWV snapshot capture (pro only) |
| **Built-in data** | Aviation/maritime → declarative plugins → `api.worldwideview.dev` |
| **CI/CD** | GitHub Actions → GHCR → Coolify webhook |
| **Plugin trust registry** | Ed25519-signed JSON, public key hardcoded in WWV, trust stamped server-side at install |
| **Package manager** | pnpm workspaces (migrated from npm) |
| **NPM submission flow** | Admin enters package name → marketplace infers manifest from `"worldwideview"` block in `package.json` |
| **NPM caching** | `NpmCache` table decouples marketplace from live NPM registry |