feat: add frontend setup with Tailwind CSS

This commit is contained in:
eligrinfeld 2025-01-06 21:25:03 -07:00
parent 7fa0e9dd9d
commit 79f26fce25
28 changed files with 6724 additions and 520 deletions

41
frontend/.gitignore vendored Normal file
View file

@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# env files (can opt-in for committing if needed)
.env*
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

36
frontend/README.md Normal file
View file

@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

View file

@ -0,0 +1,16 @@
import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"),
];
export default eslintConfig;

13
frontend/next.config.js Normal file
View file

@ -0,0 +1,13 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
async rewrites() {
return [
{
source: '/api/:path*',
destination: 'http://localhost:3000/api/:path*',
},
]
}
}
module.exports = nextConfig

7
frontend/next.config.ts Normal file
View file

@ -0,0 +1,7 @@
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
};
export default nextConfig;

5848
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

33
frontend/package.json Normal file
View file

@ -0,0 +1,33 @@
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@radix-ui/react-icons": "^1.3.2",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^0.469.0",
"next": "15.1.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.1.3",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
}

View file

@ -0,0 +1,8 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
},
};
export default config;

1
frontend/public/file.svg Normal file
View file

@ -0,0 +1 @@
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>

After

Width:  |  Height:  |  Size: 391 B

View file

@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>

After

Width:  |  Height:  |  Size: 1 KiB

1
frontend/public/next.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 128 B

View file

@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>

After

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View file

@ -0,0 +1,76 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;
--radius: 0.5rem;
}
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}

View file

@ -0,0 +1,34 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});
const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});
export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
</body>
</html>
);
}

26
frontend/src/app/page.tsx Normal file
View file

@ -0,0 +1,26 @@
'use client'
import { ServerStatus } from "@/components/server-status"
import { SearchForm } from "@/components/search-form"
import { SearchResults } from "@/components/search-results"
import { useState } from "react"
export default function Home() {
const [searchResults, setSearchResults] = useState([])
const [isSearching, setIsSearching] = useState(false)
const services = [
{ name: "Ollama", status: "running" as const },
{ name: "SearxNG", status: "running" as const },
{ name: "Supabase", status: "running" as const }
]
return (
<main className="container mx-auto p-4">
<h1 className="text-4xl font-bold text-center mb-8">Business Search</h1>
<SearchForm onSearch={setSearchResults} onSearchingChange={setIsSearching} />
<SearchResults results={searchResults} isLoading={isSearching} />
<ServerStatus services={services} />
</main>
)
}

View file

@ -0,0 +1,79 @@
import { Search } from "lucide-react"
import { useState } from "react"
interface SearchFormProps {
onSearch: (results: any[]) => void;
onSearchingChange: (isSearching: boolean) => void;
}
export function SearchForm({ onSearch, onSearchingChange }: SearchFormProps) {
const [query, setQuery] = useState("")
const [error, setError] = useState<string | null>(null)
const handleSearch = async (e: React.FormEvent) => {
e.preventDefault()
if (!query.trim()) return
setError(null)
onSearchingChange(true)
try {
const response = await fetch("/api/search", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ query: query.trim() }),
})
if (!response.ok) {
throw new Error("Search failed")
}
const data = await response.json()
onSearch(data.results || [])
} catch (error) {
console.error("Search error:", error)
onSearch([])
setError("Failed to perform search. Please try again.")
} finally {
onSearchingChange(false)
}
}
return (
<div className="w-full max-w-2xl mx-auto mt-8 mb-12">
<div className="flex flex-col gap-4">
<div className="flex flex-col gap-2">
<label htmlFor="search" className="text-lg font-medium text-center">
Find local businesses
</label>
<form onSubmit={handleSearch} className="relative">
<input
id="search"
type="text"
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="e.g. plumbers in Denver, CO"
className="w-full px-4 py-3 text-lg rounded-lg border border-border bg-background focus:outline-none focus:ring-2 focus:ring-primary"
/>
<button
type="submit"
disabled={!query.trim()}
className="absolute right-2 top-1/2 -translate-y-1/2 p-3 rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
aria-label="Search"
>
<Search className="h-5 w-5" />
</button>
</form>
{error && (
<p className="text-sm text-destructive text-center">{error}</p>
)}
<p className="text-sm text-muted-foreground text-center mt-2">
Try searching for: restaurants, dentists, electricians, etc.
</p>
</div>
</div>
</div>
)
}

