Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/supabase dev environment #7

Merged
merged 110 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
2ec7f46
feat(apps/chat-with-pdf): supabase init
dartilesm Aug 18, 2024
e671909
feat(apps/chat-with-pdf): add document prisma model and embedding column
dartilesm Aug 18, 2024
29ce62e
feat(apps/chat-with-pdf): add metadata to document
dartilesm Aug 18, 2024
abdaa49
feat(apps/chat-with-pdf): add new migrations
dartilesm Aug 19, 2024
fcbdec3
feat(apps/chat-with-pdf): add new migrations, add document-sections t…
dartilesm Aug 21, 2024
de312f1
feat(apps/chat-with-pdf): generate uuid for document sections
dartilesm Aug 24, 2024
6d1bc88
feat(apps/chat-with-pdf): insert embedding to supabase
dartilesm Aug 24, 2024
adf1038
feat(apps/chat-with-pdf): add new migrations supabase and prisma
dartilesm Aug 25, 2024
7eb6e14
feat(apps/chat-with-pdf): get context from supabase
dartilesm Aug 25, 2024
59195ae
refactor(apps/chat-with-pdf): replace prisma queries by supabase
dartilesm Sep 2, 2024
4d9cde6
refactor(apps/chat-with-pdf): add supabase types
dartilesm Sep 2, 2024
89e46ff
feat(apps/chat-with-pdf): add login and sign-up pages and components
dartilesm Sep 2, 2024
9bb604c
feat(apps/chat-with-pdf): add login and sign-up logic for supabase
dartilesm Sep 2, 2024
74bf017
chore(apps/chat-with-pdf): update migrations
dartilesm Sep 3, 2024
e02f978
refactor(apps/chat-with-pdf): add errors to login and sign-up flow
dartilesm Sep 11, 2024
d8aaae6
feat(packages/ui): add controlled errors to input fields
dartilesm Sep 11, 2024
2b78f32
feat(apps/chat-with-pdf): add github authentication method
dartilesm Sep 14, 2024
3584832
feat(apps/chat-with-pdf): add theme switcher under user nav
dartilesm Sep 14, 2024
f749857
fix(packages/ui): fix text-destructive color when the input has an error
dartilesm Sep 14, 2024
e4d5b93
chore(apps/chat-with-pdf): add ci github actions code to start supabase
dartilesm Sep 14, 2024
9206729
chore(apps/chat-with-pdf): move ci workflow to the root folder
dartilesm Sep 14, 2024
33300af
chore(Root): try to fix the ci.yml file
dartilesm Sep 14, 2024
90b0f2f
chore(Root): fix ci yml file
dartilesm Sep 14, 2024
ee341d5
chore(Root): update the ci.yml file
dartilesm Sep 14, 2024
f10f588
chore(Root): remove paths from ci.yml
dartilesm Sep 14, 2024
9f7a501
chore(Root): add tests and lint to supabase
dartilesm Sep 14, 2024
23b3317
chore(Root): fix ci.yml supabase wrong commands
dartilesm Sep 14, 2024
89caae5
chore(Root): push migration to stating
dartilesm Sep 14, 2024
22362ef
chore(Root): change types location in the ci.yml file
dartilesm Sep 14, 2024
e009b1e
feat(apps/chat-with-pdf): add profile types to database.types.ts
dartilesm Sep 14, 2024
61dc07a
chore(Root): hide 'Verify generated types are checked in' step
dartilesm Sep 14, 2024
8567c70
chore(Root): debug supabase link error
dartilesm Sep 14, 2024
e21cd8e
chore(Root): show SUPABASE_PROJECT_ID
dartilesm Sep 14, 2024
a0c2627
chore(Root): change secrets name
dartilesm Sep 14, 2024
d9e6ef8
chore(Root): change secrets name
dartilesm Sep 14, 2024
0ef08f6
chore(Root): add supabase login to ci.yml
dartilesm Sep 14, 2024
47b64fd
chore(Root): hide test job in ci.yml file
dartilesm Sep 14, 2024
9b0f6e8
chore(Root): Update Supabase CI workflow to dry-run database push
dartilesm Sep 14, 2024
1ad1af9
chore(Root): change working directory in the ci.yml file
dartilesm Sep 14, 2024
335a627
chore(Root): hide paths in the ci.yml file
dartilesm Sep 14, 2024
9522e4e
chore(Root): add Github client id and secret variables to the ci.yml …
dartilesm Sep 14, 2024
ae32515
fix(apps/chat-with-pdf): fix create extension statement
dartilesm Sep 14, 2024
ab862cb
chore(Root): create supabase-update-db.yml and rename ci.yml
dartilesm Sep 14, 2024
e6dafdd
Merge branch 'develop' of github.com:dartilesm/makify into feature/su…
dartilesm Sep 14, 2024
a72ce25
chore(Root): restrict the yml to only when new migrations are made
dartilesm Sep 14, 2024
58acc35
fix(apps/chat-with-pdf): fix build errors
dartilesm Sep 14, 2024
5a7c996
feat(apps/chat-with-pdf): add dynamic redirectTo url
dartilesm Sep 15, 2024
fc8e27e
fix(apps/chat-with-pdf): wrap login and signup component into a suspe…
dartilesm Sep 15, 2024
0054e28
refactor(apps/chat-with-pdf): add logs to debug on the server
dartilesm Sep 15, 2024
3b24703
refactor(apps/chat-with-pdf): add log in the middleware
dartilesm Sep 15, 2024
e6f5e17
refactor(apps/chat-with-pdf): remove logs
dartilesm Sep 15, 2024
f20a310
refactor(apps/chat-with-pdf): use authenticated supabase client
dartilesm Sep 15, 2024
f7942ed
fix(apps/chat-with-pdf): fix client and server errors
dartilesm Sep 15, 2024
e1c9e10
fix(apps/chat-with-pdf): restore the isTyping animation
dartilesm Sep 15, 2024
b1b5b5d
fix(apps/chat-with-pdf): fix dynamic data error from cached functions
dartilesm Sep 16, 2024
59d7884
feat(apps/chat-with-pdf): add better formatting to ai messages and un…
dartilesm Sep 22, 2024
1935225
feat(apps/chat-with-pdf): add the u element in the ai messages to hig…
dartilesm Sep 27, 2024
f4591a4
feat(apps/chat-with-pdf): get/update/delete document data from docume…
dartilesm Sep 28, 2024
3d10412
feat(Root): add suggested questions ui and install drawer and scroll-…
dartilesm Sep 28, 2024
81c43b8
feat(apps/chat-with-pdf): add generate-suggested-question action
dartilesm Sep 28, 2024
cce6cce
feat(apps/chat-with-pdf): improve suggested question ui
dartilesm Sep 28, 2024
afba837
feat(apps/chat-with-pdf): improve suggested questions animation
dartilesm Sep 28, 2024
a779d84
feat(apps/chat-with-pdf): add support to suggested questions and remo…
dartilesm Oct 4, 2024
149afb5
refactor(apps/chat-with-pdf): improve z-indexes
dartilesm Oct 5, 2024
1b00124
feat(apps/chat-with-pdf): fetch the suggested questions if they are n…
dartilesm Oct 6, 2024
fcda0b5
feat(packages/ui): add the sheet component
dartilesm Oct 7, 2024
ba62498
feat(apps/chat-with-pdf): simplify the ui
dartilesm Oct 7, 2024
3ba128b
feat(apps/chat-with-pdf): add sidebar
dartilesm Oct 7, 2024
850bdbf
feat(apps/chat-with-pdf): add sidebar in the /chats view and add log …
dartilesm Oct 7, 2024
7bb806f
feat(apps/chat-with-pdf): auto focus textarea when quoting texts
dartilesm Oct 7, 2024
219041d
feat(apps/chat-with-pdf): add full width when opening the suggested q…
dartilesm Oct 7, 2024
68cdb28
feat(apps/chat-with-pdf): add recent conversations
dartilesm Oct 13, 2024
e75aa57
fix(apps/chat-with-pdf): fix edit chat action
dartilesm Oct 13, 2024
95f0de2
fix(apps/chat-with-pdf): fix new-chat route when uploading pdfs
dartilesm Oct 13, 2024
24d09dd
feat(apps/chat-with-pdf): switch document-switcher to document-title
dartilesm Oct 14, 2024
3afae75
feat(apps/chat-with-pdf): start a new conversation from sidebar
dartilesm Oct 14, 2024
aabf0ed
feat(apps/chat-with-pdf): add styles to the scrollbar
dartilesm Oct 14, 2024
938c30e
fix(apps/chat-with-pdf): long email in the sidebar
dartilesm Oct 14, 2024
355222f
feat(apps/chat-with-pdf): add confirmation email support
dartilesm Oct 14, 2024
df504f5
feat(packages/ui): add input-otp component
dartilesm Oct 15, 2024
6dcd8a5
feat(apps/chat-with-pdf): add sign-up flow and custom email templates
dartilesm Oct 15, 2024
126a941
feat(apps/chat-with-pdf): add login components
dartilesm Oct 15, 2024
97a3756
feat(apps/chat-with-pdf): improve the login and sign-up pages
dartilesm Oct 19, 2024
adfcf3f
feat(Root): add new shadcn sidebar, update tailwind and fix layouts
dartilesm Oct 20, 2024
b6f2c8f
fix(Root): fix sidebar layout
dartilesm Oct 20, 2024
3bd500f
fix(apps/chat-with-pdf): improve sidebar's header padding
dartilesm Oct 20, 2024
ea5b4f1
feat(apps/chat-with-pdf): add makify logo
dartilesm Oct 21, 2024
621dced
fix(apps/chat-with-pdf): redirection issues
dartilesm Oct 21, 2024
d44ab8a
feat(apps/chat-with-pdf): add app icon and logo
dartilesm Oct 27, 2024
d476847
feat(apps/chat-with-pdf): change page number when clicking on underli…
dartilesm Oct 27, 2024
f314deb
fix(apps/chat-with-pdf): fix the authentication process and chat endp…
dartilesm Oct 31, 2024
789f4fe
fix(apps/chat-with-pdf): fix a typescript error
dartilesm Oct 31, 2024
be72fd7
chore(apps/chat-with-pdf): apply migration to user role and userId field
dartilesm Nov 2, 2024
a45c21b
fix(packages/ui): ui components typescript issues
dartilesm Nov 2, 2024
43cba87
refactor(apps/chat-with-pdf): log the resend key
dartilesm Nov 2, 2024
ee72d6c
refactor(apps/chat-with-pdf): log the resend key correctly
dartilesm Nov 2, 2024
02618eb
refactor(apps/chat-with-pdf): set authentication routes as dynamic
dartilesm Nov 2, 2024
98dcfce
Revert "refactor(apps/chat-with-pdf): set authentication routes as dy…
dartilesm Nov 2, 2024
f8b27dc
refactor(apps/chat-with-pdf): print RESEND_API_KEY
dartilesm Nov 2, 2024
d7eb0be
refactor(apps/chat-with-pdf): log the RESEND_API_KEY before running t…
dartilesm Nov 2, 2024
ba50d36
chore(Root): add build scripts for the landing and chat-with-pdf app
dartilesm Nov 2, 2024
bb23f55
chore(apps/chat-with-pdf): add dev script in loose env mode
dartilesm Nov 3, 2024
6a34989
fix(apps/chat-with-pdf): avoid parsing undefined chunk when creating …
dartilesm Nov 3, 2024
15c4b60
fix(apps/chat-with-pdf): use the gemini-1.5-flash-latest model for th…
dartilesm Nov 3, 2024
a6b2fce
fix(apps/chat-with-pdf): fix delete chat action and add toast error w…
dartilesm Nov 9, 2024
6e14576
fix(apps/chat-with-pdf): fix suggested questions UI
dartilesm Nov 9, 2024
1da3599
fix(apps/chat-with-pdf): fix create new conversation/chat
dartilesm Nov 9, 2024
f4077a8
feat(apps/chat-with-pdf): add new migration file
dartilesm Nov 9, 2024
551d2e5
fix(apps/chat-with-pdf): fix typescript issue
dartilesm Nov 9, 2024
7220c5c
fix(apps/chat-with-pdf): fix migration history
dartilesm Nov 9, 2024
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
55 changes: 55 additions & 0 deletions .github/workflows/supabase-tests-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Supabase checks

