Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
developersdigest committed Sep 17, 2024
1 parent b0bf0c4 commit c523445
Show file tree
Hide file tree
Showing 13 changed files with 601 additions and 107 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dotenv.enableAutocloaking": true
}
40 changes: 40 additions & 0 deletions app/api/generate-report/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { NextResponse } from 'next/server';
import OpenAI from "openai";
import FirecrawlApp from '@mendable/firecrawl-js';

const openai = new OpenAI();
const firecrawlApp = new FirecrawlApp({ apiKey: process.env.FIRECRAWL_API_KEY });

export async function POST(request: Request) {
const { url, instructions } = await request.json();

const crawlResponse = await firecrawlApp.crawlUrl(url, {
limit: 5,
scrapeOptions: {
formats: ['markdown', 'html'],
}
});

if (!crawlResponse.success) {
throw new Error(`Failed to crawl: ${crawlResponse.error}`);
}

const completion = await openai.chat.completions.create({
model: "o1-preview",
messages: [
{
role: "user",
content: `
Generate a report with the following details in valid HTML:
- Instructions: ${instructions}
- URL: ${url}
- Results: ${JSON.stringify(crawlResponse.data)}
`
}
]
});

const generatedHtml = completion.choices[0].message.content;

return NextResponse.json({ html: generatedHtml, crawlData: crawlResponse.data });
}
162 changes: 162 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,165 @@ body {
background: var(--background);
font-synthesis: none;
}

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 0 0% 3.9%;
--card: 0 0% 100%;
--card-foreground: 0 0% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 0 0% 3.9%;
--primary: 0 0% 9%;
--primary-foreground: 0 0% 98%;
--secondary: 0 0% 96.1%;
--secondary-foreground: 0 0% 9%;
--muted: 0 0% 96.1%;
--muted-foreground: 0 0% 45.1%;
--accent: 0 0% 96.1%;
--accent-foreground: 0 0% 9%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 89.8%;
--input: 0 0% 89.8%;
--ring: 0 0% 3.9%;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
--radius: 0.5rem;
}
.dark {
--background: 0 0% 3.9%;
--foreground: 0 0% 98%;
--card: 0 0% 3.9%;
--card-foreground: 0 0% 98%;
--popover: 0 0% 3.9%;
--popover-foreground: 0 0% 98%;
--primary: 0 0% 98%;
--primary-foreground: 0 0% 9%;
--secondary: 0 0% 14.9%;
--secondary-foreground: 0 0% 98%;
--muted: 0 0% 14.9%;
--muted-foreground: 0 0% 63.9%;
--accent: 0 0% 14.9%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 14.9%;
--input: 0 0% 14.9%;
--ring: 0 0% 83.1%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}


.tiptap {
font-family: 'Arial', sans-serif;
line-height: 1.6;
color: var(--foreground);
}

.tiptap h1, .tiptap h2, .tiptap h3, .tiptap h4, .tiptap h5, .tiptap h6 {
font-weight: bold;
margin-top: 1.5em;
margin-bottom: 0.5em;
color: var(--primary-foreground);
}

.tiptap p {
margin-bottom: 1em;
}

.tiptap ul, .tiptap ol {
margin: 1em 0;
padding-left: 2em;
}

.tiptap ul li, .tiptap ol li {
margin-bottom: 0.5em;
}

.tiptap strong {
font-weight: bold;
color: var(--primary);
}

.tiptap em {
font-style: italic;
color: var(--secondary);
}

.tiptap u {
text-decoration: underline;
color: var(--accent);
}

.tiptap blockquote {
border-left: 4px solid var(--muted);
padding-left: 1em;
color: var(--muted-foreground);
margin: 1em 0;
}

.tiptap a {
color: var(--chart-1);
text-decoration: underline;
}

.tiptap img {
max-width: 100%;
height: auto;
margin: 1em 0;
}

.tiptap table {
width: 100%;
border-collapse: collapse;
margin: 1em 0;
}

.tiptap th, .tiptap td {
border: 1px solid var(--border);
padding: 0.5em;
text-align: left;
}

.tiptap th {
background-color: var(--muted);
color: var(--muted-foreground);
}

.tiptap code {
font-family: 'Courier New', monospace;
background-color: var(--input);
padding: 0.2em 0.4em;
border-radius: var(--radius);
}

.tiptap pre {
background-color: var(--input);
padding: 1em;
border-radius: var(--radius);
overflow-x: auto;
}

.tiptap hr {
border: none;
border-top: 1px solid var(--border);
margin: 2em 0;
}
97 changes: 3 additions & 94 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,100 +1,9 @@
import Image from "next/image";
import { ConsultantReportGeneratorComponent } from "@/components/consultant-report-generator";

export default function Home() {
return (
<div className="font-sans grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20">
<main className="flex flex-col gap-8 row-start-2 items-center sm:items-start">
<Image
className="dark:invert"
src="/next.svg"
alt="Next.js logo"
width={180}
height={38}
priority
/>
<ol className="font-mono list-inside list-decimal text-sm text-center sm:text-left">
<li className="mb-2">
Get started by editing{" "}
<code className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-semibold">
app/page.tsx
</code>
</li>
<li>Save and see your changes instantly.</li>
</ol>

<div className="flex gap-4 items-center flex-col sm:flex-row">
<a
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
className="dark:invert"
src="/vercel.svg"
alt="Vercel logomark"
width={20}
height={20}
/>
Deploy now
</a>
<a
className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Read our docs
</a>
</div>
</main>
<footer className="row-start-3 flex gap-6 flex-wrap items-center justify-center">
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="/file-text.svg"
alt="File icon"
width={16}
height={16}
/>
Learn
</a>
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="/window.svg"
alt="Window icon"
width={16}
height={16}
/>
Examples
</a>
<a
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
aria-hidden
src="/globe.svg"
alt="Globe icon"
width={16}
height={16}
/>
Go to nextjs.org →
</a>
</footer>
<div className="font-sans">
<ConsultantReportGeneratorComponent />
</div>
);
}
Binary file modified bun.lockb
Binary file not shown.
20 changes: 20 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "app/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
}
}
Loading

0 comments on commit c523445

Please sign in to comment.