Self-hosted short video messaging
parco-molo docs IMPLEMENTATION_PLAN.md
20 kB · 646 lines
Markdown
at dev

Implementation Plan #

This document breaks down the MVP implementation into small, incremental tasks. Each task should be independently reviewable and testable.

Review Process #

After completing each task:

  1. Claude implements the feature
  2. Run tests (if applicable)
  3. Manually verify the feature works
  4. You commit the changes (not Claude)
  5. Claude confirms you made the commit before proceeding
  6. Move to next task

Important: You are responsible for making all git commits. Claude will remind you to commit after each task and verify the commit was made before continuing to the next task.

Phase 1: Project Setup & Foundation #

Project Structure Note #

Backend (Rust) and frontend (TypeScript with Deno) coexist at repo root:

  • Root level: Cargo.toml, deno.json, configs
  • src/ - Rust backend source code
  • client/ - TypeScript frontend source code

This allows managing both from repo root without cd'ing between directories.

Tooling:

  • Backend: cargo run, cargo test, etc.
  • Frontend: deno task dev, deno task build, deno task lint, deno fmt

Task 1.1: Backend Project Initialization #

Goal: Create basic Rust project structure at repo root

Steps:

    • axum
    • tokio (with "full" feature)
    • tower
    • serde (with "derive")
    • serde_json

Deliverable: Basic Rust server that responds to health check


Task 1.2: Frontend Project Initialization #

Goal: Create basic TypeScript project structure at repo root using Deno

Steps:

    • Tasks for dev, build, lint, format
    • Import map for dependencies
    • TypeScript compiler options
    • Vite (via npm: for dev server and bundling)
    • Biome (for linting and formatting)

Deliverable: Basic TypeScript project using Deno that builds and runs, managed from repo root

Note: Using Vite instead of rsbuild as it has better Deno integration. Deno's native TypeScript support eliminates need for separate TypeScript compiler.


Task 1.3: Environment Configuration #

Goal: Set up environment variables and configuration with excellent error messages

Steps:

    • database_path: String
    • storage_path: String
    • bind_address: String
    • jwt_secret: String
    • Variable name
    • Why it's needed
    • Example value
    • Where to set it (systemd, shell, docker, etc.)

Deliverable: Configuration system with rock-solid error messages, no .env auto-loading

Note: Environment variables must be explicitly set by the deployer. This ensures clarity about configuration and avoids hidden .env files in production.


Task 1.4: Structured Logging Setup #

Goal: Add tracing/logging infrastructure

Steps:

Deliverable: Structured logging throughout application


Phase 2: Database & User Management #

Task 2.1: SQLite Database Setup #

Goal: Initialize database with sqlx

Steps:

    • id TEXT PRIMARY KEY (UUID as string)
    • email TEXT UNIQUE NOT NULL
    • password_hash TEXT NOT NULL
    • display_name TEXT NOT NULL
    • created_at TEXT NOT NULL (ISO8601 timestamp)

Deliverable: Database with users table and migration system


Task 2.2: User Model & Repository #

Goal: Create user data structures and database access

Steps:

    • create_user(pool, email, password_hash, display_name) -> Result<User>
    • find_user_by_email(pool, email) -> Result<Option<User>>
    • find_user_by_id(pool, id) -> Result<Option<User>>

Deliverable: User model with database operations


Task 2.3: Password Hashing #

Goal: Secure password storage with argon2

Steps:

Deliverable: Secure password hashing and verification


Task 2.4: JWT Token Generation #

Goal: Create and validate JWT tokens

Steps:

Deliverable: JWT token system with access and refresh tokens


Task 2.5: Registration Endpoint #

Goal: POST /api/auth/register endpoint

Steps:

    • Validate input
    • Check if email already exists
    • Hash password
    • Create user in database
    • Generate tokens
    • Return tokens + user info

Deliverable: Working registration endpoint


Task 2.6: Login Endpoint #

Goal: POST /api/auth/login endpoint

Steps:

    • Find user by email
    • Verify password
    • Generate tokens
    • Return tokens + user info

Deliverable: Working login endpoint


Task 2.7: Auth Middleware #

Goal: Protect routes with JWT validation

Steps:

    • Extracts token from Authorization header
    • Validates token
    • Adds user_id to request extensions

Deliverable: JWT authentication middleware


Phase 3: Frontend Authentication #

Task 3.1: TypeScript API Client Foundation #

Goal: Create type-safe API client

Steps:

    • User interface
    • LoginRequest interface
    • RegisterRequest interface
    • AuthResponse interface (tokens + user)
    • register(email, password, displayName)
    • login(email, password)

Deliverable: Type-safe API client


Task 3.2: Token Storage #

Goal: Store and manage JWT tokens

Steps:

    • saveTokens(accessToken, refreshToken)
    • getAccessToken()
    • getRefreshToken()
    • clearTokens()

Deliverable: Client-side token management


Task 3.3: Registration Form (Web Component) #

Goal: Create registration UI