on:
push:
paths:
# Only run the workflow when changes are made to the migrations directory
- "apps/chat-with-pdf/supabase/migrations/**"
branches:
- "feature/**"
workflow_dispatch:

jobs:
test:
name: Supabase tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: supabase/setup-cli@v1
with:
version: latest

- name: Init Supabase local development setup
run: supabase init

- name: Start Supabase local development setup
run: supabase start

- name: Run Supabase lint locally
run: supabase db lint

- name: Run Supabase tests locally
run: supabase test db
push:
name: Push to Supabase
needs: test
runs-on: ubuntu-latest
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_PROJECT_ID: ${{ github.base_ref == 'main' && secrets.SUPABASE_PROD_PROJECT_ID || secrets.SUPABASE_STAGING_PROJECT_ID }}
SUPABASE_DB_PASSWORD: ${{ github.base_ref == 'main' && secrets.SUPABASE_PROD_DB_PASSWORD || secrets.SUPABASE_STAGING_DB_PASSWORD }}
SUPABASE_AUTH_GITHUB_CLIENT_ID: ${{ secrets.SUPABASE_AUTH_GITHUB_CLIENT_ID }}
SUPABASE_AUTH_GITHUB_SECRET: ${{ secrets.SUPABASE_AUTH_GITHUB_SECRET }}

