Spaces:
Sleeping
Implementation Plan: ChatGPT App Integration
Branch: 003-chatgpt-app-integration | Date: 2025-11-26 | Spec: spec.md
Input: Feature specification from /specs/003-chatgpt-app-integration/spec.md
Note: This template is filled in by the /speckit.plan command. See .specify/templates/commands/plan.md for the execution workflow.
Summary
Adapt the backend to support ChatGPT Apps SDK by adding a static service token auth strategy, configuring CORS for ChatGPT, and updating MCP tools to return metadata for widget rendering. Create a standalone widget.html entry point in the frontend.
Technical Context
Language/Version: Python 3.11+, TypeScript/React 18
Primary Dependencies: fastmcp, fastapi, vite
Storage: No schema changes; relies on existing vault.
Testing: pytest for auth/tools; manual verification for widgets.
Target Platform: Hugging Face Spaces (Docker) + ChatGPT UI.
Project Type: Full Stack (Backend API + Frontend Widget).
Performance Goals: Widget load < 500ms.
Constraints: Must work alongside existing "local dev" and "HF OAuth" modes.
Scale/Scope: Demo scale (single tenant impersonation via service token).
Constitution Check
GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.
- Brownfield Integration: Respects existing auth structure (adding a strategy, not rewriting). Reuses
NoteViewercomponent. - Test-Backed: New auth strategy will be unit tested.
- Simplicity: Using static token instead of full OIDC.
Project Structure
Documentation (this feature)
specs/003-chatgpt-app-integration/
βββ plan.md # This file
βββ research.md # Phase 0 output
βββ data-model.md # Phase 1 output
βββ quickstart.md # Phase 1 output
βββ tasks.md # Phase 2 output
Source Code (repository root)
backend/
βββ src/
β βββ api/
β β βββ main.py # Update: CORS, widget route
β β βββ middleware/
β β βββ auth_middleware.py # Update: Strategy usage
β βββ services/
β β βββ auth.py # Update: Refactor to Strategy pattern
β β βββ config.py # Update: New config fields
β βββ mcp/
β βββ server.py # Update: Tool return types
βββ tests/
βββ unit/
βββ test_auth_strategy.py # New test
frontend/
βββ vite.config.ts # Update: Multi-page build
βββ widget.html # New: Widget entry point
βββ src/
βββ widget.tsx # New: Widget root component
Structure Decision: Multi-page build for Frontend; Strategy pattern for Backend Auth.
Complexity Tracking
| Violation | Why Needed | Simpler Alternative Rejected Because |
|---|---|---|
| Multi-page Vite | To isolate widget styles/scripts from main app | Iframing the full app is too heavy and leaky for ChatGPT widgets. |