Project Plan · v1 · Draft

Video Planner

AI-assisted planning for video content — generating prompts, SEO captions, and feeding DiffusionBear (images) and Phosphene (video).

Frontend: planner.hlmn.app Backend: api.planner.hlmn.app PostgreSQL (self-hosted) Text AI: DeepSeek Flash Images: DiffusionBear Video: Phosphene
1. Overview
2. Scope (v1)
3. Architecture
4. Tech Stack
5. Infrastructure & Domains
6. Authentication
7. Database Schema
8. Data Model & Hierarchy
9. AI Integration
10. Prompt Generation
11. API Design
12. Frontend Pages
13. Docs Serving (/docs)
14. Deployment
15. Security
16. Milestones
17. Assumptions & Open Questions

1. Overview

Video Planner is a single-section web application that helps a user plan video content with AI assistance. For now it contains one section — Video Planner — where the user can generate structured prompts and SEO-ready copy for a video project:

Videos are organized under Categories. A category carries a complete, user-written description of its theme/genre. When creating a project, the user selects a category and can ask the AI to explore the category and suggest a main scenario based on it.

User flow — planning one video

  1. Log in — Google OAuth, restricted to the allowlisted email.
  2. Manage categories — create a category and write its full description (a reusable bucket such as "historical shorts" or "product explainers").
  3. Create a project — set a title, a brief overview, and pick the category.
  4. Suggest / generate the main scenario — either request a category-based suggestion (AI explores the category description and proposes a scenario) or generate from explicit inputs; then edit and save.
  5. Generate characters — add characters and generate each character prompt.
  6. Generate scenes — add scenes (using the scenario + characters as context) and generate scene prompts; reorder as needed.
  7. Generate captions — for each selected social media platform, generate an SEO-optimized caption (hook, body, hashtags) tailored to that platform.
  8. Review & refine — edit any prompt or caption, refine/regenerate individual items, approve what's final.

Flow simulation

Animated preview of a project's end-to-end planning flow (looping).

Login

Google OAuth — allowlisted account only.

Category

Create a category with its full description and optional style guide.

Project

Title, overview, platforms, target duration, and language.

Main scenario

Suggest 3 from the category, or generate from explicit inputs.

Characters

Add characters and generate each character prompt.

Scenes

Generate ordered scene prompts using scenario + character context.

Captions

Generate one SEO-optimized caption per selected platform.

Review & approve

Refine, version, revert, and approve the final set.

Access is restricted to a single Google account ([email protected]) during this phase. AI generation is powered by DeepSeek Flash using a user-supplied API key.

2. Scope (v1)

In scope

Out of scope (deferred)

3. Architecture

Three primary components behind an Nginx reverse proxy, all on the same server:

Browser
   │
   ├── https://planner.hlmn.app  ──► Nginx ──► Frontend (static SPA)
   │                                    │
   │                                    └──► /docs ──► static HTML (this plan)
   │
   └── https://api.planner.hlmn.app ─► Nginx ──► Backend API (Node.js)
                                                     │
                                                     ├──► PostgreSQL (localhost)
                                                     └──► DeepSeek API (outbound HTTPS)

4. Tech Stack

LayerChoice (proposed)Notes
FrontendReact + Vite (TypeScript)SPA; static build served by Nginx. Routing with React Router.
BackendNode.js + Fastify (TypeScript)Lightweight, typed. Alternative: Express.
DatabasePostgreSQL 16Hosted on this server; accessed over localhost.
ORMPrisma (or Drizzle)Schema-first migrations.
AuthGoogle OAuth 2.0 (Authorization Code flow)Session via signed httpOnly cookie.
AIDeepSeek API (Flash)Key from environment; model id configurable.
Reverse proxyNginx + Let's Encrypt (TLS)Terminates TLS for both domains.
Process managerPM2 or systemdKeeps backend running; restart on crash.

5. Infrastructure & Domains

ItemValuePurpose
Frontend domainplanner.hlmn.appSPA + /docs static page.
Backend domainapi.planner.hlmn.appREST API.
PostgreSQLlocalhost:5432Not publicly exposed.
TLSLet's EncryptHTTPS on both domains.
DNS: both subdomains should resolve to this server's public IP. Nginx serves a virtual host for each subdomain; only ports 80/443 (and SSH) are exposed externally.

6. Authentication

Flow

  1. User visits planner.hlmn.app → not authenticated → redirected to api.planner.hlmn.app/auth/google.
  2. Backend redirects to Google consent screen (Authorization Code flow).
  3. Google redirects back to api.planner.hlmn.app/auth/google/callback?code=....
  4. Backend exchanges code for tokens, fetches profile (email + sub).
  5. Backend checks email against the allowlist.
  6. If allowed → create/find user, set session cookie, redirect to frontend.
  7. If denied → show a "Not authorized" page; do not create a session.

