diff --git a/freelance-assistant/.gitignore b/freelance-assistant/.gitignore new file mode 100644 index 000000000000..5ef6a5207802 --- /dev/null +++ b/freelance-assistant/.gitignore @@ -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 diff --git a/freelance-assistant/README.md b/freelance-assistant/README.md new file mode 100644 index 000000000000..8019e9ab03fc --- /dev/null +++ b/freelance-assistant/README.md @@ -0,0 +1,42 @@ +# Freelance Assistant + +A Next.js + TypeScript app to scrape jobs, generate proposals with OpenAI, apply, and track follow-ups. + +## Setup + +1. Copy env template + +```bash +cp .env.local.example .env.local +``` + +2. Fill in `.env.local` values +- Firebase client (web app) keys +- Firebase Admin credentials (Service Account) +- OpenAI API key +- Optional OAuth creds for Upwork/Freelancer and Apify token + +3. Firebase +- Create a Firebase project +- Enable Authentication (Email/Password and Google) +- Create a Web App to obtain client config +- Create a Service Account key and paste into env + +4. Install and run + +```bash +npm i +npm run dev +``` + +Open http://localhost:3000 + +## Features +- Email/Google sign-in +- Scrape jobs from a URL (basic, extend selectors for platforms) +- Generate proposals via OpenAI +- Save proposals, update status, set follow-up dates + +## Notes +- Upwork/Freelancer APIs are not yet wired. Add OAuth at `src/app/api/oauth/*` (stubs TBD) and job/proposal endpoints once credentials and scopes are confirmed. +- Scraping public pages may violate platform ToS. Prefer official APIs. diff --git a/freelance-assistant/eslint.config.mjs b/freelance-assistant/eslint.config.mjs new file mode 100644 index 000000000000..c85fb67c463f --- /dev/null +++ b/freelance-assistant/eslint.config.mjs @@ -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; diff --git a/freelance-assistant/next.config.ts b/freelance-assistant/next.config.ts new file mode 100644 index 000000000000..e9ffa3083ad2 --- /dev/null +++ b/freelance-assistant/next.config.ts @@ -0,0 +1,7 @@ +import type { NextConfig } from "next"; + +const nextConfig: NextConfig = { + /* config options here */ +}; + +export default nextConfig; diff --git a/freelance-assistant/package.json b/freelance-assistant/package.json new file mode 100644 index 000000000000..a84afd4028ea --- /dev/null +++ b/freelance-assistant/package.json @@ -0,0 +1,36 @@ +{ + "name": "freelance-assistant", + "version": "0.1.0", + "private": true, + "scripts": { + "dev": "next dev --turbopack", + "build": "next build", + "start": "next start", + "lint": "next lint" + }, + "dependencies": { + "apify-client": "^2.13.0", + "axios": "^1.11.0", + "cheerio": "^1.1.2", + "date-fns": "^4.1.0", + "firebase": "^12.1.0", + "firebase-admin": "^13.4.0", + "next": "15.4.6", + "openai": "^5.12.2", + "react": "19.1.0", + "react-dom": "19.1.0", + "uuid": "^11.1.0", + "zod": "^3.25.76" + }, + "devDependencies": { + "@eslint/eslintrc": "^3", + "@tailwindcss/postcss": "^4", + "@types/node": "^20", + "@types/react": "^19", + "@types/react-dom": "^19", + "eslint": "^9", + "eslint-config-next": "15.4.6", + "tailwindcss": "^4", + "typescript": "^5" + } +} diff --git a/freelance-assistant/postcss.config.mjs b/freelance-assistant/postcss.config.mjs new file mode 100644 index 000000000000..c7bcb4b1ee14 --- /dev/null +++ b/freelance-assistant/postcss.config.mjs @@ -0,0 +1,5 @@ +const config = { + plugins: ["@tailwindcss/postcss"], +}; + +export default config; diff --git a/freelance-assistant/public/file.svg b/freelance-assistant/public/file.svg new file mode 100644 index 000000000000..004145cddf3f --- /dev/null +++ b/freelance-assistant/public/file.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/freelance-assistant/public/globe.svg b/freelance-assistant/public/globe.svg new file mode 100644 index 000000000000..567f17b0d7c7 --- /dev/null +++ b/freelance-assistant/public/globe.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/freelance-assistant/public/next.svg b/freelance-assistant/public/next.svg new file mode 100644 index 000000000000..5174b28c565c --- /dev/null +++ b/freelance-assistant/public/next.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/freelance-assistant/public/vercel.svg b/freelance-assistant/public/vercel.svg new file mode 100644 index 000000000000..77053960334e --- /dev/null +++ b/freelance-assistant/public/vercel.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/freelance-assistant/public/window.svg b/freelance-assistant/public/window.svg new file mode 100644 index 000000000000..b2b2a44f6ebc --- /dev/null +++ b/freelance-assistant/public/window.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/freelance-assistant/src/app/(auth)/login/page.tsx b/freelance-assistant/src/app/(auth)/login/page.tsx new file mode 100644 index 000000000000..49bb90179ef5 --- /dev/null +++ b/freelance-assistant/src/app/(auth)/login/page.tsx @@ -0,0 +1,77 @@ +"use client"; + +import { FormEvent, useEffect, useState } from 'react'; +import { GoogleAuthProvider, createUserWithEmailAndPassword, signInWithEmailAndPassword, signInWithPopup } from 'firebase/auth'; + +export default function LoginPage() { + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [error, setError] = useState(null); + const [isReady, setIsReady] = useState(false); + + useEffect(() => { + (async () => { + const { getEnv } = await import('@/lib/env'); + const env = getEnv(); + setIsReady(env.isConfigured); + })(); + }, []); + + async function handleEmailSignUp(e: FormEvent) { + e.preventDefault(); + setError(null); + try { + const { getFirebaseClientServices } = await import('@/lib/firebase-client'); + const { auth } = getFirebaseClientServices(); + await createUserWithEmailAndPassword(auth, email, password); + } catch (e: unknown) { + const message = e instanceof Error ? e.message : 'Sign up failed'; + setError(message); + } + } + + async function handleEmailSignIn(e: FormEvent) { + e.preventDefault(); + setError(null); + try { + const { getFirebaseClientServices } = await import('@/lib/firebase-client'); + const { auth } = getFirebaseClientServices(); + await signInWithEmailAndPassword(auth, email, password); + } catch (e: unknown) { + const message = e instanceof Error ? e.message : 'Sign in failed'; + setError(message); + } + } + + async function handleGoogle() { + const { getFirebaseClientServices } = await import('@/lib/firebase-client'); + const { auth } = getFirebaseClientServices(); + const provider = new GoogleAuthProvider(); + await signInWithPopup(auth, provider); + } + + if (!isReady) { + return ( +
+