View file

@ -0,0 +1,76 @@
interface Business {
id: string;
name: string;
address: string;
phone: string;
website?: string;
email?: string;
description?: string;
rating?: number;
}
interface SearchResultsProps {
results: Business[];
isLoading: boolean;
}
export function SearchResults({ results, isLoading }: SearchResultsProps) {
if (isLoading) {
return (
<div className="w-full max-w-4xl mx-auto mt-8">
<div className="animate-pulse space-y-4">
{[...Array(3)].map((_, i) => (
<div key={i} className="bg-muted rounded-lg p-6">
<div className="h-4 bg-muted-foreground/20 rounded w-3/4 mb-4"></div>
<div className="h-3 bg-muted-foreground/20 rounded w-1/2"></div>
</div>
))}
</div>
</div>
)
}
if (!results.length) {
return null
}
return (
<div className="w-full max-w-4xl mx-auto mt-8">
<div className="space-y-4">
{results.map((business) => (
<div key={business.id} className="bg-card rounded-lg p-6 shadow-sm">
<h3 className="text-xl font-semibold mb-2">{business.name}</h3>
{business.address && (
<p className="text-muted-foreground mb-2">{business.address}</p>
)}
<div className="flex flex-wrap gap-4 text-sm">
{business.phone && (
<a
href={`tel:${business.phone}`}
className="text-primary hover:underline"
>
{business.phone}
</a>
)}
{business.website && (
<a
href={business.website}
target="_blank"
rel="noopener noreferrer"
className="text-primary hover:underline"
>
Visit Website
</a>
)}
</div>
{business.description && (
<p className="mt-4 text-sm text-muted-foreground">
{business.description}
</p>
)}
</div>
))}
</div>
</div>
)
}

View file

@ -0,0 +1,59 @@
import { CheckCircle2, XCircle, AlertCircle } from "lucide-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
interface ServiceStatus {
name: string
status: "running" | "error" | "warning"
}
interface ServerStatusProps {
services: ServiceStatus[]
error?: string
}
export function ServerStatus({ services, error }: ServerStatusProps) {
if (error) {
return (
<Alert variant="destructive" className="max-w-md mx-auto mt-4">
<XCircle className="h-4 w-4" />
<AlertTitle>Server Error</AlertTitle>
<AlertDescription>{error}</AlertDescription>
</Alert>
)
}
return (
<div className="space-y-4 max-w-md mx-auto mt-4">
<h2 className="text-xl font-semibold text-center mb-6">Service Status</h2>
<div className="space-y-3">
{services.map((service) => (
<Alert
key={service.name}
variant={service.status === "error" ? "destructive" : "default"}
className="flex items-center justify-between hover:bg-accent/50 transition-colors"
>
<div className="flex items-center gap-3">
{service.status === "running" && (
<CheckCircle2 className="h-5 w-5 text-green-500 shrink-0" />
)}
{service.status === "error" && (
<XCircle className="h-5 w-5 text-red-500 shrink-0" />
)}
{service.status === "warning" && (
<AlertCircle className="h-5 w-5 text-yellow-500 shrink-0" />
)}
<AlertTitle className="font-medium">{service.name}</AlertTitle>
</div>
<span className={`text-sm ${
service.status === "running" ? "text-green-600" :
service.status === "error" ? "text-red-600" :
"text-yellow-600"
}`}>
{service.status.charAt(0).toUpperCase() + service.status.slice(1)}
</span>
</Alert>
))}
</div>
</div>
)
}

View file

@ -0,0 +1,58 @@
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const alertVariants = cva(
"relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",
{
variants: {
variant: {
default: "bg-background text-foreground",
destructive:
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
},
},
defaultVariants: {
variant: "default",
},
}
)
const Alert = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
>(({ className, variant, ...props }, ref) => (
<div
ref={ref}
role="alert"
className={cn(alertVariants({ variant }), className)}
{...props}
/>
))
Alert.displayName = "Alert"
const AlertTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h5
ref={ref}
className={cn("mb-1 font-medium leading-none tracking-tight", className)}
{...props}
/>
))
AlertTitle.displayName = "AlertTitle"
const AlertDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("text-sm [&_p]:leading-relaxed", className)}
{...props}
/>
))
AlertDescription.displayName = "AlertDescription"
export { Alert, AlertTitle, AlertDescription }