Allowlist

ALLOWED_EMAILS="[email protected]"

Comparison is case-insensitive and trimmed. The allowlist is a comma-separated environment variable so future accounts can be added without code changes.

Session

7. Database Schema

users
  id            uuid PK
  email         text UNIQUE NOT NULL
  name          text
  google_sub    text UNIQUE        -- Google account subject id
  avatar_url    text
  created_at    timestamptz NOT NULL DEFAULT now()
  updated_at    timestamptz NOT NULL DEFAULT now()

categories           -- user-defined grouping; also acts as a style template
  id            uuid PK
  user_id       uuid FK → users.id
  name          text NOT NULL
  description   text NOT NULL      -- complete description of the category (drives AI exploration)
  style_guide   text               -- visual/tonal guide applied to every generation in this category
  tone          text               -- default tone (e.g. 'dramatic', 'playful', 'documentary')
  default_template text            -- optional reusable prompt-structure template
  default_language text DEFAULT 'en'
  created_at    timestamptz NOT NULL DEFAULT now()
  updated_at    timestamptz NOT NULL DEFAULT now()

projects
  id            uuid PK
  user_id       uuid FK → users.id
  category_id   uuid FK → categories.id  -- selected at project creation
  title         text NOT NULL
  overview      text               -- high-level description / input context
  platforms     text[]             -- selected social media (one or more): 'youtube' | 'tiktok' | 'instagram' | 'shorts' | 'reels'
  aspect_ratio  text DEFAULT '16:9'-- '16:9' | '9:16' | '1:1'
  target_duration_sec integer      -- target total runtime
  language      text DEFAULT 'en'  -- output language (inherits category default)
  status        text DEFAULT 'draft'
  created_at    timestamptz NOT NULL DEFAULT now()
  updated_at    timestamptz NOT NULL DEFAULT now()

scenarios            -- main scenario (one per project); current/approved version
  id            uuid PK
  project_id    uuid FK → projects.id  UNIQUE
  input         jsonb              -- user inputs used for generation
  prompt        text               -- current main-scenario prompt
  status        text DEFAULT 'draft'  -- 'draft' | 'approved'
  model         text               -- model id used
  created_at    timestamptz NOT NULL DEFAULT now()
  updated_at    timestamptz NOT NULL DEFAULT now()

scenario_suggestions -- AI candidates from a category-based suggest request
  id            uuid PK
  project_id    uuid FK → projects.id
  content       text               -- candidate scenario (logline + pitch)
  status        text DEFAULT 'draft'  -- 'draft' | 'accepted' | 'rejected'
  created_at    timestamptz NOT NULL DEFAULT now()
  updated_at    timestamptz NOT NULL DEFAULT now()

characters
  id            uuid PK
  project_id    uuid FK → projects.id
  name          text
  input         jsonb              -- user inputs (role, traits, etc.)
  prompt        text               -- current character prompt
  status        text DEFAULT 'draft'  -- 'draft' | 'approved'
  model         text
  created_at    timestamptz NOT NULL DEFAULT now()
  updated_at    timestamptz NOT NULL DEFAULT now()

scenes
  id            uuid PK
  project_id    uuid FK → projects.id
  scenario_id   uuid FK → scenarios.id  -- optional link
  title         text
  order_index   integer NOT NULL DEFAULT 0
  duration_sec  integer            -- planned scene length
  input         jsonb
  prompt        text               -- current scene prompt
  status        text DEFAULT 'draft'  -- 'draft' | 'approved'
  model         text
  created_at    timestamptz NOT NULL DEFAULT now()
  updated_at    timestamptz NOT NULL DEFAULT now()

captions             -- one SEO caption per selected platform
  id            uuid PK
  project_id    uuid FK → projects.id
  platform      text NOT NULL      -- 'youtube' | 'tiktok' | 'instagram' | 'shorts' | 'reels'
  content       text               -- SEO-optimized caption (hook + body + CTA)
  hashtags      text[]             -- suggested hashtags
  keywords      text[]             -- SEO keywords used
  status        text DEFAULT 'draft'  -- 'draft' | 'approved'
  model         text
  created_at    timestamptz NOT NULL DEFAULT now()
  updated_at    timestamptz NOT NULL DEFAULT now()
  UNIQUE (project_id, platform)

prompt_versions      -- full history for every artifact (refine / revert)
  id            uuid PK
  project_id    uuid FK → projects.id
  artifact_type text               -- 'scenario' | 'character' | 'scene' | 'caption'
  artifact_id   uuid               -- id of the artifact row
  version_no    integer NOT NULL
  content       text NOT NULL
  instruction   text               -- refine instruction that produced this version (null = initial)
  model         text
  created_at    timestamptz NOT NULL DEFAULT now()