steps:
- uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with:
version: latest

- run: supabase link --project-ref $SUPABASE_PROJECT_ID --debug
working-directory: apps/chat-with-pdf
- run: supabase db push
working-directory: apps/chat-with-pdf
32 changes: 32 additions & 0 deletions .github/workflows/supabase-update-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Supabase update

on:
push:
paths:
- "apps/chat-with-pdf/**"
branches:
- "develop"
- "main"
workflow_dispatch:

jobs:
update:
name: Update Supabase db
runs-on: ubuntu-latest
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
SUPABASE_PROJECT_ID: ${{ github.base_ref == 'main' && secrets.SUPABASE_PROD_PROJECT_ID || secrets.SUPABASE_STAGING_PROJECT_ID }}
SUPABASE_DB_PASSWORD: ${{ github.base_ref == 'main' && secrets.SUPABASE_PROD_DB_PASSWORD || secrets.SUPABASE_STAGING_DB_PASSWORD }}
SUPABASE_AUTH_GITHUB_CLIENT_ID: ${{ secrets.SUPABASE_AUTH_GITHUB_CLIENT_ID }}
SUPABASE_AUTH_GITHUB_SECRET: ${{ secrets.SUPABASE_AUTH_GITHUB_SECRET }}

steps:
- uses: actions/checkout@v4
- uses: supabase/setup-cli@v1
with:
version: latest

