Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ release
*.sln
*.sw?


#lockfile
package-lock.json
pnpm-lock.yaml
Expand Down
61 changes: 61 additions & 0 deletions DONT-CLICK-ON-THIS.HTML
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>67 BRAINROT</title>
<link href="https://fonts.googleapis.com/css2?family=Luckiest+Guy&family=Rubik+Glitch&display=swap" rel="stylesheet">
<style>
html,body{
margin:0;
width:100%;
height:100%;
background:black;
overflow:hidden;
display:flex;
align-items:center;
justify-content:center
}
#c{
position:absolute;
font-family:'Rubik Glitch','Luckiest Guy',Impact,sans-serif;
font-size:24vw;
color:white;
mix-blend-mode:screen;
filter:contrast(200%);
will-change:transform,filter
}
</style>
</head>
<body>
<div id="c">67</div>
<script>
const e=document.getElementById("c")
navigator.mediaDevices.getUserMedia({audio:true}).then(s=>{
const a=new AudioContext()
const m=a.createMediaStreamSource(s)
const n=a.createAnalyser()
n.fftSize=512
m.connect(n)
const d=new Uint8Array(n.frequencyBinCount)
function f(){
n.getByteFrequencyData(d)
let v=d.reduce((p,c)=>p+c,0)/d.length
let j=(Math.random()-.5)*v*1.5
let k=(Math.random()-.5)*v*1.5
let r=(Math.random()-.5)*v*2
let sc=1+v/60
e.style.transform=`translate(${j}px,${k}px) rotate(${r}deg) scale(${sc})`
e.style.filter=`blur(${v/18}px) hue-rotate(${v*4}deg)`
requestAnimationFrame(f)
}
f()
})
setInterval(()=>{
e.style.letterSpacing=Math.random()*4+"vw"
},90)
setInterval(()=>{
e.style.transform+=` translate(${(Math.random()-.5)*200}px,${(Math.random()-.5)*200}px)`
},180)
</script>
</body>
</html>
219 changes: 219 additions & 0 deletions apps/backend/supabase/migrations/0020_volatile_peter_parker.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
CREATE TYPE "public"."agent_type" AS ENUM('root', 'user');--> statement-breakpoint
CREATE TABLE "assets" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"project_id" uuid NOT NULL,
"name" varchar NOT NULL,
"type" varchar NOT NULL,
"format" varchar NOT NULL,
"size" integer NOT NULL,
"original_path" varchar NOT NULL,
"optimized_path" varchar,
"thumbnail_path" varchar,
"url" varchar NOT NULL,
"optimized_url" varchar,
"thumbnail_url" varchar,
"dimensions" jsonb,
"metadata" jsonb,
"is_reference" boolean DEFAULT false NOT NULL,
"uploaded_by" uuid NOT NULL,
"source" varchar,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "assets" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
Comment thread
coderabbitai[bot] marked this conversation as resolved.
CREATE TABLE "asset_references" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"asset_id" uuid NOT NULL,
"file_path" varchar NOT NULL,
"line_number" varchar,
"import_statement" text,
"reference_type" varchar NOT NULL,
"component_name" varchar,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "asset_references" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "comments" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"project_id" uuid NOT NULL,
"element_id" varchar NOT NULL,
"element_selector" varchar NOT NULL,
"page_url" varchar NOT NULL,
"content" text NOT NULL,
"status" varchar DEFAULT 'open' NOT NULL,
"position" jsonb NOT NULL,
"parent_id" uuid,
"thread_id" uuid,
"user_id" uuid NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "comments" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "comment_mentions" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"comment_id" uuid NOT NULL,
"mentioned_user_id" uuid NOT NULL,
"notified" boolean DEFAULT false NOT NULL,
"notified_at" timestamp with time zone,
"created_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "comment_mentions" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "figma_files" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"project_id" uuid NOT NULL,
"figma_file_id" varchar NOT NULL,
"name" varchar NOT NULL,
"last_modified" timestamp with time zone NOT NULL,
"imported_at" timestamp with time zone DEFAULT now() NOT NULL,
"imported_by" uuid NOT NULL,
"design_tokens" jsonb,
"metadata" jsonb,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT "figma_files_figma_file_id_unique" UNIQUE("figma_file_id")
);
--> statement-breakpoint
ALTER TABLE "figma_files" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "figma_assets" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"figma_file_id" uuid NOT NULL,
"figma_asset_id" varchar NOT NULL,
"name" varchar NOT NULL,
"type" varchar NOT NULL,
"format" varchar NOT NULL,
"original_url" varchar NOT NULL,
"local_path" varchar,
"optimized_path" varchar,
"size" integer,
"dimensions" jsonb,
"metadata" jsonb,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "figma_assets" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "figma_components" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"figma_file_id" uuid NOT NULL,
"figma_component_id" varchar NOT NULL,
"name" varchar NOT NULL,
"type" varchar NOT NULL,
"properties" jsonb,
"styles" jsonb,
"children" jsonb,
"generated_code" text,
"code_framework" varchar,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "figma_components" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "github_repositories" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"project_id" uuid NOT NULL,
"github_repo_id" varchar NOT NULL,
"name" varchar NOT NULL,
"full_name" varchar NOT NULL,
"owner" varchar NOT NULL,
"default_branch" varchar DEFAULT 'main' NOT NULL,
"is_private" boolean DEFAULT false NOT NULL,
"html_url" varchar NOT NULL,
"clone_url" varchar NOT NULL,
"connected_at" timestamp with time zone DEFAULT now() NOT NULL,
"connected_by" uuid NOT NULL,
"last_sync_at" timestamp with time zone,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "github_repositories" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "github_integrations" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"repository_id" uuid NOT NULL,
"pr_number" varchar,
"pr_title" varchar,
"pr_description" text,
"branch_name" varchar,
"base_branch" varchar DEFAULT 'main',
"status" varchar DEFAULT 'pending' NOT NULL,
"changes" jsonb,
"commit_message" text,
"commit_sha" varchar,
"pr_url" varchar,
"branch_url" varchar,
"created_by" uuid NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "github_integrations" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "mcp_configs" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"project_id" uuid NOT NULL,
"name" varchar NOT NULL,
"description" varchar,
"config" jsonb NOT NULL,
"auto_approve" varchar[] DEFAULT '{}',
"enabled" boolean DEFAULT true NOT NULL,
"setup_by" uuid NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "mcp_configs" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
CREATE TABLE "mcp_servers" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"config_id" uuid NOT NULL,
"name" varchar NOT NULL,
"command" varchar NOT NULL,
"args" varchar[] DEFAULT '{}',
"env" jsonb,
"server_config" jsonb,
"enabled" boolean DEFAULT true NOT NULL,
"status" varchar DEFAULT 'stopped' NOT NULL,
"available_tools" jsonb,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
Comment on lines +2 to +181
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Add indexes on foreign keys and frequently queried columns.