generation_logs      -- optional audit/history of AI calls
  id            uuid PK
  project_id    uuid FK → projects.id
  user_id       uuid FK → users.id
  type          text               -- 'scenario' | 'scenario_suggestion' | 'character' | 'scene'
  model         text
  prompt_tokens integer
  completion_tokens integer
  created_at    timestamptz NOT NULL DEFAULT now()

8. Data Model & Hierarchy

User
 ├── Category (0..N)         -- user-defined; carries a full description
 │
 └── Project (video project)
      ├── Category (selected) -- chosen at project creation
      ├── Scenario  (main scenario, 1 per project)
      ├── Character (0..N)
      ├── Scene     (0..N, ordered, optionally linked to the scenario)
      └── Caption   (0..N, one per selected platform)

A Category holds a complete description of a video theme/genre and is reusable across projects; it also carries the style template (style guide, tone, default template, default language). A Project is the top-level container and references one category at creation, plus the platform/aspect/duration/language targets; the main scenario can be suggested from that category. Generating a scene can reference the project's scenario and selected characters as context, so scene prompts stay consistent with the story. Captions are generated per selected platform with platform-specific SEO rules. Every artifact (including each platform caption) keeps a full version history (prompt_versions) so it can be refined and reverted.

9. AI Integration

DEEPSEEK_API_KEY="sk-..."
DEEPSEEK_BASE_URL="https://api.deepseek.com"   # default
DEEPSEEK_MODEL="deepseek-flash"                # confirm exact id
The key must never be sent to the frontend. The backend is the only component that talks to DeepSeek.

10. Prompt Generation

Each artifact type uses a dedicated system prompt (template) plus the user's inputs. The templates live server-side so they can be tuned without a frontend deploy.

10.1 Main scenario

Inputs: topic/theme, genre, audience, tone, duration, any reference notes.

Output: a structured scenario prompt (logline, setting, conflict, acts/beats).

10.2 Category-based scenario suggestion

Inputs: the project's selected category (full description) + the project overview. Each request returns 3 candidate scenarios by default.

The AI explores the category description (themes, audience, conventions, angles) and proposes one or more main-scenario directions. The user picks a suggestion, then refines and saves it as the project's main scenario. This is a separate action from the manual "Generate" in 10.1.

Output: candidate scenario(s) (logline + short pitch); the accepted one becomes the project scenario.

10.3 Character

Inputs: name, role, appearance, personality, motivation, relation to story.

Output: a character prompt (identity, visual description, personality, arc).

10.4 Scenes

Inputs: title, location, action summary, characters involved, mood; plus optional scenario context.

Output: a scene prompt (setting, action, dialogue direction, camera/visual style).

10.5 Captions (SEO per platform)

Inputs: the project's scenario + character/scene context, the category style, the output language, and the selected platform.

One caption is generated per selected platform, structured as hook → body → call-to-action → hashtags and optimized for search/discovery on that platform:

Output: caption text + extracted keywords + hashtags, stored per platform; editable, versioned, and approvable like other artifacts.

10.6 Iterative refinement & versioning

Every generation, edit, or refinement writes a new row to prompt_versions; the artifact keeps the current content while the full history is retained.

10.7 Generation context

Every generation is enriched with project/category context so output stays consistent:

Generation is deterministic by request: the user clicks "Generate", the backend calls DeepSeek with the template + inputs, returns the result, and saves it. Nothing is generated unsolicited.

11. API Design

Base URL: https://api.planner.hlmn.app. All routes except auth require a valid session.