- run: supabase link --project-ref $SUPABASE_PROJECT_ID --debug
working-directory: apps/chat-with-pdf
- run: supabase db push
working-directory: apps/chat-with-pdf
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ node_modules

# Local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
.env**

# Testing
coverage
Expand Down
40 changes: 40 additions & 0 deletions apps/chat-with-pdf/app/(authentication)/auth-failed/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ArrowRightIcon } from "lucide-react";
import Link from "next/link";

export default function AuthFailed() {
return (
<div className="bg-background flex min-h-screen flex-col items-center justify-center">
<div className="mx-auto flex max-w-[400px] flex-col items-center space-y-6 text-center">
<div className="bg-destructive/10 flex h-20 w-20 items-center justify-center rounded-full">
<svg
className="text-destructive h-10 w-10"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
/>
</svg>
</div>
<h1 className="text-2xl font-semibold tracking-tight">
Authentication Failed
</h1>
<p className="text-muted-foreground">
There was a problem authenticating your account. Please try signing in
again.
</p>
<Link
href="/login"
className="bg-primary text-primary-foreground hover:bg-primary/90 flex inline-flex h-10 items-center justify-center gap-2 rounded-md px-8 text-sm font-medium transition-colors"
>
Return to Login <ArrowRightIcon className="h-4 w-4" />
</Link>
</div>
</div>
);
}
11 changes: 11 additions & 0 deletions apps/chat-with-pdf/app/(authentication)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default function AuthenticationLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<div className="flex h-screen w-full items-center justify-center lg:min-h-[600px] xl:min-h-[800px]">
<div className="flex items-center justify-center py-12">{children}</div>
</div>
);
}
10 changes: 10 additions & 0 deletions apps/chat-with-pdf/app/(authentication)/login/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { LoginContainer } from "@/components/pages-containers/login/login-container";
import { Suspense } from "react";