Steps:

    • Email input
    • Password input
    • Display name input
    • Submit button
    • Call API client register method
    • Save tokens on success
    • Show error message on failure
    • Redirect to home on success

Deliverable: Working registration form component


Task 3.4: Login Form (Web Component) #

Goal: Create login UI

Steps:

    • Email input
    • Password input
    • Submit button
    • Link to registration
    • Call API client login method
    • Save tokens on success
    • Redirect to home on success

Deliverable: Working login form component


Task 3.5: Simple Routing #

Goal: Basic client-side navigation

Steps:

    • #/ - home/video feed
    • #/login - login page
    • #/register - registration page
    • #/upload - upload page

Deliverable: Basic client-side routing


Phase 4: Video Upload Backend #

Task 4.1: Video Storage Setup #

Goal: Configure video file storage

Steps:

    • $STORAGE_PATH/originals/
    • $STORAGE_PATH/variants/
    • $STORAGE_PATH/thumbs/

Deliverable: Storage directory management


Task 4.2: Video Database Schema #

Goal: Create video tables

Steps:

    • id TEXT PRIMARY KEY (UUID)
    • uploader_id TEXT NOT NULL (foreign key to users)
    • group_id TEXT (NULL for now, will add groups later)
    • title TEXT
    • description TEXT
    • duration_secs REAL NOT NULL
    • upload_date TEXT NOT NULL
    • original_path TEXT NOT NULL
    • thumbnail_path TEXT
    • processing_status TEXT NOT NULL (pending/processing/complete/failed)
    • id TEXT PRIMARY KEY
    • video_id TEXT NOT NULL (foreign key to videos)
    • quality TEXT NOT NULL (high/medium/low)
    • max_dimension INTEGER NOT NULL
    • path TEXT NOT NULL
    • bitrate_kbps INTEGER NOT NULL

Deliverable: Video database schema


Task 4.3: Video Model & Repository #

Goal: Video data structures and queries

Steps:

    • create_video(pool, video) -> Result<Video>
    • find_video_by_id(pool, id) -> Result<Option<Video>>
    • list_videos_by_user(pool, user_id) -> Result<Vec<Video>>
    • update_processing_status(pool, id, status) -> Result<()>

Deliverable: Video model with database operations


Task 4.4: Simple Upload Endpoint (Single File) #

Goal: POST /api/videos/upload (simplified, no chunking yet)

Steps:

    • Require authentication
    • Parse multipart form data
    • Get video file from form
    • Generate UUID for video
    • Save original file to storage
    • Create video record in database (status: pending)
    • Return video ID and upload confirmation

Deliverable: Basic video upload endpoint (no chunking yet)


Task 4.5: List Videos Endpoint #

Goal: GET /api/videos endpoint

Steps:

    • Require authentication
    • Get current user ID
    • Query videos for user
    • Return list of videos with metadata

Deliverable: Endpoint to list uploaded videos


Phase 5: Basic Video Upload Frontend #

Task 5.1: Video Upload API Methods #

Goal: Add upload methods to API client

Steps:

    • Video interface
    • UploadResponse interface
    • uploadVideo(file: File, title?: string) method
    • listVideos() method

Deliverable: Type-safe video API methods


Task 5.2: Simple Upload Form (Web Component) #

Goal: Basic video upload UI (no chunking yet)

Steps:

    • File input (accept video/*)
    • Title input (optional)
    • Upload button
    • Progress indicator (basic)
    • Validate file type
    • Show file name and size
    • Call API client upload method
    • Show progress/loading state
    • Show success message
    • Clear form on success

Deliverable: Basic video upload component


Task 5.3: Video List Component #

Goal: Display uploaded videos

Steps:

    • Fetch videos on component mount
    • Render list of videos
    • Show video metadata (title, upload date, status)
    • Show loading state
    • Show empty state

Deliverable: Video list component


Task 5.4: Basic Home Page #

Goal: Assemble components into home page

Steps:

Deliverable: Functional home page with navigation


Phase 6: Review & Polish #

Task 6.1: Error Handling Review #

Goal: Ensure good error messages throughout

Steps:

    • Network failures
    • Invalid input
    • Authentication errors
    • File upload errors

Deliverable: Polished error handling


Task 6.2: Basic Manual Testing #

Goal: End-to-end testing of implemented features

Test Scenarios:

Deliverable: Verified working MVP features


Next Phases (Future) #

After completing Phase 6, the next major features will be:

  • Phase 7: Groups (create, join, invite links)
  • Phase 8: Video transcoding and HLS streaming
  • Phase 9: Chunked upload implementation
  • Phase 10: Real-time updates (SSE)
  • Phase 11: Admin dashboard

Notes #

  • Each task should take 30 minutes to 2 hours max
  • You commit after each completed task - Claude will remind you
  • Review and test before committing
  • If a task is too large, break it down further
  • Don't proceed if tests/verification fails
  • Claude will wait for confirmation that you've committed before starting the next task