MethodPathDescription
GET/auth/googleStart Google OAuth.
GET/auth/google/callbackOAuth callback + allowlist check.
GET/auth/meCurrent user.
POST/auth/logoutDestroy session.
GET/api/categoriesList categories.
POST/api/categoriesCreate category (name, description, style guide, tone, template, language).
PATCH/api/categories/:idUpdate category.
DELETE/api/categories/:idDelete category.
GET/api/projectsList user's projects.
POST/api/projectsCreate project (category, platform, aspect ratio, target duration, language).
GET/api/projects/:idGet project + artifacts.
PATCH/api/projects/:idUpdate project.
DELETE/api/projects/:idDelete project (cascades).
GET/api/projects/:id/scenarioGet main scenario.
POST/api/projects/:id/scenario/generateGenerate/regenerate scenario from explicit inputs.
POST/api/projects/:id/scenario/suggestAI explores the category and returns draft suggestion(s).
GET/api/projects/:id/scenario/suggestionsList scenario suggestions + status.
POST/api/projects/:id/scenario/suggestions/:sid/acceptAccept a suggestion as the project scenario.
POST/api/projects/:id/scenario/refineRefine scenario with an instruction (new version).
GET/api/projects/:id/scenario/versionsList scenario versions.
POST/api/projects/:id/scenario/versions/:vid/revertRevert scenario to a version.
POST/api/projects/:id/scenario/approveMark scenario approved.
PATCH/api/projects/:id/scenarioSave a manual edit (recorded as a new version).
GET/api/projects/:id/charactersList characters.
POST/api/projects/:id/charactersCreate character.
POST/api/projects/:id/characters/:cid/generateGenerate character prompt.
POST/api/projects/:id/characters/:cid/refineRefine the character prompt (new version).
GET/api/projects/:id/characters/:cid/versionsList character prompt versions.
POST/api/projects/:id/characters/:cid/approveMark character approved.
PATCH/api/projects/:id/characters/:cidSave a manual edit (recorded as a new version).
GET/api/projects/:id/scenesList scenes (ordered).
POST/api/projects/:id/scenesCreate scene.
POST/api/projects/:id/scenes/:sid/generateGenerate scene prompt.
POST/api/projects/:id/scenes/:sid/refineRefine the scene prompt (new version).
GET/api/projects/:id/scenes/:sid/versionsList scene prompt versions.
POST/api/projects/:id/scenes/:sid/approveMark scene approved.
PATCH/api/projects/:id/scenes/:sidSave a manual edit (recorded as a new version).
PATCH/api/projects/:id/scenes/reorderReorder scenes.
GET/api/projects/:id/captionsList captions (one per selected platform).
POST/api/projects/:id/captions/generateGenerate SEO captions for the selected platform(s).
POST/api/projects/:id/captions/:platform/refineRefine a platform caption (new version).
GET/api/projects/:id/captions/:platform/versionsList caption versions.
POST/api/projects/:id/captions/:platform/approveMark caption approved.
PATCH/api/projects/:id/captions/:platformSave a manual caption edit (new version).

12. Frontend Pages

RouteContent
/loginSign in with Google button (or auto-redirect).
/Dashboard: list of projects, "New project" action.
/categoriesManage categories: name, description, style guide, tone, default template, default language.
/projects/:idEditor with tabs: Scenario (inputs, "Suggest from category" → 3 drafts, accept/reject, refine, manual edit), Characters, Scenes, Captions (one SEO caption per selected platform). Shared header: platforms (multi-select, auto-fills aspect ratio + typical duration) / target duration / language; per-artifact version history and approve toggle; non-blocking duration warning when scene durations don't sum to the target.
/docsThis plan document (static HTML).
/unauthorizedShown when login email is not allowlisted.

13. Docs Serving (/docs)

This plan document is a static HTML file. Nginx serves it at planner.hlmn.app/docs (directory index or a dedicated location /docs block), independent of the SPA so it loads even when the app is not authenticated.

location /docs {
  alias /var/www/video-planner/docs;
  index index.html;
}

14. Deployment

  1. Provision PostgreSQL on this server; create app database and user.
  2. Configure Nginx virtual hosts + TLS for both subdomains.
  3. Deploy backend (build → run via PM2/systemd).
  4. Deploy frontend (build → static files served by Nginx).
  5. Create Google OAuth client (consent screen) with redirect URI https://api.planner.hlmn.app/auth/google/callback.
  6. Set environment variables (see below).
  7. Run DB migrations; smoke-test login + generation.
# Backend environment
DATABASE_URL="postgresql://app:...@localhost:5432/video_planner"
GOOGLE_CLIENT_ID="..."
GOOGLE_CLIENT_SECRET="..."
GOOGLE_REDIRECT_URI="https://api.planner.hlmn.app/auth/google/callback"
ALLOWED_EMAILS="[email protected]"
DEEPSEEK_API_KEY="sk-..."
DEEPSEEK_MODEL="deepseek-flash"
SESSION_SECRET="..."
FRONTEND_URL="https://planner.hlmn.app"

15. Security

16. Milestones

#MilestoneDeliverable
1InfrastructureDomains, Nginx, TLS, PostgreSQL running.
2AuthenticationGoogle OAuth + allowlist working.
3Data layerSchema migrated; CRUD for categories, projects, and artifacts.
4AI integrationDeepSeek generation + refinement/versioning for scenario (incl. category suggestion), character, scene, and per-platform SEO captions.
5FrontendVideo Planner UI (dashboard + editor, version history, approve flow, style template, platform/duration, captions).
6DocsThis page live at planner.hlmn.app/docs.
7HardeningError handling, logging, basic tests.

17. Assumptions & Open Questions

Assumptions

Feature decisions (defaults adopted)

Technical decisions (out of this feature discussion)