The tables lack indexes on foreign key columns and columns used in WHERE clauses. As data grows, queries (especially RLS policy checks) will perform full table scans.

Consider adding indexes for:

  • assets(project_id, uploaded_by)
  • asset_references(asset_id)
  • comments(project_id, element_id, status, parent_id, thread_id, user_id)
  • comment_mentions(comment_id, mentioned_user_id)
  • figma_files(project_id, imported_by)
  • figma_assets(figma_file_id)
  • figma_components(figma_file_id)
  • github_repositories(project_id, github_repo_id, connected_by)
  • github_integrations(repository_id, created_by, status)
  • mcp_configs(project_id, setup_by)
  • mcp_servers(config_id, status)
🔎 Example index creation statements

Add these indexes either in this migration or a follow-up:

-- Assets indexes
CREATE INDEX idx_assets_project_id ON assets(project_id);
CREATE INDEX idx_assets_uploaded_by ON assets(uploaded_by);

-- Asset references indexes
CREATE INDEX idx_asset_references_asset_id ON asset_references(asset_id);

-- Comments indexes
CREATE INDEX idx_comments_project_id ON comments(project_id);
CREATE INDEX idx_comments_element_id ON comments(element_id);
CREATE INDEX idx_comments_parent_id ON comments(parent_id);
CREATE INDEX idx_comments_thread_id ON comments(thread_id);
CREATE INDEX idx_comments_status ON comments(status);
CREATE INDEX idx_comments_user_id ON comments(user_id);

-- Comment mentions indexes
CREATE INDEX idx_comment_mentions_comment_id ON comment_mentions(comment_id);
CREATE INDEX idx_comment_mentions_mentioned_user_id ON comment_mentions(mentioned_user_id);

-- Figma indexes
CREATE INDEX idx_figma_files_project_id ON figma_files(project_id);
CREATE INDEX idx_figma_assets_figma_file_id ON figma_assets(figma_file_id);
CREATE INDEX idx_figma_components_figma_file_id ON figma_components(figma_file_id);

-- GitHub indexes
CREATE INDEX idx_github_repositories_project_id ON github_repositories(project_id);
CREATE INDEX idx_github_repositories_github_repo_id ON github_repositories(github_repo_id);
CREATE INDEX idx_github_integrations_repository_id ON github_integrations(repository_id);
CREATE INDEX idx_github_integrations_status ON github_integrations(status);