export default function LoginPage() {
return (
<Suspense fallback={null}>
<LoginContainer />
</Suspense>
);
}
10 changes: 10 additions & 0 deletions apps/chat-with-pdf/app/(authentication)/signup/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SignUpContainer } from "@/components/pages-containers/signup/sign-up-container";
import { Suspense } from "react";

export default function LoginPage() {
return (
<Suspense fallback={null}>
<SignUpContainer />
</Suspense>
);
}
7 changes: 7 additions & 0 deletions apps/chat-with-pdf/app/(default)/chat/[documentId]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default async function ChatLayout({
children,
}: {
children: React.ReactNode;
}) {
return <>{children}</>;
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { getCachedChatMessages } from "@/app/actions/get-chat-messages";
import { ChatIdContainer } from "@/components/pages-containers/chat-id-container";
import { Metadata, ResolvingMetadata } from "next";
import { Metadata } from "next";
import { redirect } from "next/navigation";
import { getChat } from "supabase/queries/get-chat";
import { getDocumentByChatId } from "@/app/actions/get-document-by-chat-id";

type Props = {
params: {
documentId: string;
};
};

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const chatData = await getCachedChatMessages(params.documentId);
const document = await getDocumentByChatId(params.documentId);

return {
title: `Chat - ${(chatData?.documentMetadata as Record<string, unknown>)?.title}`,
title: `Chat - ${document?.name || "Untitled"}`,
};
}

export default async function Page({ params }: Props) {
const chatData = await getCachedChatMessages(params.documentId);
const chatData = await getChat(params.documentId);

if (!chatData) redirect("/chat");

Expand Down
13 changes: 13 additions & 0 deletions apps/chat-with-pdf/app/(default)/chat/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Metadata } from "next";

export const metadata: Metadata = {
title: "Chats",
};

export default async function ChatLayout({
children,
}: {
children: React.ReactNode;
}) {
return <>{children}</>;
}
12 changes: 12 additions & 0 deletions apps/chat-with-pdf/app/(default)/chat/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ChatsContainer } from "@/components/pages-containers/chats-container";
import { getChats } from "supabase/queries/get-chats";
import { getDocuments } from "supabase/queries/get-documents";

export const dynamic = "force-dynamic";

export default async function Page() {
const chats = await getChats();
const documents = await getDocuments();

return <ChatsContainer chats={chats} documents={documents} />;
}
42 changes: 42 additions & 0 deletions apps/chat-with-pdf/app/(default)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Header } from "@/components/header/header";
import { AppSidebar } from "@/components/sidebar/app-sidebar";
import { createClient } from "@/lib/supabase/server";
import { SidebarProvider } from "@makify/ui";
import { cn } from "@makify/ui/lib/utils";
import { User } from "@supabase/supabase-js";
import { Metadata } from "next";

export const metadata: Metadata = {
title: "Chats",
};

export default async function DefaultLayout({
children,
}: {
children: React.ReactNode;
}) {
const supabase = createClient();
const {
data: { user },
} = await supabase.auth.getUser();

return (
<SidebarProvider
defaultOpen={false}
className="flex h-screen w-screen max-w-[100vw] flex-row"
>
<AppSidebar userInfo={user as User} />
<div
className={cn([
"flex h-screen flex-1 shrink-0 flex-col",
// Calculate the remaining width for the main content
// as the css is not able to calculate it
"max-w-[calc(100%-(var(--sidebar-width-icon)))]",
])}
>
<Header />
<main className="flex flex-1 flex-row overflow-hidden">{children}</main>
</div>
</SidebarProvider>
);
}
18 changes: 18 additions & 0 deletions apps/chat-with-pdf/app/actions/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use server";

import { createClient } from "@/lib/supabase/server";

export const verifyOtp = async (data: {
email: string;
otp: string;
type: string;
}) => {
const supabase = createClient();

const res = await supabase.auth.verifyOtp({
email: data.email,
token: data.otp,
type: "email",
});
return JSON.stringify(res);
};
54 changes: 0 additions & 54 deletions apps/chat-with-pdf/app/actions/create-new-chat.ts

This file was deleted.

Loading
Loading