How firecrawl/firegeo works
Project type and purpose
• This is a full-stack SaaS starter built on Next.js 15 + TypeScript.
• Key features: authentication (Better Auth), subscription billing (Autumn + Stripe), AI-driven chat, brand-monitoring with web scraping, PostgreSQL database, email notifications, and serverless API routes.
File structure
• app/
– Next.js App Router for both UI pages (app/login, app/chat, app/brand-monitor, etc.) and serverless API endpoints under app/api.
– API subdivisions:
· auth (Better Auth endpoints)
· autumn (billing endpoints)
· brand-monitor (analysis, scrape, web-search)
· chat (conversations, feedback)
· user, credits
• components/
– React UI components organized by domain (ui, autumn, brand-monitor, general).
• lib/
– Shared server-side logic: DB client (Drizzle), authentication client, API wrappers, AI-provider utilities, scraping utils, SSE parser, email.
• config/, scripts/, migrations/, drizzle.config.ts
– Configuration files, setup and migration scripts for DB, billing, auth.
• public/
– Static assets.
• next.config.ts, middleware.ts, etc.
– Framework configuration and global middleware for auth/session.
README for additional insights
• Tech Stack: Next.js, React, Tailwind CSS, Drizzle ORM, Better Auth, Autumn, Firecrawl, multiple AI providers, Resend email.
• Provides a high-level component breakdown under “Project Structure.”
• Describes environment variables required for each external integration.
a. Main Components
1. Client (Browser) – React pages in app/.
2. Next.js Server/API Layer – app/api routes & middleware.
3. Business Logic Layer – lib/ modules handling auth, DB, AI, billing, scraping, email.
4. Database – PostgreSQL via Drizzle ORM.
5. Authentication Service – Better Auth tables & endpoints.
6. Billing Service – Autumn + Stripe webhooks & API.
7. External AI Providers – OpenAI, Anthropic, Google Gemini, Perplexity.
8. Web Scraper – Firecrawl.
9. Email Service – Resend.
10. Drizzle Studio / Migration Scripts – migrations folder & drizzle.config.ts.
b. Relationships and Interactions
• Client → Next.js Router & Server Components for pages (login, dashboard, chat).
• Client → app/api/* routes over HTTPS for data operations.
• API Layer → lib/auth.ts for session validation.
• API Layer → lib/db.ts → PostgreSQL for CRUD.
• API Layer → lib/api-wrapper or lib/anthropic-web-search → AI providers.
• API Layer → lib/scrape-utils → Firecrawl.
• API Layer → lib/email → Resend for notifications.
• API Layer → better-auth migrations & endpoints for user management.
• API Layer → Autumn endpoints for billing actions → Stripe.
• Drizzle migration scripts → PostgreSQL schema versioning.
c. Architectural Patterns / Design Principles
• Monolithic “modular” architecture leveraging Next.js App Router with clear separation of UI (React components) and API (serverless functions).
• Layered architecture: Presentation (React), API layer (Next.js routes), Service layer (lib/), Data Access (Drizzle ORM), External integrations.
• Incremental adoption of feature domains: auth, billing, chat, brand-monitor.
• Infrastructure as code / migrations for database & auth.
d. Key Technologies & Frameworks
• Frontend: Next.js 15, React 19, Tailwind CSS, shadcn/ui.
• Backend/API: Next.js serverless routes, TypeScript.
• ORM: Drizzle ORM (drizzle.config.ts, lib/db/schema.ts).
• Auth: Better Auth + custom middleware (middleware.ts).
• Billing: Autumn SDK + Stripe.
• AI: OpenAI, Anthropic, Google Gemini, Perplexity via lib/providers.
• Scraping: Firecrawl.
• Email: Resend.
• Database: PostgreSQL.