# tarek291/staticforge-engine architecture

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

- Interactive diagram: https://gitdiagram.com/tarek291/staticforge-engine
- Repository: https://github.com/tarek291/staticforge-engine

## Overview

StaticForge is a schema-driven programmatic SEO engine for multi-location service businesses. Its main workflow validates structured business, service, and location data, generates and publishes pages, then exposes them through the web app. The README also documents queued generation, sync-driven incremental refresh, block editing, database-backed templates, plugins, AI gap analysis, and tenant controls. Several subsystems are represented by their exact enclosing directories because their implementation files were not sampled; those connections are shown only where the README documents them.

Main entry points: [`packages/generator/src/build-pages.ts`](https://github.com/tarek291/staticforge-engine/blob/main/packages/generator/src/build-pages.ts) (Page generation), [`apps/web/app/api/dashboard`](https://github.com/tarek291/staticforge-engine/tree/main/apps/web/app/api/dashboard) (Dashboard API), [`packages/cli/src/worker/worker.ts`](https://github.com/tarek291/staticforge-engine/blob/main/packages/cli/src/worker/worker.ts) (Queue worker), [`packages/database/src/queue.ts`](https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/queue.ts) (Job queue)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_content["Content engine"]
  node_schemas["Content schemas"]
  node_validation["Input validation<br/>[validate-input.ts]"]
  node_authoring["AI authoring<br/>[ai-content.ts]"]
  node_ai_service["AI service<br/>[service.ts]"]
  node_grounding["Fact grounding<br/>[grounding.ts]"]
  node_ai_cache["Generation cache<br/>[cache.ts]"]
  node_page_builder["Page generation<br/>[build-pages.ts]"]
  node_links["Internal link graph<br/>[link-graph.ts]"]
  node_seo["SEO publishing<br/>[seo-publishing.ts]"]
  node_output["Generated output<br/>[save-output.ts]"]
  node_templates[("Template registry<br/>[registry.ts]")]
end

subgraph group_operations["Jobs and integrations"]
  node_queue["Job queue<br/>[queue.ts]"]
  node_worker["Queue worker<br/>[worker.ts]"]
  node_sync["Data sync<br/>[sync.ts]"]
  node_block_edit["Block editing<br/>[route.ts]"]
  node_gap_analysis["AI gap analysis<br/>[gap-analysis.ts]"]
  node_plugins["Plugin runtime"]
end

subgraph group_web["Web product"]
  node_dashboard["Dashboard"]
  node_site_view["Published site view"]
  node_api["Dashboard API"]
end

subgraph group_control["Tenant control plane"]
  node_auth["Request authentication<br/>[auth.ts]"]
  node_access["Roles and access<br/>[access.ts]"]
  node_api_keys[("Organization API keys<br/>[api-key.ts]")]
  node_quotas[("Usage quotas<br/>[quota.ts]")]
  node_audit[("Audit trail<br/>[audit.ts]")]
  node_db[("Project data store<br/>[repository.ts]")]
end

node_operator(("Site operator"))
node_sync_client(("Sync provider"))

node_operator -->|"manages projects"| node_dashboard
node_operator -->|"requests jobs"| node_api
node_api -->|"authenticates"| node_auth
node_api -->|"enqueues jobs"| node_queue
node_queue -->|"dispatches jobs"| node_worker
node_worker -->|"runs generation"| node_page_builder
node_validation -->|"validates against"| node_schemas
node_page_builder -->|"uses contracts"| node_schemas
node_page_builder -->|"authors content"| node_authoring
node_authoring -.->|"uses AI service"| node_ai_service
node_ai_service -->|"grounds content"| node_grounding
node_ai_service -->|"reads and writes"| node_ai_cache
node_page_builder -->|"builds link graph"| node_links
node_page_builder -->|"publishes SEO"| node_seo
node_page_builder -.->|"saves pages"| node_output
node_site_view -.->|"uses templates"| node_templates
node_site_view -.->|"serves pages"| node_output
node_sync_client -->|"submits changes"| node_sync
node_sync -->|"queues affected work"| node_queue
node_api -->|"edits page blocks"| node_block_edit
node_operator -->|"reviews content gaps"| node_gap_analysis
node_worker -->|"triggers build hooks"| node_plugins
node_auth -->|"checks credentials"| node_api_keys
node_auth -->|"checks permissions"| node_access
node_queue -->|"enforces quotas"| node_quotas
node_access -->|"records changes"| node_audit
node_worker -->|"loads and saves pages"| node_db
node_api -->|"reads project data"| node_db

click node_schemas "https://github.com/tarek291/staticforge-engine/tree/main/packages/schemas/src"
click node_validation "https://github.com/tarek291/staticforge-engine/blob/main/packages/generator/src/validate-input.ts"
click node_authoring "https://github.com/tarek291/staticforge-engine/blob/main/packages/generator/src/ai-content.ts"
click node_ai_service "https://github.com/tarek291/staticforge-engine/blob/main/packages/ai/src/service.ts"
click node_grounding "https://github.com/tarek291/staticforge-engine/blob/main/packages/ai/src/grounding.ts"
click node_ai_cache "https://github.com/tarek291/staticforge-engine/blob/main/packages/ai/src/cache.ts"
click node_page_builder "https://github.com/tarek291/staticforge-engine/blob/main/packages/generator/src/build-pages.ts"
click node_links "https://github.com/tarek291/staticforge-engine/blob/main/packages/core/src/link-graph.ts"
click node_seo "https://github.com/tarek291/staticforge-engine/blob/main/packages/core/src/seo-publishing.ts"
click node_output "https://github.com/tarek291/staticforge-engine/blob/main/packages/generator/src/save-output.ts"
click node_templates "https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/registry.ts"
click node_dashboard "https://github.com/tarek291/staticforge-engine/tree/main/apps/web/app/dashboard"
click node_site_view "https://github.com/tarek291/staticforge-engine/tree/main/apps/web/app/%5Bslug%5D"
click node_api "https://github.com/tarek291/staticforge-engine/tree/main/apps/web/app/api/dashboard"
click node_queue "https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/queue.ts"
click node_worker "https://github.com/tarek291/staticforge-engine/blob/main/packages/cli/src/worker/worker.ts"
click node_sync "https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/sync.ts"
click node_block_edit "https://github.com/tarek291/staticforge-engine/blob/main/apps/web/app/api/dashboard/projects/%5Bid%5D/pages/%5Bslug%5D/block/route.ts"
click node_gap_analysis "https://github.com/tarek291/staticforge-engine/blob/main/packages/ai/src/agents/gap-analysis.ts"
click node_plugins "https://github.com/tarek291/staticforge-engine/tree/main/packages/core/src/plugins"
click node_auth "https://github.com/tarek291/staticforge-engine/blob/main/apps/web/lib/auth.ts"
click node_access "https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/access.ts"
click node_api_keys "https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/api-key.ts"
click node_quotas "https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/quota.ts"
click node_audit "https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/audit.ts"
click node_db "https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/repository.ts"

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_schemas,node_validation,node_authoring,node_ai_service,node_grounding,node_ai_cache,node_page_builder,node_links,node_seo,node_output,node_templates toneBlue
class node_queue,node_worker,node_sync,node_block_edit,node_gap_analysis,node_plugins toneAmber
class node_dashboard,node_site_view,node_api toneMint
class node_auth,node_access,node_api_keys,node_quotas,node_audit,node_db toneRose
class node_operator,node_sync_client toneIndigo
```

## Components

### Content engine

- [Content schemas](https://github.com/tarek291/staticforge-engine/tree/main/packages/schemas/src): `packages/schemas/src`
- [Input validation](https://github.com/tarek291/staticforge-engine/blob/main/packages/generator/src/validate-input.ts): `packages/generator/src/validate-input.ts`
- [AI authoring](https://github.com/tarek291/staticforge-engine/blob/main/packages/generator/src/ai-content.ts): `packages/generator/src/ai-content.ts`
- [AI service](https://github.com/tarek291/staticforge-engine/blob/main/packages/ai/src/service.ts): `packages/ai/src/service.ts`
- [Fact grounding](https://github.com/tarek291/staticforge-engine/blob/main/packages/ai/src/grounding.ts): `packages/ai/src/grounding.ts`
- [Generation cache](https://github.com/tarek291/staticforge-engine/blob/main/packages/ai/src/cache.ts): `packages/ai/src/cache.ts`
- [Page generation](https://github.com/tarek291/staticforge-engine/blob/main/packages/generator/src/build-pages.ts): `packages/generator/src/build-pages.ts`
- [Internal link graph](https://github.com/tarek291/staticforge-engine/blob/main/packages/core/src/link-graph.ts): `packages/core/src/link-graph.ts`
- [SEO publishing](https://github.com/tarek291/staticforge-engine/blob/main/packages/core/src/seo-publishing.ts): `packages/core/src/seo-publishing.ts`
- [Generated output](https://github.com/tarek291/staticforge-engine/blob/main/packages/generator/src/save-output.ts): `packages/generator/src/save-output.ts`
- [Template registry](https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/registry.ts): `packages/database/src/registry.ts`

### Jobs and integrations

- [Job queue](https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/queue.ts): `packages/database/src/queue.ts`
- [Queue worker](https://github.com/tarek291/staticforge-engine/blob/main/packages/cli/src/worker/worker.ts): `packages/cli/src/worker/worker.ts`
- [Data sync](https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/sync.ts): `packages/database/src/sync.ts`
- [Block editing](https://github.com/tarek291/staticforge-engine/blob/main/apps/web/app/api/dashboard/projects/%5Bid%5D/pages/%5Bslug%5D/block/route.ts): `apps/web/app/api/dashboard/projects/[id]/pages/[slug]/block/route.ts`
- [AI gap analysis](https://github.com/tarek291/staticforge-engine/blob/main/packages/ai/src/agents/gap-analysis.ts): `packages/ai/src/agents/gap-analysis.ts`
- [Plugin runtime](https://github.com/tarek291/staticforge-engine/tree/main/packages/core/src/plugins): `packages/core/src/plugins`

### Web product

- [Dashboard](https://github.com/tarek291/staticforge-engine/tree/main/apps/web/app/dashboard): `apps/web/app/dashboard`
- [Published site view](https://github.com/tarek291/staticforge-engine/tree/main/apps/web/app/%5Bslug%5D): `apps/web/app/[slug]`
- [Dashboard API](https://github.com/tarek291/staticforge-engine/tree/main/apps/web/app/api/dashboard): `apps/web/app/api/dashboard`

### Tenant control plane

- [Request authentication](https://github.com/tarek291/staticforge-engine/blob/main/apps/web/lib/auth.ts): `apps/web/lib/auth.ts`
- [Roles and access](https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/access.ts): `packages/database/src/access.ts`
- [Organization API keys](https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/api-key.ts): `packages/database/src/api-key.ts`
- [Usage quotas](https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/quota.ts): `packages/database/src/quota.ts`
- [Audit trail](https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/audit.ts): `packages/database/src/audit.ts`
- [Project data store](https://github.com/tarek291/staticforge-engine/blob/main/packages/database/src/repository.ts): `packages/database/src/repository.ts`

### Other components

- **Site operator**
- **Sync provider**

## Connections

- Site operator → Dashboard: manages projects (evidence: `README.md`)
- Site operator → Dashboard API: requests jobs (evidence: `apps/web/app/api/dashboard/jobs/route.ts`)
- Dashboard API → Request authentication: authenticates (evidence: `apps/web/app/api/dashboard/jobs/route.ts`)
- Dashboard API → Job queue: enqueues jobs (evidence: `apps/web/app/api/dashboard/jobs/route.ts`)
- Job queue → Queue worker: dispatches jobs (evidence: `README.md`)
- Queue worker → Page generation: runs generation (evidence: `README.md`)
- Input validation → Content schemas: validates against
- Page generation → Content schemas: uses contracts (evidence: `packages/generator/src/build-pages.ts`)
- Page generation → AI authoring: authors content (evidence: `README.md`)
- AI authoring → AI service: uses AI service
- AI service → Fact grounding: grounds content (evidence: `packages/ai/src/service.ts`)
- AI service → Generation cache: reads and writes (evidence: `packages/ai/src/service.ts`)
- Page generation → Internal link graph: builds link graph (evidence: `README.md`)
- Page generation → SEO publishing: publishes SEO (evidence: `README.md`)
- Page generation → Generated output: saves pages
- Published site view → Template registry: uses templates
- Published site view → Generated output: serves pages
- Sync provider → Data sync: submits changes
- Data sync → Job queue: queues affected work
- Dashboard API → Block editing: edits page blocks (evidence: `README.md`)
- Site operator → AI gap analysis: reviews content gaps (evidence: `README.md`)
- Queue worker → Plugin runtime: triggers build hooks (evidence: `README.md`)
- Request authentication → Organization API keys: checks credentials (evidence: `apps/web/lib/auth.ts`)
- Request authentication → Roles and access: checks permissions (evidence: `apps/web/lib/auth.ts`)
- Job queue → Usage quotas: enforces quotas (evidence: `README.md`)
- Roles and access → Audit trail: records changes (evidence: `README.md`)
- Queue worker → Project data store: loads and saves pages (evidence: `README.md`)
- Dashboard API → Project data store: reads project data (evidence: `apps/web/app/api/dashboard/projects/route.ts`)