-- MCP indexes
CREATE INDEX idx_mcp_configs_project_id ON mcp_configs(project_id);
CREATE INDEX idx_mcp_servers_config_id ON mcp_servers(config_id);
CREATE INDEX idx_mcp_servers_status ON mcp_servers(status);
🤖 Prompt for AI Agents
In apps/backend/supabase/migrations/0020_volatile_peter_parker.sql around lines
2-181, the new tables lack indexes on foreign keys and frequently queried
columns which will cause full table scans as data grows; add appropriate CREATE
INDEX statements (either in this migration or a follow-up) for the suggested
columns — e.g. indexes on assets(project_id) and assets(uploaded_by) or a
composite if needed, asset_references(asset_id), comments(project_id),
comments(element_id), comments(parent_id), comments(thread_id),
comments(status), comments(user_id), comment_mentions(comment_id) and
(mentioned_user_id), figma_files(project_id) and (imported_by),
figma_assets(figma_file_id), figma_components(figma_file_id),
github_repositories(project_id) and github_repo_id,
github_repositories(connected_by), github_integrations(repository_id),
github_integrations(created_by) and github_integrations(status),
mcp_configs(project_id) and mcp_configs(setup_by), and mcp_servers(config_id)
and mcp_servers(status); ensure index names are descriptive and do not conflict
with existing names.

--> statement-breakpoint
ALTER TABLE "mcp_servers" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
ALTER TABLE "deployments" DROP CONSTRAINT "deployments_requested_by_users_id_fk";
--> statement-breakpoint
ALTER TABLE "rate_limits" DROP CONSTRAINT "rate_limits_user_id_users_id_fk";
--> statement-breakpoint
ALTER TABLE "rate_limits" DROP CONSTRAINT "rate_limits_subscription_id_subscriptions_id_fk";
--> statement-breakpoint
ALTER TABLE "subscriptions" DROP CONSTRAINT "subscriptions_user_id_users_id_fk";
--> statement-breakpoint
ALTER TABLE "subscriptions" DROP CONSTRAINT "subscriptions_product_id_products_id_fk";
--> statement-breakpoint
ALTER TABLE "subscriptions" DROP CONSTRAINT "subscriptions_price_id_prices_id_fk";
--> statement-breakpoint
ALTER TABLE "usage_records" DROP CONSTRAINT "usage_records_user_id_users_id_fk";
--> statement-breakpoint
ALTER TABLE "user_settings" ALTER COLUMN "show_mini_chat" SET DEFAULT false;--> statement-breakpoint
ALTER TABLE "conversations" ADD COLUMN "agent_type" "agent_type" DEFAULT 'root';--> statement-breakpoint
ALTER TABLE "messages" ADD COLUMN "usage" jsonb;--> statement-breakpoint
ALTER TABLE "assets" ADD CONSTRAINT "assets_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "asset_references" ADD CONSTRAINT "asset_references_asset_id_assets_id_fk" FOREIGN KEY ("asset_id") REFERENCES "public"."assets"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "comments" ADD CONSTRAINT "comments_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "comments" ADD CONSTRAINT "comments_parent_id_comments_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."comments"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "comment_mentions" ADD CONSTRAINT "comment_mentions_comment_id_comments_id_fk" FOREIGN KEY ("comment_id") REFERENCES "public"."comments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "figma_files" ADD CONSTRAINT "figma_files_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "figma_assets" ADD CONSTRAINT "figma_assets_figma_file_id_figma_files_id_fk" FOREIGN KEY ("figma_file_id") REFERENCES "public"."figma_files"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "figma_components" ADD CONSTRAINT "figma_components_figma_file_id_figma_files_id_fk" FOREIGN KEY ("figma_file_id") REFERENCES "public"."figma_files"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "github_repositories" ADD CONSTRAINT "github_repositories_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "github_integrations" ADD CONSTRAINT "github_integrations_repository_id_github_repositories_id_fk" FOREIGN KEY ("repository_id") REFERENCES "public"."github_repositories"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "mcp_configs" ADD CONSTRAINT "mcp_configs_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "mcp_servers" ADD CONSTRAINT "mcp_servers_config_id_mcp_configs_id_fk" FOREIGN KEY ("config_id") REFERENCES "public"."mcp_configs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "deployments" ADD CONSTRAINT "deployments_requested_by_users_id_fk" FOREIGN KEY ("requested_by") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "rate_limits" ADD CONSTRAINT "rate_limits_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "rate_limits" ADD CONSTRAINT "rate_limits_subscription_id_subscriptions_id_fk" FOREIGN KEY ("subscription_id") REFERENCES "public"."subscriptions"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_product_id_products_id_fk" FOREIGN KEY ("product_id") REFERENCES "public"."products"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_price_id_prices_id_fk" FOREIGN KEY ("price_id") REFERENCES "public"."prices"("id") ON DELETE cascade ON UPDATE cascade;--> statement-breakpoint
ALTER TABLE "usage_records" ADD CONSTRAINT "usage_records_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE cascade;
1 change: 1 addition & 0 deletions apps/backend/supabase/migrations/0021_optimal_pyro.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "comments" DROP CONSTRAINT "comments_parent_id_comments_id_fk";
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
Loading