App not configured. Add environment variables to enable authentication.

+
+ ); + } + + return ( +
+

Login / Sign up

+ +
+
+ setEmail(e.target.value)} /> + setPassword(e.target.value)} /> +
+ + +
+
+ {error &&

{error}

} +
+ ); +} \ No newline at end of file diff --git a/freelance-assistant/src/app/api/proposal/route.ts b/freelance-assistant/src/app/api/proposal/route.ts new file mode 100644 index 000000000000..9e3d868764bc --- /dev/null +++ b/freelance-assistant/src/app/api/proposal/route.ts @@ -0,0 +1,28 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { z } from 'zod'; +import { generateProposal } from '@/lib/openai'; + +const BodySchema = z.object({ + freelancerType: z.string().min(1), + jobTitle: z.string().min(1), + jobDescription: z.string().min(1), + budget: z.string().optional(), + freelancerProfileSummary: z.string().optional(), + preferredRate: z.string().optional(), +}); + +export async function POST(req: NextRequest) { + try { + const body = await req.json(); + const parsed = BodySchema.safeParse(body); + if (!parsed.success) { + return NextResponse.json({ error: 'Invalid payload', details: parsed.error.flatten() }, { status: 400 }); + } + + const text = await generateProposal(parsed.data); + return NextResponse.json({ proposal: text }); + } catch (error: unknown) { + console.error('Proposal error', error); + return NextResponse.json({ error: 'Failed to generate proposal' }, { status: 500 }); + } +} \ No newline at end of file diff --git a/freelance-assistant/src/app/api/proposals/list/route.ts b/freelance-assistant/src/app/api/proposals/list/route.ts new file mode 100644 index 000000000000..5d127a05c5e8 --- /dev/null +++ b/freelance-assistant/src/app/api/proposals/list/route.ts @@ -0,0 +1,20 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { getFirebaseAdmin } from '@/lib/firebase-admin'; +import { verifyAuthToken } from '@/lib/auth'; + +export async function GET(req: NextRequest) { + const authz = req.headers.get('authorization') || undefined; + const decoded = await verifyAuthToken(authz); + if (!decoded) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + + const { firestore } = getFirebaseAdmin(); + const snap = await firestore + .collection('proposals') + .where('uid', '==', decoded.uid) + .orderBy('createdAt', 'desc') + .limit(100) + .get(); + + const items = snap.docs.map((d) => ({ id: d.id, ...d.data() })); + return NextResponse.json({ proposals: items }); +} \ No newline at end of file diff --git a/freelance-assistant/src/app/api/proposals/save/route.ts b/freelance-assistant/src/app/api/proposals/save/route.ts new file mode 100644 index 000000000000..7baa48e28360 --- /dev/null +++ b/freelance-assistant/src/app/api/proposals/save/route.ts @@ -0,0 +1,42 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { z } from 'zod'; +import { getFirebaseAdmin } from '@/lib/firebase-admin'; +import { verifyAuthToken } from '@/lib/auth'; + +const BodySchema = z.object({ + jobTitle: z.string().min(1), + jobUrl: z.string().url().optional(), + source: z.string().optional(), + proposal: z.string().min(1), + status: z.enum(['draft','sent','pending','accepted','rejected']).default('draft').optional(), + followUpAt: z.string().datetime().optional(), +}); + +export async function POST(req: NextRequest) { + const authz = req.headers.get('authorization') || undefined; + const decoded = await verifyAuthToken(authz); + if (!decoded) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + + const body = await req.json(); + const parsed = BodySchema.safeParse(body); + if (!parsed.success) { + return NextResponse.json({ error: 'Invalid payload', details: parsed.error.flatten() }, { status: 400 }); + } + + const { firestore } = getFirebaseAdmin(); + const now = new Date(); + const doc = { + uid: decoded.uid, + jobTitle: parsed.data.jobTitle, + jobUrl: parsed.data.jobUrl || null, + source: parsed.data.source || null, + proposal: parsed.data.proposal, + status: parsed.data.status || 'draft', + followUpAt: parsed.data.followUpAt || null, + createdAt: now.toISOString(), + updatedAt: now.toISOString(), + }; + + const ref = await firestore.collection('proposals').add(doc); + return NextResponse.json({ id: ref.id, ...doc }); +} \ No newline at end of file diff --git a/freelance-assistant/src/app/api/proposals/update/route.ts b/freelance-assistant/src/app/api/proposals/update/route.ts new file mode 100644 index 000000000000..dab698496511 --- /dev/null +++ b/freelance-assistant/src/app/api/proposals/update/route.ts @@ -0,0 +1,43 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { z } from 'zod'; +import { getFirebaseAdmin } from '@/lib/firebase-admin'; +import { verifyAuthToken } from '@/lib/auth'; +import type { firestore as AdminFirestore } from 'firebase-admin'; + +const BodySchema = z.object({ + id: z.string().min(1), + status: z.enum(['draft','sent','pending','accepted','rejected']).optional(), + followUpAt: z.string().datetime().nullable().optional(), +}); + +type ProposalUpdate = { + updatedAt: string; + status?: 'draft' | 'sent' | 'pending' | 'accepted' | 'rejected'; + followUpAt?: string | null; +}; + +export async function POST(req: NextRequest) { + const authz = req.headers.get('authorization') || undefined; + const decoded = await verifyAuthToken(authz); + if (!decoded) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + + const body = await req.json(); + const parsed = BodySchema.safeParse(body); + if (!parsed.success) { + return NextResponse.json({ error: 'Invalid payload', details: parsed.error.flatten() }, { status: 400 }); + } + + const { firestore } = getFirebaseAdmin(); + const ref = firestore.collection('proposals').doc(parsed.data.id); + const doc = await ref.get(); + if (!doc.exists || doc.data()?.uid !== decoded.uid) { + return NextResponse.json({ error: 'Not found' }, { status: 404 }); + } + + const update: ProposalUpdate = { updatedAt: new Date().toISOString() }; + if (parsed.data.status) update.status = parsed.data.status; + if ('followUpAt' in parsed.data) update.followUpAt = parsed.data.followUpAt ?? null; + + await ref.update(update as AdminFirestore.UpdateData); + return NextResponse.json({ ok: true }); +} \ No newline at end of file diff --git a/freelance-assistant/src/app/api/scrape/route.ts b/freelance-assistant/src/app/api/scrape/route.ts new file mode 100644 index 000000000000..60f82705124d --- /dev/null +++ b/freelance-assistant/src/app/api/scrape/route.ts @@ -0,0 +1,21 @@ +import { NextRequest, NextResponse } from 'next/server'; +import { z } from 'zod'; +import { scrapeJobsFromUrl } from '@/lib/scraper'; + +const BodySchema = z.object({ url: z.string().url() }); + +export async function POST(req: NextRequest) { + try { + const body = await req.json(); + const parsed = BodySchema.safeParse(body); + if (!parsed.success) { + return NextResponse.json({ error: 'Invalid payload', details: parsed.error.flatten() }, { status: 400 }); + } + + const jobs = await scrapeJobsFromUrl(parsed.data.url); + return NextResponse.json({ jobs }); + } catch (error: unknown) { + console.error('Scrape error', error); + return NextResponse.json({ error: 'Failed to scrape jobs' }, { status: 500 }); + } +} \ No newline at end of file diff --git a/freelance-assistant/src/app/dashboard/page.tsx b/freelance-assistant/src/app/dashboard/page.tsx new file mode 100644 index 000000000000..d9e36fce6f8d --- /dev/null +++ b/freelance-assistant/src/app/dashboard/page.tsx @@ -0,0 +1,24 @@ +export default function DashboardPage() { + return ( +
+

Dashboard

+
+
+

Active Jobs

+

Scrape jobs from your platforms and see them here.

+ Go to Scraping +
+
+

Proposals

+

Generate and track your proposals.

+ View Proposals +
+
+

Follow-ups

+

Set reminders for follow-ups.

+ Tracking +
+
+
+ ); +} \ No newline at end of file diff --git a/freelance-assistant/src/app/favicon.ico b/freelance-assistant/src/app/favicon.ico new file mode 100644 index 000000000000..718d6fea4835 Binary files /dev/null and b/freelance-assistant/src/app/favicon.ico differ diff --git a/freelance-assistant/src/app/globals.css b/freelance-assistant/src/app/globals.css new file mode 100644 index 000000000000..a2dc41ecee5e --- /dev/null +++ b/freelance-assistant/src/app/globals.css @@ -0,0 +1,26 @@ +@import "tailwindcss"; + +:root { + --background: #ffffff; + --foreground: #171717; +} + +@theme inline { + --color-background: var(--background); + --color-foreground: var(--foreground); + --font-sans: var(--font-geist-sans); + --font-mono: var(--font-geist-mono); +} + +@media (prefers-color-scheme: dark) { + :root { + --background: #0a0a0a; + --foreground: #ededed; + } +} + +body { + background: var(--background); + color: var(--foreground); + font-family: Arial, Helvetica, sans-serif; +} diff --git a/freelance-assistant/src/app/layout.tsx b/freelance-assistant/src/app/layout.tsx new file mode 100644 index 000000000000..5af6640d8346 --- /dev/null +++ b/freelance-assistant/src/app/layout.tsx @@ -0,0 +1,37 @@ +import type { Metadata } from "next"; +import { Geist, Geist_Mono } from "next/font/google"; +import "./globals.css"; +import { AuthProvider } from "@/components/AuthProvider"; +import Nav from "@/components/Nav"; + +const geistSans = Geist({ + variable: "--font-geist-sans", + subsets: ["latin"], +}); + +const geistMono = Geist_Mono({ + variable: "--font-geist-mono", + subsets: ["latin"], +}); + +export const metadata: Metadata = { + title: "Freelance Assistant", + description: "Automate proposals and track freelance applications", +}; + +export default function RootLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + return ( + + + +