View file

@ -0,0 +1,6 @@
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}

View file

@ -0,0 +1,79 @@
import type { Config } from "tailwindcss";
const config: Config = {
darkMode: ["class"],
content: [
'./pages/**/*.{ts,tsx}',
'./components/**/*.{ts,tsx}',
'./app/**/*.{ts,tsx}',
'./src/**/*.{ts,tsx}',
],
theme: {
container: {
center: true,
padding: "2rem",
screens: {
"2xl": "1400px",
},
},
extend: {
colors: {
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
keyframes: {
"accordion-down": {
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
},
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
},
},
},
plugins: [require("tailwindcss-animate")],
}
export default config;

27
frontend/tsconfig.json Normal file
View file

@ -0,0 +1,27 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}

6
postcss.config.js Normal file
View file

@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

View file

@ -1,557 +1,213 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en" class="h-full bg-gray-50">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OffMarket Pro - Find Off-Market Property Services</title> <title>OffMarket Pro - Business Search</title>
<style> <link href="/styles/output.css" rel="stylesheet">
:root { <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
--primary-color: #2c3e50;
--secondary-color: #3498db;
--accent-color: #e74c3c;
--background-color: #f8f9fa;
--text-color: #2c3e50;
--border-radius: 8px;
--card-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
body {
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
margin: 0;
padding: 0;
background: var(--background-color);
color: var(--text-color);
}
.header {
background: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
padding: 1rem;
}
.logo {
font-size: 1.8rem;
font-weight: bold;
color: var(--primary-color);
text-decoration: none;
}
.search-container {
max-width: 1200px;
margin: 3rem auto;
padding: 2rem;
text-align: center;
}
.search-box {
display: flex;
gap: 1rem;
max-width: 800px;
margin: 2rem auto;
}
.search-input {
flex: 1;
padding: 1rem;
border: 2px solid #ddd;
border-radius: var(--border-radius);
font-size: 1rem;
}
.search-button {
padding: 1rem 2rem;
background: var(--secondary-color);
color: white;
border: none;
border-radius: var(--border-radius);
cursor: pointer;
font-size: 1rem;
transition: background 0.2s;
}
.search-button:hover {
background: #2980b9;
}
.categories-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
margin: 2rem auto;
max-width: 1200px;
padding: 0 1rem;
}
.category-card {
background: white;
border-radius: var(--border-radius);
padding: 1.5rem;
box-shadow: var(--card-shadow);
transition: transform 0.2s;
cursor: pointer;
}
.category-card:hover {
transform: translateY(-2px);
}
.category-icon {
font-size: 2rem;
margin-bottom: 1rem;
}
.subcategories {
margin-top: 1rem;
font-size: 0.9rem;
}
.subcategory {
color: var(--secondary-color);
cursor: pointer;
margin: 0.25rem 0;
}
.subcategory:hover {
text-decoration: underline;
}
.results-container {
max-width: 1200px;
margin: 2rem auto;
padding: 0 1rem;
}
.business-card {
background: white;
padding: 1.5rem;
margin-bottom: 1rem;
border-radius: var(--border-radius);
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
display: grid;
grid-template-columns: auto 1fr auto;
gap: 1.5rem;
align-items: start;
}
.business-logo {
width: 80px;
height: 80px;
object-fit: cover;
border-radius: var(--border-radius);
}
.business-info h3 {
margin: 0 0 0.5rem 0;
color: var(--primary-color);
}
.business-contact {
text-align: right;
}
.rating-stars {
color: #f1c40f;
margin-bottom: 0.5rem;
}
@media (max-width: 768px) {
.search-box {
flex-direction: column;
}
.business-card {
grid-template-columns: 1fr;
text-align: center;
}
.business-contact {
text-align: center;
}
.business-logo {
margin: 0 auto;
}
}
.loading {
text-align: center;
padding: 2rem;
color: var(--text-color);
}
.error-message {
background: #fee;
border: 1px solid #fcc;
padding: 1rem;
border-radius: var(--border-radius);
text-align: center;
}
.no-results {
background: #f8f9fa;
padding: 2rem;
border-radius: var(--border-radius);
text-align: center;
}
.no-results ul {
text-align: left;
display: inline-block;
margin: 1rem auto;
}
.results-table {
width: 100%;
border-collapse: collapse;
margin-top: 2rem;
background: white;
box-shadow: var(--card-shadow);
border-radius: var(--border-radius);
overflow: hidden;
}
.results-table th {
background: #f8f9fa;
padding: 1rem;
text-align: left;
font-weight: 600;
color: var(--primary-color);
border-bottom: 2px solid #eee;
}
.results-table td {
padding: 1rem;
border-bottom: 1px solid #eee;
vertical-align: top;
}
.business-icon {
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
background: #f0f0f0;
border-radius: var(--border-radius);
font-size: 1.5rem;
color: var(--primary-color);
}
.business-info {
display: flex;
gap: 1rem;
align-items: start;
}
.business-details h3 {
margin: 0 0 0.5rem 0;
color: var(--primary-color);
}
.business-meta {
font-size: 0.9rem;
color: #666;
}
.rating {
display: flex;
align-items: center;
gap: 0.25rem;
color: #f39c12;
}
.contact-info {
text-align: right;
white-space: nowrap;
}
.phone {
font-weight: 600;
color: var(--primary-color);
margin-bottom: 0.25rem;
}
.address {
color: #666;
font-size: 0.9rem;
}
.action-buttons {
display: flex;
gap: 0.5rem;
justify-content: flex-end;
}
.action-button {
padding: 0.5rem 1rem;
border: none;
border-radius: var(--border-radius);
cursor: pointer;
font-size: 0.9rem;
}
.primary-button {
background: var(--secondary-color);
color: white;
}
.secondary-button {
background: #eee;
color: var(--text-color);
}
</style>
</head> </head>
<body> <body class="min-h-full">
<header class="header"> <div class="bg-white">
<a href="/" class="logo">OffMarket Pro</a> <!-- Navigation -->
</header> <nav class="bg-white shadow-sm">
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<div class="flex h-16 justify-between items-center">
<div class="flex-shrink-0 flex items-center">
<h1 class="text-xl font-bold text-gray-900">OffMarket Pro</h1>
</div>
</div>
</div>
</nav>
<div class="search-container"> <!-- Main Content -->
<h1>Find Off-Market Property Services</h1> <main class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-8">
<div class="search-box"> <!-- Search Form -->
<input type="text" id="searchQuery" placeholder="What service are you looking for?"> <div class="mb-8">
<input type="text" id="searchLocation" placeholder="Location"> <h2 class="text-2xl font-bold text-gray-900 mb-6">Find Off-Market Property Services</h2>
<button onclick="performSearch()">Search</button> <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
<div>
<label for="searchQuery" class="block text-sm font-medium text-gray-700">Service Type</label>
<input type="text" id="searchQuery" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary focus:ring-primary sm:text-sm" placeholder="e.g. plumber, electrician">
</div>
<div>
<label for="searchLocation" class="block text-sm font-medium text-gray-700">Location</label>
<input type="text" id="searchLocation" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary focus:ring-primary sm:text-sm" placeholder="e.g. Denver, CO">
</div>
</div>
<div class="mt-4">
<button onclick="performSearch()" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-primary hover:bg-primary-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Search
</button>
</div> </div>
</div> </div>
<div class="categories-grid"> <!-- Progress Indicator -->
<!-- Categories will be dynamically inserted here --> <div id="searchProgress" class="hidden mb-8">
<div class="bg-white shadow sm:rounded-lg">
<div class="px-4 py-5 sm:p-6">
<h3 class="text-lg font-medium leading-6 text-gray-900">Search Progress</h3>
<div class="mt-4">
<div class="relative pt-1">
<div class="overflow-hidden h-2 mb-4 text-xs flex rounded bg-gray-200">
<div id="progressBar" class="shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-primary transition-all duration-500" style="width: 0%"></div>
</div>
<div id="progressText" class="text-sm text-gray-600"></div>
</div>
</div>
</div>
</div>
</div> </div>
<div class="container"> <!-- Error Display -->
<table class="results-table"> <div id="errorDisplay" class="hidden mb-8">
<thead> <div class="rounded-md bg-red-50 p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-red-800">Error</h3>
<div class="mt-2 text-sm text-red-700">
<p id="errorMessage"></p>
</div>
</div>
</div>
</div>
</div>
<!-- Results Table -->
<div id="resultsContainer" class="hidden">
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
<div class="px-4 py-5 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">Search Results</h3>
</div>
<div class="border-t border-gray-200">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr> <tr>
<th style="width: 50%">Business</th> <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Business</th>
<th style="width: 30%">Contact</th> <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Contact</th>
<th style="width: 20%">Actions</th> <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr> </tr>
</thead> </thead>
<tbody id="resultsBody"> <tbody id="resultsBody" class="bg-white divide-y divide-gray-200">
<!-- Results will be populated here --> <!-- Results will be inserted here -->
</tbody> </tbody>
</table> </table>
<div id="searchProgress" class="search-progress"></div> </div>
</div>
</div>
</div>
</main>
</div> </div>
<script> <script>
// Load categories class SearchProgress {
fetch('/api/categories') constructor() {
.then(response => response.json()) this.progressBar = document.getElementById('progressBar');
.then(categories => { this.progressText = document.getElementById('progressText');
const grid = document.querySelector('.categories-grid'); this.container = document.getElementById('searchProgress');
grid.innerHTML = categories.map(category => ` }
<div class="category-card" onclick="searchCategory('${category.name}')">
<div class="category-icon">${category.icon}</div> show() {
<h3>${category.name}</h3> this.container.classList.remove('hidden');
<div class="subcategories"> this.setProgress(0, 'Starting search...');
${category.subcategories.map(sub => }
`<div class="subcategory" onclick="event.stopPropagation(); searchSubcategory('${sub.name}')">${sub.name}</div>`
).join('')} hide() {
</div> this.container.classList.add('hidden');
</div> }
`).join('');
}); setProgress(percent, message) {
this.progressBar.style.width = `${percent}%`;
this.progressText.textContent = message;
}
showError(message) {
this.setProgress(100, `Error: ${message}`);
this.progressBar.classList.remove('bg-primary');
this.progressBar.classList.add('bg-red-500');
}
}
async function performSearch() { async function performSearch() {
const query = document.getElementById('searchQuery').value; const query = document.getElementById('searchQuery').value;
const location = document.getElementById('searchLocation').value; const location = document.getElementById('searchLocation').value;
if (!query || !location) { if (!query || !location) {
alert('Please enter both search query and location'); showError('Please enter both search query and location');
return; return;
} }
await doSearch(query, location); const progress = new SearchProgress();
} progress.show();
function searchCategory(category) {
const location = document.getElementById('searchLocation').value;
if (!location) {
alert('Please enter a location first');
return;
}
document.getElementById('searchQuery').value = category;
performSearch();
}
// Add searchSubcategory function
function searchSubcategory(subcategory) {
const location = document.getElementById('searchLocation').value;
if (!location) {
alert('Please enter a location first');
return;
}
document.getElementById('searchQuery').value = subcategory;
performSearch();
}
// Update doSearch function
async function doSearch(query, location) {
const searchTerm = `${query} in ${location}`;
const resultsBody = document.getElementById('resultsBody');
const progressDiv = document.getElementById('searchProgress');
try { try {
resultsBody.innerHTML = ` document.getElementById('errorDisplay').classList.add('hidden');
<tr> document.getElementById('resultsContainer').classList.add('hidden');
<td colspan="3" class="loading">
<p>Searching for ${query} in ${location}...</p>
</td>
</tr>
`;
const response = await fetch(`/api/search?q=${encodeURIComponent(searchTerm)}`); const response = await fetch('/api/search', {
const reader = response.body.getReader(); method: 'POST',
const decoder = new TextDecoder(); headers: {
let buffer = ''; 'Content-Type': 'application/json',
let allResults = new Set(); // Use Set to avoid duplicates },
body: JSON.stringify({ query, location })
while (true) {
const { value, done } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
// Process complete chunks
const chunks = buffer.split('\n');
buffer = chunks.pop() || ''; // Keep the incomplete chunk
for (const chunk of chunks) {
if (!chunk.trim()) continue;
try {
const data = JSON.parse(chunk);
console.log('Received chunk:', data);
if (data.source === 'database' || (data.source === 'search' && data.results)) {
// Add new results to our set
data.results.forEach(result => {
allResults.add(JSON.stringify(result)); // Convert to string for Set storage
}); });
// Display all current results const data = await response.json();
displayResults(Array.from(allResults).map(str => JSON.parse(str)));
} else if (data.status && data.progress) { if (!data.success) {
// Update progress throw new Error(data.error || 'Search failed');
progressDiv.innerHTML = `
<p>${data.status} (${data.progress}% complete)</p>
`;
}
} catch (e) {
console.error('Error parsing chunk:', e);
}
}
} }
// Clear progress when done displayResults(data.results);
progressDiv.innerHTML = ''; progress.hide();
} catch (error) { } catch (error) {
console.error('Search error:', error); console.error('Search error:', error);
resultsBody.innerHTML = ` progress.showError(error.message);
<tr> showError(error.message);
<td colspan="3" class="error-message">
<h3>Search Error</h3>
<p>Sorry, we encountered an error while searching. Please try again.</p>
<p>Error details: ${error.message}</p>
<button onclick="performSearch()" class="search-button">Try Again</button>
</td>
</tr>
`;
} }
} }
function displayResults(businesses) { function showError(message) {
const resultsBody = document.getElementById('resultsBody'); const errorDisplay = document.getElementById('errorDisplay');
const errorMessage = document.getElementById('errorMessage');
if (!businesses || businesses.length === 0) { errorMessage.textContent = message;
resultsBody.innerHTML = ` errorDisplay.classList.remove('hidden');
<tr>
<td colspan="3" style="text-align: center; padding: 2rem;">
<h3>No Results Found</h3>
<p>We couldn't find any businesses matching your search.</p>
</td>
</tr>
`;
return;
} }
resultsBody.innerHTML = businesses.map(business => { function displayResults(results) {
const icon = getBusinessIcon(business.name); const container = document.getElementById('resultsContainer');
const rating = business.rating ? (business.rating / 20).toFixed(1) : 0; // Convert to 5-star scale const tbody = document.getElementById('resultsBody');
return ` tbody.innerHTML = results.map(business => `
<tr> <tr>
<td> <td class="px-6 py-4">
<div class="business-info"> <div class="text-sm font-medium text-gray-900">${business.name}</div>
<div class="business-icon">${icon}</div> <div class="text-sm text-gray-500">${business.description}</div>
<div class="business-details">
<h3>${business.name}</h3>
<div class="business-meta">
<div class="rating">
${getRatingStars(rating)}
<span>(${rating})</span>
</div>
<div class="description">${business.description || ''}</div>
</div>
</div>
</div>
</td> </td>
<td> <td class="px-6 py-4">
<div class="contact-info"> <div class="text-sm text-gray-900">${business.address}</div>
<div class="phone">${business.phone || 'No phone available'}</div> <div class="text-sm text-gray-500">${business.phone}</div>
<div class="address">${business.address || 'Address not available'}</div>
</div>
</td> </td>
<td> <td class="px-6 py-4">
<div class="action-buttons">
${business.website ? ${business.website ?
`<a href="${business.website}" target="_blank" class="action-button primary-button">Visit Website</a>` : `<a href="${business.website}" target="_blank"
'<button class="action-button secondary-button" disabled>No Website</button>' class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-white bg-primary hover:bg-primary-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
Visit Website
</a>` :
'<span class="text-sm text-gray-500">No website available</span>'
} }
<button onclick="contactBusiness('${business.id}')" class="action-button secondary-button">Contact</button>
</div>
</td> </td>
</tr> </tr>
`; `).join('');
}).join('');
}
// Helper function to get business icon container.classList.remove('hidden');
function getBusinessIcon(businessName) {
// Map of business types to icons
const icons = {
'real estate': '🏢',
'legal': '⚖️',
'financial': '💰',
'contractor': '🔨',
'property': '🏠',
'marketing': '📢',
'tech': '💻',
'default': '🏢'
};
// Determine business type from name
const businessType = Object.keys(icons).find(type =>
businessName.toLowerCase().includes(type)
) || 'default';
return icons[businessType];
}
// Helper function to generate rating stars
function getRatingStars(rating) {
const fullStars = Math.floor(rating);
const hasHalfStar = rating % 1 >= 0.5;
const emptyStars = 5 - fullStars - (hasHalfStar ? 1 : 0);
return `
${'★'.repeat(fullStars)}
${hasHalfStar ? '½' : ''}
${'☆'.repeat(emptyStars)}
`;
} }
</script> </script>
</body> </body>

3
src/styles/input.css Normal file
View file

@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

12
tailwind.config.js Normal file
View file

@ -0,0 +1,12 @@
module.exports = {
content: ['./public/**/*.{html,js}'],
theme: {
extend: {
colors: {
primary: '#2563eb',
'primary-hover': '#1d4ed8',
},
},
},
plugins: [],
}