Deepcrawl Documentation

repository·main·Indexed 20 days ago

https://github.com/lumpinif/deepcrawl

An open-source, agent-oriented web scraping platform designed to extract high-quality, LLM-ready data, including cleaned Markdown and hierarchical link trees, from public websites. The project includes a Next.js 16 and React 19 dashboard, a Cloudflare Workers-based Auth Worker powered by Better Auth, and a Deepcrawl API Worker (v0) featuring oRPC and REST endpoints.

Tokens
73.3K
Snippets
244
Records
345
Agent score
68%

What's inside deepcrawl

  1. Overview of Deepcrawl Auth Worker features

    main

    The Deepcrawl Auth Worker is an authentication service powered by Better Auth and Cloudflare Workers. It provides several key capabilities:

    Authentication Methods

    • OAuth Providers: GitHub and Google integration.
    • Passkeys: WebAuthn passwordless authentication.
    • Magic Links: Email-based login.
    • Email Verification: Account verification flows.
    • Password Reset: Password recovery.

    Session Management

    • Multi-Session Support: Supports up to 2 concurrent sessions per user.
    • Cross-Domain Cookies: Functional across deepcrawl.dev subdomains.
    • API Key Authentication: The primary method for API access.
    • Cookie Fallback: Used for Dashboard authentication.
    • Secure Headers: Includes CSRF protection and security headers.

    Email System

    • Universal Email Support: Compatible with both Workers and Next.js.
    • HTML Templates: Uses React components for email designs.
    • Resend Integration: Uses Resend for email delivery.
    • Organization Invitations: Includes a team invitation system.

    Infrastructure

    • Service Bindings: Communicates with the main Deepcrawl worker.
    • Rate Limiting: Protects against abuse.
    • Database: Uses PostgreSQL with Drizzle ORM.
  2. Overview of Deepcrawl

    main

    Deepcrawl is an agent-oriented website data context extraction platform designed for high-frequency agent workloads. Unlike tools focused on bypassing anti-bot measures, Deepcrawl is optimized to scrape public pages and transform them into LLM-friendly formats.

    Key outputs include:

    • Cleaned Markdown: Page content converted to markdown to minimize token costs.
    • Hierarchical Links Tree: An agent-favored structure of links for easier navigation.
    • Metadata: Structured data designed to reduce context switching and hallucinations in LLMs.

    WARNING: The project is under rapid development and is subject to change. It is not currently recommended for production use.

  3. Overview of the create-deepcrawl CLI scope

    main

    The create-deepcrawl CLI is a scaffolding tool designed to provision Cloudflare resources, write configuration, and deploy Deepcrawl components in a single guided flow.

    Currently, the CLI focuses on the V0 API Worker only (running on Cloudflare Workers) with authentication set to either none or jwt.

    Upon successful deployment, the CLI provides:

    1. The Worker URL.
    2. A link to documentation.
    3. The locations of two secret files (apps/workers/v0/.dev.vars and apps/workers/v0/.dev.vars.production) which contain the JWT_SECRET.
    4. A summary of provisioned resources.
    5. An option to run an immediate test, which auto-mints a 15-minute token (if JWT is required) and prints a copyable curl command for testing the API.
  4. Overview of @deepcrawl/types

    main

    The @deepcrawl/types package provides TypeScript types and Zod schemas used throughout the Deepcrawl API ecosystem. It ensures type-safe contracts between clients and servers and provides runtime validation for API requests and responses.

    Key Features:

    • Runtime validation: Zod schemas for validating API requests and responses.
    • Type-safe contracts: Shared types used across both client and server implementations.
    • oRPC integration: Type definitions specifically for oRPC endpoints.
    • Service schemas: Validation schemas for all core Deepcrawl services.
    • Configuration types: Definitions for environment and configuration settings.
  5. Introduction to Deepcrawl

    main

    Deepcrawl is an open-source, agents-oriented web page context extraction platform designed to make website data AI-ready. It converts messy web pages into cleaned markdown, agent-navigable link trees, and page metadata to reduce token costs and hallucinations in LLM prompts.

    Warning: Deepcrawl is under active development. All APIs and SDKs are subject to change. Use at your own risk.

    Key Capabilities

    • Markdown Extraction: Compresses web content into structured markdown optimized for LLM consumption.
    • Link Mapping: Maps domain link topologies so agent workflows can understand site structure before browsing.
    • Type-Safe Integration: Provides production-ready APIs and SDKs designed to feel native within agent frameworks like ai-sdk.
  6. Use @deepcrawl/contracts for type-safe API definitions

    main
    The @deepcrawl/contracts package provides type-safe API contract definitions for oRPC endpoints used throughout the Deepcrawl ecosystem. It ensures consistent interfaces, input/output validation schemas, and standardized error types between clients and servers.
  7. How @deepcrawl/types ensures ecosystem consistency

    main

    The @deepcrawl/types package acts as the central source of truth for the entire Deepcrawl ecosystem. It provides unified type definitions to maintain consistency across four key layers:

    1. oRPC contracts: Ensures type-safe API definitions.
    2. Service implementations: Provides types for business logic validation.
    3. Client libraries: Guarantees type safety within SDKs.
    4. Database schemas: Maintains consistency for data models.
  8. Understand the Deepcrawl Architecture

    main

    Deepcrawl is a pnpm + Turbo monorepo designed to keep the dashboard, Workers, and SDKs in sync. The architecture is divided into three main areas:

    • Apps and Workers: Contains the user-facing Next.js dashboard (apps/app) and the core Cloudflare Workers (apps/workers/auth for authentication and apps/workers/v0 for crawl jobs/queues).
    • Shared Packages: Contains the logic used by both apps and workers, including packages/auth (session/token helpers), packages/contracts (oRPC definitions for type-safe API calls), packages/db (Prisma clients and migrations), and packages/sdks/js-ts (the public TypeScript SDK).
    • Tooling: Uses Turborepo for optimized builds and Biome for linting and formatting.

    By using shared oRPC contracts in packages/contracts, every API call between the dashboard, Workers, and the SDK remains type-safe.

  9. Understand the GetOneLogResponse structure

    main

    The GetOneLogResponse object contains metadata about the request and the resulting payload. The response field's shape depends on the path value:

    • read-getMarkdown: response is the markdown string or GetMarkdownResponse (string).
    • read-readUrl: response narrows to ReadUrlResponse.
    • links-getLinks / links-extractLinks: response narrows to GetLinksResponse or ExtractLinksResponse respectively.

    Example JSON Response

    {
      "id": "log_123",
      "path": "read-readUrl",
      "success": true,
      "requestOptions": {
        "url": "https://example.com",
        "markdown": true
      },
      "response": {
        "markdown": "# Example Page",
        "links": ["https://example.com/about"]
      },
      "requestTimestamp": "2025-01-10T14:20:00.000Z"
    }
  10. Use Conventional Commits for scoped messages

    main

    Deepcrawl uses scoped Conventional Commits following the pattern: <scope>[:subscope]:<type> message.

    Examples:

    • app:feat add job status badge to dashboard
    • pkg:ui:fix correct Button loading state
    • workers:v0:chore add queue retries
    • scripts:ref log slow routes

    Guidelines:

    • Keep the subject line $\le$ 72 characters and use the imperative mood.
    • Reference issues (e.g., #123) in the body when relevant.
    <scope>[:subscope]:<type> message
  11. Understand the Deepcrawl D1 Database Architecture

    main

    The Deepcrawl D1 database uses a two-table architecture designed to separate lightweight activity logging from heavy response storage. This separation enables fast analytics while maintaining storage efficiency through content deduplication.

    Core Components:

    1. activity_log: A lightweight table that tracks every API request. It stores metadata, performance metrics (like executionTimeMs), and a responseHash that links to the actual content.
    2. response_record: A storage table for deduplicated response payloads. Instead of storing the same response multiple times, it stores unique content once, indexed by a responseHash.

    Key Benefits:

    • Deduplication: Identical responses are stored only once in response_record, significantly reducing storage costs.
    • Query Performance: The activity_log is optimized for fast timeline and analytics queries. Full response content is only retrieved via a JOIN when explicitly requested.
    • Scalability: The generic path format ({endpoint}-{method}) allows the schema to support new endpoints without requiring database migrations.