# lobo017/metacrawler architecture

> Architecture diagram of the GitHub repository lobo017/metacrawler, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lobo017/metacrawler
- Repository: https://github.com/lobo017/metacrawler

## Overview

1. **Overall shape**  
   MetaCrawler is a **polyglot, service-oriented scraping platform**. The repo is split into a browser UI, a central GraphQL gateway, and three execution backends specialized for different workload types: **Go for fast static crawling**, **Node.js for browser automation**, and **Python for NLP / RAG / async orchestration**.

2. **User-facing layer: `frontend/`**  
   The frontend is a **Next.js dashboard** used for workspace management, job control, analytics, and chat-style interaction. Components like `Dashboard`, `JobController`, `AnalyticsChart`, and the chat modals suggest the UI is mainly an **operations console** rather than a content site. Its only architectural dependency is the API layer.

3. **API boundary: `api-gateway/`**  
   The gateway is the **system’s single entry point**. It exposes a **GraphQL schema** (`schema.graphql`) and resolver layer (`resolvers.js`) on Node.js/Apollo, with tests for the resolver contract. This layer is where frontend requests are unified and where job submission, status lookup, and orchestration logic are concentrated.

4. **Gateway role in the data flow**  
   The gateway acts as the **control plane**: it accepts a job request, assigns/returns an identifier, forwards work to the right backend, and provides a stable API for the frontend. The README also describes a **webhook callback path** for long-running work, so the gateway is not just a proxy—it also receives asynchronous completion updates.

5. **Python intelligence service: `backend-python/`**  
   This service is the **semantic enrichment and knowledge layer**. It includes:
   - `app/nlp/processor.py` and `site_qa.py` for NLP and site-aware question answering
   - `app/unified_rag.py` for local retrieval-augmented generation over crawled content
   - `app/scrapers/` for crawl-oriented helpers
   - `celery_worker.py` for asynchronous task execution  
   This backend is the natural place for **long-running jobs** and **post-processing** of scraped data.

6. **Python execution model**  
   The presence of **Celery** indicates the Python backend is designed for **background jobs**, not just synchronous HTTP responses. The README’s lifecycle model (`queued -> running -> done/failed`) and webhook updates fit this service well: it can process work, then notify the gateway when complete.

7. **Go extraction engine: `backend-go/`**  
   The Go service is the **high-throughput crawler/extractor** optimized for static pages. Its `internal/scraper/` package contains `crawler.go` and `engine.go`, and `internal/queue/consumer.go` suggests it can **consume jobs from a queue**. This is the lowest-overhead data extraction path in the system.

8. **Node automation service: `backend-node/`**  
   This backend is the **dynamic browsing layer**. Its `src/scrapers/browser.js` and Playwright-oriented setup indicate it handles pages that require **JavaScript execution, browser state, or interactive flows**. This service fills the gap where Go-style HTTP scraping is insufficient.

9. **Primary data flow across services**  
   The typical flow is:  
   **Frontend → GraphQL gateway → chosen backend (Go/Python/Node) → results/status back to gateway → frontend refreshes/visualizes**.  
   Static scraping prefers Go, dynamic rendering prefers Node, and enrichment/knowledge-building flows through Python. The gateway keeps these execution paths unified for the UI.

10. **Operational state and caching**  
   The README describes **Redis** as the message broker and **MongoDB** as persistent storage, with deterministic deduplication based on request parameters. Architecturally, that means jobs are **addressed by identity**, queued asynchronously, and reused when possible rather than recomputed.

11. **Deployment boundary**  
   Each service has its own `Dockerfile`, and the root `docker-compose.yml` ties them together. This is a **container-first, locally composable deployment** with separate runtime images for frontend, gateway, and each backend. The `.github/workflows/ci.yml` file shows the repo also has **multi-service CI**.

12. **Testing and service isolation**  
   Tests are intentionally split by service boundary: GraphQL resolver tests in the gateway, crawler tests in Go, and resilience/knowledge tests in Python. That separation reinforces the architecture: each backend owns its own domain logic and can be validated independently.

13. **Notable architectural constraint**  
   The repo is not a monolith with a single scraping pipeline. It is a **router plus specialized workers** system. The important diagram should show the gateway as the center, with the frontend on one side and three independent execution backends on the other, plus shared infrastructure for queueing, caching, and persistence.

