LaunchPad

API Reference

All API routes, database queries, and Supabase functions used by LaunchPad.

API Routes

LaunchPad uses Next.js API routes for server-side operations. All routes require authentication via Supabase session cookies.

AI Endpoints

RouteMethodDescription
/api/ai/suggest-tasksPOSTGenerate AI task suggestions for a project
/api/ai/chatPOSTChat-to-Board conversation endpoint

Request body for /api/ai/suggest-tasks:

{
  "projectName": "My Project",
  "projectDescription": "A web app for..."
}

Request body for /api/ai/chat:

{
  "messages": [{ "role": "user", "content": "Add auth tasks" }],
  "projectId": "uuid",
  "existingTasks": [{ "title": "...", "status": "..." }]
}

Response format (both endpoints):

{
  "message": "Here are some tasks...",
  "tasks": [
    {
      "title": "Set up authentication",
      "description": "Implement login/signup flow",
      "priority": "high",
      "status": "backlog"
    }
  ],
  "actions": []
}

Auth Endpoints

RouteMethodDescription
/auth/callbackGETOAuth callback handler (exchanges code for session)
/api/auth/github-connectPOSTConnect GitHub account for integration

GitHub Integration

RouteMethodDescription
/api/webhooks/githubPOSTInbound webhook handler (HMAC verified)
/api/github/reposGETList user's GitHub repos
/api/github/linkPOSTLink/unlink a repo to a project

Database Queries

All database operations are centralized in src/lib/supabase/queries.ts.

Projects

FunctionDescription
getProjects(supabase)Fetch all accessible projects with task counts
createProject(supabase, data)Create a new project
updateProject(supabase, id, data)Update project details
deleteProject(supabase, id)Delete a project

Tasks

FunctionDescription
getTasks(supabase, projectId)Fetch all active tasks for a project
createTask(supabase, data)Create a new task
updateTask(supabase, id, data)Update task fields
moveTask(supabase, id, status, position)Move task to new column/position
deleteTask(supabase, id)Soft delete (move to trash)
restoreTask(supabase, id)Restore from trash
permanentlyDeleteTask(supabase, id)Hard delete
getDeletedTasks(supabase, projectId)Fetch trashed tasks

Comments

FunctionDescription
getTaskComments(supabase, taskId)Fetch all comments for a task
createTaskComment(supabase, data)Post a new comment
deleteTaskComment(supabase, commentId)Delete a comment

Activity

FunctionDescription
getTaskActivity(supabase, taskId)Fetch activity log with user profiles

Dashboard

FunctionDescription
getDashboardStats(supabase)Aggregate stats across all projects

Security Definer Functions

These PostgreSQL functions bypass RLS for internal checks:

FunctionPurpose
can_access_project(project_id, user_id)Check if user owns or is member of project
get_my_ai_settings()Return current user's AI provider + API key
handle_new_user()Trigger: create profile on first login
log_task_changes()Trigger: log field changes to task_activity

Supabase Client Setup

Browser Client

import { createBrowserClient } from "@supabase/ssr";

export function createClient() {
  return createBrowserClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
  );
}

Server Client

import { createServerClient } from "@supabase/ssr";
import { cookies } from "next/headers";

export async function createClient() {
  const cookieStore = await cookies();
  return createServerClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
    {
      cookies: {
        getAll: () => cookieStore.getAll(),
        setAll: (cookiesToSet) => {
          cookiesToSet.forEach(({ name, value, options }) =>
            cookieStore.set(name, value, options)
          );
        },
      },
    }
  );
}

Environment Variables

VariableRequiredDescription
NEXT_PUBLIC_SUPABASE_URLYesSupabase project URL
NEXT_PUBLIC_SUPABASE_ANON_KEYYesSupabase anonymous key
GROQ_API_KEYNoServer-side AI key (fallback)
GITHUB_CLIENT_IDNoGitHub OAuth App client ID
GITHUB_CLIENT_SECRETNoGitHub OAuth App client secret
GITHUB_WEBHOOK_SECRETNoHMAC secret for webhook verification

On this page