What inside?
https://production-url/
git clone https://github.com/nicitaacom/29_ai-companion/
pnpm i
Login in supabase - https://app.supabase.com/sign-in
1. category
create table
public.category (
id uuid not null default uuid_generate_v4 (),
name character varying(255) not null,
constraint category_pkey primary key (id)
) tablespace pg_default;
2. companion
create table
public.companion (
id uuid not null default uuid_generate_v4 (),
user_id uuid not null default gen_random_uuid (),
username character varying(255) not null,
src character varying(255) not null,
name text not null,
description text not null,
instructions text not null,
seed text not null,
created_at timestamp with time zone not null default timezone ('UTC'::text, now()),
updated_at timestamp with time zone not null default timezone ('UTC'::text, now()),
category_id uuid not null,
constraint companion_pkey primary key (id),
constraint companion_category_id_fkey foreign key (category_id) references category (id) on update cascade on delete cascade,
constraint public_companion_user_id_fkey foreign key (user_id) references auth.users (id) on update cascade on delete cascade
) tablespace pg_default;
allow select for authenticated user
Target role - authenticated
true
allow to delete their own companions
(user_id = auth.uid())
3. messages
create table
public.messages (
id uuid not null default uuid_generate_v4 (),
role public.role not null,
content text not null,
created_at timestamp with time zone not null default timezone ('UTC'::text, now()),
updated_at timestamp with time zone not null default timezone ('UTC'::text, now()),
companion_id uuid not null,
user_id character varying(255) not null,
constraint message_pkey primary key (id)
) tablespace pg_default;
allow insert for authenticated users
Target role - authenticated
true
allow select for authenticated users
Target role - authenticated
true
4. user_subscription
create table
public.user_subscription (
id uuid not null default uuid_generate_v4 (),
user_id character varying(255) not null,
stripe_customer_id character varying(255) null,
stripe_subscription_id character varying(255) null,
stripe_price_id character varying(255) null,
stripe_current_period_end timestamp with time zone null,
constraint usersubscription_pkey primary key (id),
constraint usersubscription_stripecustomerid_key unique (stripe_customer_id),
constraint usersubscription_stripesubscriptionid_key unique (stripe_subscription_id),
constraint usersubscription_userid_key unique (user_id)
) tablespace pg_default;
4. user_subscription
create table
public.users (
id uuid not null,
created_at timestamp with time zone not null default now(),
email text not null,
avatar_url text null,
providers text[] not null default '{}'::text[],
role text[] not null default '{USER}'::text[],
constraint users_duplicate_pkey primary key (id),
constraint users_id_fkey foreign key (id) references auth.users (id) on update cascade on delete cascade
) tablespace pg_default;
allow select user based on user id
(id = auth.uid())
allow updated user based on user id
(id = auth.uid())
https://youtu.be/PGPGcKBpAk8?t=17601
https://youtu.be/PjYWpd7xkaM?t=15618
Note that PINECONE_ENVIRONMENT='gcp-starter'
for 02.2024 for free plan on GCP
https://youtu.be/PjYWpd7xkaM?t=17350