Main entry points: [`api-gateway/resolvers.js`](https://github.com/lobo017/metacrawler/blob/main/api-gateway/resolvers.js) (Resolvers), [`backend-python/celery_worker.py`](https://github.com/lobo017/metacrawler/blob/main/backend-python/celery_worker.py) (Celery Worker), [`docker-compose.yml`](https://github.com/lobo017/metacrawler/blob/main/docker-compose.yml) (Compose Stack), [`api-gateway/index.js`](https://github.com/lobo017/metacrawler/blob/main/api-gateway/index.js) (Gateway Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_ui["Dashboard UI<br/>Next.js console<br/>[Dashboard.jsx]"]
  node_frontend_jobs["Job Control<br/>UI controller<br/>[JobController.jsx]"]
  node_frontend_chat["Chat Modals<br/>UI chat<br/>[ChatModal.jsx]"]
end

subgraph group_gateway["API Gateway"]
  node_gateway_schema["GraphQL Schema<br/>GraphQL contract<br/>[schema.graphql]"]
  node_gateway_resolvers["Resolvers<br/>[resolvers.js]"]
  node_gateway_entry["Gateway Server<br/>Node service<br/>[index.js]"]
end

subgraph group_go["Go Backend"]
  node_go_engine["Crawler Engine<br/>Go extractor<br/>[engine.go]"]
  node_go_crawler["Crawler Core<br/>Go crawler<br/>[crawler.go]"]
  node_go_consumer["Queue Consumer<br/>Go worker<br/>[consumer.go]"]
end

subgraph group_node["Node Backend"]
  node_node_browser["Browser Scraper<br/>Playwright scraper<br/>[browser.js]"]
  node_node_entry["Node Worker<br/>Node service<br/>[index.js]"]
end

subgraph group_python["Python Backend"]
  node_python_nlp["NLP Processor<br/>Python NLP<br/>[processor.py]"]
  node_python_rag["Unified RAG<br/>Python retrieval<br/>[unified_rag.py]"]
  node_python_worker["Celery Worker<br/>Python worker<br/>[celery_worker.py]"]
  node_python_crawler["Site Crawler<br/>Python scraper<br/>[site_crawler.py]"]
end

subgraph group_infra["Shared Infra"]
  node_redis[("Redis<br/>broker<br/>[docker-compose.yml]")]
  node_mongo[("MongoDB<br/>persistence<br/>[docker-compose.yml]")]
  node_compose["Compose Stack<br/>deployment<br/>[docker-compose.yml]"]
end

node_frontend_ui -->|"API calls"| node_gateway_entry
node_frontend_jobs -->|"submit/status"| node_gateway_resolvers
node_frontend_chat -->|"chat requests"| node_gateway_resolvers
node_gateway_entry -->|"serves"| node_gateway_schema
node_gateway_entry -->|"executes"| node_gateway_resolvers
node_gateway_resolvers -->|"static jobs"| node_go_consumer
node_gateway_resolvers -->|"dynamic jobs"| node_node_browser
node_gateway_resolvers -->|"enrichment jobs"| node_python_worker
node_gateway_resolvers -->|"enqueue"| node_redis
node_gateway_resolvers -->|"persist"| node_mongo
node_go_consumer -->|"consume"| node_go_engine
node_go_engine -->|"crawl"| node_go_crawler
node_node_entry -->|"run"| node_node_browser
node_python_worker -->|"process"| node_python_nlp
node_python_worker -->|"retrieve"| node_python_rag
node_python_worker -->|"scrape"| node_python_crawler
node_go_consumer -->|"broker"| node_redis
node_python_worker -->|"broker"| node_redis
node_go_engine -->|"results"| node_mongo
node_python_rag -->|"knowledge"| node_mongo
node_compose -.->|"runs"| node_gateway_entry
node_compose -.->|"runs"| node_go_consumer
node_compose -.->|"runs"| node_node_entry
node_compose -.->|"runs"| node_python_worker
node_compose -.->|"runs"| node_frontend_ui

click node_frontend_ui "https://github.com/lobo017/metacrawler/blob/main/frontend/components/Dashboard.jsx"
click node_frontend_jobs "https://github.com/lobo017/metacrawler/blob/main/frontend/components/JobController.jsx"
click node_frontend_chat "https://github.com/lobo017/metacrawler/blob/main/frontend/components/ChatModal.jsx"
click node_gateway_schema "https://github.com/lobo017/metacrawler/blob/main/api-gateway/schema.graphql"
click node_gateway_resolvers "https://github.com/lobo017/metacrawler/blob/main/api-gateway/resolvers.js"
click node_gateway_entry "https://github.com/lobo017/metacrawler/blob/main/api-gateway/index.js"
click node_go_engine "https://github.com/lobo017/metacrawler/blob/main/backend-go/internal/scraper/engine.go"
click node_go_crawler "https://github.com/lobo017/metacrawler/blob/main/backend-go/internal/scraper/crawler.go"
click node_go_consumer "https://github.com/lobo017/metacrawler/blob/main/backend-go/internal/queue/consumer.go"
click node_node_browser "https://github.com/lobo017/metacrawler/blob/main/backend-node/src/scrapers/browser.js"
click node_node_entry "https://github.com/lobo017/metacrawler/blob/main/backend-node/index.js"
click node_python_nlp "https://github.com/lobo017/metacrawler/blob/main/backend-python/app/nlp/processor.py"
click node_python_rag "https://github.com/lobo017/metacrawler/blob/main/backend-python/app/unified_rag.py"
click node_python_worker "https://github.com/lobo017/metacrawler/blob/main/backend-python/celery_worker.py"
click node_python_crawler "https://github.com/lobo017/metacrawler/blob/main/backend-python/app/scrapers/site_crawler.py"
click node_redis "https://github.com/lobo017/metacrawler/blob/main/docker-compose.yml"
click node_mongo "https://github.com/lobo017/metacrawler/blob/main/docker-compose.yml"
click node_compose "https://github.com/lobo017/metacrawler/blob/main/docker-compose.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_ui,node_frontend_jobs,node_frontend_chat toneBlue
class node_gateway_schema,node_gateway_resolvers,node_gateway_entry toneAmber
class node_go_engine,node_go_crawler,node_go_consumer toneMint
class node_node_browser,node_node_entry toneRose
class node_python_nlp,node_python_rag,node_python_worker,node_python_crawler toneIndigo
class node_redis,node_mongo,node_compose toneTeal
```

## Components

### Frontend

Next.js operations console for workspaces, jobs, analytics, and chat

- [Dashboard UI](https://github.com/lobo017/metacrawler/blob/main/frontend/components/Dashboard.jsx): Next.js console · User-facing workspace, job, analytics, and chat interface · `frontend/components/Dashboard.jsx`
- [Job Control](https://github.com/lobo017/metacrawler/blob/main/frontend/components/JobController.jsx): UI controller · Submits and monitors scraping jobs · `frontend/components/JobController.jsx`
- [Chat Modals](https://github.com/lobo017/metacrawler/blob/main/frontend/components/ChatModal.jsx): UI chat · Chat-style interaction surfaces for workspace assistance · `frontend/components/ChatModal.jsx`

### API Gateway

GraphQL control plane and request router

- [GraphQL Schema](https://github.com/lobo017/metacrawler/blob/main/api-gateway/schema.graphql): GraphQL contract · Single API contract exposed to the frontend · `api-gateway/schema.graphql`
- [Resolvers](https://github.com/lobo017/metacrawler/blob/main/api-gateway/resolvers.js): Apollo resolvers · Routes requests and coordinates job lifecycle logic · `api-gateway/resolvers.js`
- [Gateway Server](https://github.com/lobo017/metacrawler/blob/main/api-gateway/index.js): Node service · API entrypoint that hosts the GraphQL gateway · `api-gateway/index.js`

### Go Backend

High-throughput static crawling and extraction

- [Crawler Engine](https://github.com/lobo017/metacrawler/blob/main/backend-go/internal/scraper/engine.go): Go extractor · Core static crawling and extraction pipeline · `backend-go/internal/scraper/engine.go`
- [Crawler Core](https://github.com/lobo017/metacrawler/blob/main/backend-go/internal/scraper/crawler.go): Go crawler · Fetches and normalizes static pages · `backend-go/internal/scraper/crawler.go`
- [Queue Consumer](https://github.com/lobo017/metacrawler/blob/main/backend-go/internal/queue/consumer.go): Go worker · Consumes crawl jobs from the queue · `backend-go/internal/queue/consumer.go`

### Node Backend

Browser automation for dynamic pages

- [Browser Scraper](https://github.com/lobo017/metacrawler/blob/main/backend-node/src/scrapers/browser.js): Playwright scraper · Handles dynamic, JavaScript-heavy browsing flows · `backend-node/src/scrapers/browser.js`
- [Node Worker](https://github.com/lobo017/metacrawler/blob/main/backend-node/index.js): Node service · Browser-automation backend process · `backend-node/index.js`

### Python Backend

NLP, RAG, and asynchronous enrichment

- [NLP Processor](https://github.com/lobo017/metacrawler/blob/main/backend-python/app/nlp/processor.py): Python NLP · Semantic enrichment and text processing · `backend-python/app/nlp/processor.py`
- [Unified RAG](https://github.com/lobo017/metacrawler/blob/main/backend-python/app/unified_rag.py): Python retrieval · Local retrieval-augmented generation over crawled content · `backend-python/app/unified_rag.py`
- [Celery Worker](https://github.com/lobo017/metacrawler/blob/main/backend-python/celery_worker.py): Python worker · Background task execution for long-running jobs · `backend-python/celery_worker.py`
- [Site Crawler](https://github.com/lobo017/metacrawler/blob/main/backend-python/app/scrapers/site_crawler.py): Python scraper · Async scraping and site-aware crawl helpers · `backend-python/app/scrapers/site_crawler.py`

### Shared Infra

Queueing, persistence, and composition boundary

- [Redis](https://github.com/lobo017/metacrawler/blob/main/docker-compose.yml): broker · Message broker for asynchronous job dispatch · `docker-compose.yml`
- [MongoDB](https://github.com/lobo017/metacrawler/blob/main/docker-compose.yml): persistence · Persistent job and content storage · `docker-compose.yml`
- [Compose Stack](https://github.com/lobo017/metacrawler/blob/main/docker-compose.yml): deployment · Container orchestration for the multi-service local stack · `docker-compose.yml`

## Connections

- Dashboard UI → Gateway Server: API calls · Frontend talks only to the gateway
- Job Control → Resolvers: submit/status · Job creation and polling flow
- Chat Modals → Resolvers: chat requests · Interactive workspace requests are routed through the gateway
- Gateway Server → GraphQL Schema: serves · Gateway exposes the GraphQL contract
- Gateway Server → Resolvers: executes · Resolves requests and control-plane actions
- Resolvers → Queue Consumer: static jobs · Routes fast crawl jobs to the Go backend
- Resolvers → Browser Scraper: dynamic jobs · Routes browser-heavy work to the Node backend
- Resolvers → Celery Worker: enrichment jobs · Routes NLP and RAG-oriented work to Python
- Resolvers → Redis: enqueue · Uses the broker for asynchronous execution
- Resolvers → MongoDB: persist · Stores job state and results
- Queue Consumer → Crawler Engine: consume · Worker hands off to the crawler engine
- Crawler Engine → Crawler Core: crawl · Engine coordinates page fetching and extraction
- Node Worker → Browser Scraper: run · Node process hosts browser automation logic
- Celery Worker → NLP Processor: process · Background work flows into NLP processing
- Celery Worker → Unified RAG: retrieve · Worker can build answers from crawled content
- Celery Worker → Site Crawler: scrape · Worker can run async site crawling tasks
- Queue Consumer → Redis: broker · Consumes jobs from the shared queue
- Celery Worker → Redis: broker · Celery uses Redis for task dispatch
- Crawler Engine → MongoDB: results · Extraction output is stored for reuse
- Unified RAG → MongoDB: knowledge · RAG reads persisted crawl content
- Compose Stack → Gateway Server: runs · Compose includes the gateway container
- Compose Stack → Queue Consumer: runs · Compose includes the Go backend
- Compose Stack → Node Worker: runs · Compose includes the Node backend
- Compose Stack → Celery Worker: runs · Compose includes the Python backend
- Compose Stack → Dashboard UI: runs · Compose includes the frontend container
