diff --git a/.env b/.env
index 96a9f85..78f6130 100644
--- a/.env
+++ b/.env
@@ -1,2 +1 @@
# make your own .env.local file with any secret keys
-FIREBASE_API_KEY=AIzaSyBMSlF-S6LQFa-Zv9Yc48YxFCqV5wqvjd4
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index fd3dbb5..9c3206d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,8 @@ yarn-error.log*
# local env files
.env*.local
+.env.local
+*.env.local
# vercel
.vercel
diff --git a/app/api/checkout_sessions/route.js b/app/api/checkout_sessions/route.js
new file mode 100644
index 0000000..2f6de62
--- /dev/null
+++ b/app/api/checkout_sessions/route.js
@@ -0,0 +1,42 @@
+import { loadStripe } from '@stripe/stripe-js';
+import { NextResponse } from 'next/server';
+const stripe = new Stripe(process.env.STRPE_API_SECRET_KEY)
+/* const stripe = await loadStripe(process.env.STRIPE_API_PUBLIC_KEY); */
+
+const formatAmountStripe = (amount) => {
+ return Math.round(amount * 100)
+}
+
+export async function POST(req) {
+ const params = {
+ submit_type: 'subscription',
+ payment_method_types: ['card'],
+ line_items: [
+ {
+ price_data: {
+ currency: "usd",
+ product_data: {
+ name: "Pro subscription",
+ },
+ unit_amount: formatAmountStripe(10),
+ reccuring: {
+ interval: "month",
+ interval_count: 1,
+ },
+ },
+ quantity: 1,
+ },
+ ],
+ success_url: `${req.headers.origin}/result?session_id={CHECKOUT_SESSION_ID}`,
+ cancel_url: `${req.headers.origin}/result?session_id={CHECKOUT_SESSION_ID}`,
+ }
+
+ const checkoutSession = await stripe.checkout.sessions.create(params);
+
+ return NextResponse.json(checkoutSession, {
+ status: 200,
+ })
+
+}
+
+
diff --git a/app/api/generate/route.js b/app/api/generate/route.js
index e69de29..bcf076b 100644
--- a/app/api/generate/route.js
+++ b/app/api/generate/route.js
@@ -0,0 +1,44 @@
+import { IM_Fell_French_Canon } from "next/font/google";
+import { NextResponse } from "next/server";
+import OpenAI, { fileFromPath } from "openai"
+
+const systemPrompt = `You are a flashcard creator. Your primary goal is to generate clear, concise, and effective flashcards that help users learn and retain information. Each flashcard should focus on a single concept or question, with a brief, accurate answer or explanation. Ensure that the language used is simple and accessible, catering to the user’s level of knowledge on the subject. Whenever possible, include examples, analogies, or mnemonics to aid in memory retention. Your flashcards should be well-organized and categorized, making it easy for users to review and study the material systematically.
+1. Understand the Topic: Begin by thoroughly understanding the subject matter or topic for which the flashcards are being created.
+2. Identify Key Concepts: Break down the topic into its core concepts, terms, or questions that are essential for understanding the material.
+3. Formulate Questions: For each key concept, create a clear and concise question that targets the specific knowledge or skill the user needs to acquire.
+4. Craft Answers: Write brief, accurate, and focused answers or explanations for each question, ensuring that the language is easy to understand.
+5. Use Examples: Where applicable, include examples that illustrate the concept or answer in a practical, relatable way.
+6. Incorporate Mnemonics: Add mnemonic devices, analogies, or memory aids to help users remember challenging or complex information.
+7. Ensure Clarity: Review each flashcard to ensure that the questions and answers are clear, unambiguous, and directly related to the key concepts.
+8. Organize Systematically: Arrange the flashcards in a logical order, grouping related concepts together to facilitate easier learning and review.
+9. Review and Revise: After creating the flashcards, review them to check for accuracy, clarity, and completeness. Make any necessary revisions to improve their effectiveness.
+10. Aim to create a balanced set of flashcards that covers the topics comprehensively
+
+Return in the following JSON format
+{
+ "flashcards":|
+ {
+ "front": str,
+ "back": str
+ }|
+}
+`;
+
+export async function POST(req){
+ const openai = OpenAI()
+ const data = await req.text()
+
+ const completion = await openai.chat.completion.create({
+ messages: [
+ {role: "system", content: systemPrompt},
+ {role: "user", content: data},
+ ],
+
+ model: "gpt-4o",
+ respnse_format:{type: "json_object"}
+ })
+
+ const flashcards = JSON.parse(completion.choices[0].message.content)
+
+ return NextResponse.json(flashcards.flashcard)
+}
\ No newline at end of file
diff --git a/app/layout.js b/app/layout.js
index 9aef1df..0b3bf91 100644
--- a/app/layout.js
+++ b/app/layout.js
@@ -1,6 +1,8 @@
import { Inter } from "next/font/google";
import "./globals.css";
+import { ClerkProvider } from '@clerk/nextjs'
+
const inter = Inter({ subsets: ["latin"] });
export const metadata = {
@@ -10,8 +12,11 @@ export const metadata = {
export default function RootLayout({ children }) {
return (
-
-