How m-damien/directgpt works
Project type and purpose
• This is a client-side, single-page application (SPA) built with React and TypeScript.
• Its purpose is to provide a direct-manipulation UI on top of the OpenAI ChatGPT API, featuring reusable prompt tooling, manipulable outputs, and a built-in study runner with tutorial videos.
High-level architecture and key directories
• public/ → static assets (index.html, robots.txt, tutorial videos)
• src/
• model/ → data structures and prompt generators (Element, Model, ChatPrompt, CodePrompt, etc.)
• view/ → React UI components and interfaces (Launcher, ChatInterface, DirectInterface, StudyInterface, plus reusable widgets and entity renderers)
• package.json & tsconfig.json → build tooling and compile configuration
• .github/workflows → CI/CD pipeline (deploy.yml)
Main components
A. Browser/Client (React SPA)
1. Launcher
• Entry point where user enters API key and chooses mode
2. Interfaces
• ChatInterface & DirectInterface for interactive prompting
• StudyInterface for guided tasks with embedded videos
3. Shared UI Components
• PromptBuilder, PromptHistory, ReusablePromptButton, Drag’n’Drop, CustomCursor, OverlappingMarkup
4. Entity Renderers
• CodeEntity, SVGEntity, TextualEntity, UnknownEntity
B. Model Layer (in-app data & prompt generation)
• Model.tsx & Element.tsx hold the in-memory representation of outputs
• prompts/*.tsx generate structured prompt payloads for various content types
C. External Services
• OpenAI Chat API (HTTPS calls from the client)
D. Static Asset Server
• public/index.html serves the SPA shell
• public/study/tuto/*.mp4 tutorial videos loaded during study mode
E. Deployment Pipeline
• GitHub Actions (deploy.yml) builds and publishes the site (e.g., to GitHub Pages or another host)
Relationships and data flows
• User action in a View component → calls a Model prompt generator → sends JSON payload via fetch/XHR to OpenAI API → receives response → Model updates its Element tree → View re-renders Entities.
• Study mode fetches static videos from the asset server and sequences tasks via StudyTaskGenerator.
• Launcher stores API key in memory (never persisted) and passes it into every API request.
Architectural patterns and design principles
• Component-based UI (React) separating view logic (src/view) from data/prompt logic (src/model)
• MVC-style separation:
• Model layer for state & prompt assembly
• View layer for rendering & interaction
• Reusability and extensibility via a toolbar of prompt templates and entity components
• Single source of truth: central Model.tsx representing the current generative output