Project Plan · v1 · Draft

Video Planner

AI-assisted planning for video content — generating prompts for the main scenario, characters, and scenes.

Frontend: planner.hlmn.app Backend: api.planner.hlmn.app PostgreSQL (self-hosted) AI: DeepSeek Flash
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 for three artifacts of a video project:

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()

projects
  id            uuid PK
  user_id       uuid FK → users.id
  title         text NOT NULL
  overview      text               -- high-level description / input context
  status        text DEFAULT 'draft'
  created_at    timestamptz NOT NULL DEFAULT now()
  updated_at    timestamptz NOT NULL DEFAULT now()

scenarios            -- main scenario (one per project)
  id            uuid PK
  project_id    uuid FK → projects.id  UNIQUE
  input         jsonb              -- user inputs used for generation
  prompt        text               -- generated main-scenario prompt
  model         text               -- model id used
  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               -- generated character prompt
  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
  input         jsonb
  prompt        text               -- generated scene prompt
  model         text
  created_at    timestamptz NOT NULL DEFAULT now()
  updated_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' | 'character' | 'scene'
  model         text
  prompt_tokens integer
  completion_tokens integer
  created_at    timestamptz NOT NULL DEFAULT now()

8. Data Model & Hierarchy

User
 └── Project (video project)
      ├── Scenario  (main scenario, 1 per project)
      ├── Character (0..N)
      └── Scene     (0..N, ordered, optionally linked to the scenario)

A Project is the top-level container. Generating a scene can reference the project's scenario and selected characters as context, so scene prompts stay consistent with the story.

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 Character

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

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

10.3 Scenes

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

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

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/projectsList user's projects.
POST/api/projectsCreate project.
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.
GET/api/projects/:id/charactersList characters.
POST/api/projects/:id/charactersCreate character.
POST/api/projects/:id/characters/:cid/generateGenerate character prompt.
GET/api/projects/:id/scenesList scenes (ordered).
POST/api/projects/:id/scenesCreate scene.
POST/api/projects/:id/scenes/:sid/generateGenerate scene prompt.

12. Frontend Pages

RouteContent
/loginSign in with Google button (or auto-redirect).
/Dashboard: list of projects, "New project" action.
/projects/:idEditor with tabs: Scenario, Characters, Scenes.
/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 projects/artifacts.
4AI integrationDeepSeek generation for scenario/character/scene.
5FrontendVideo Planner UI (dashboard + editor).
6DocsThis page live at planner.hlmn.app/docs.
7HardeningError handling, logging, basic tests.

17. Assumptions & Open Questions

Assumptions

Open questions