# vtempest/svelte-starter-docs architecture

> Architecture diagram of the GitHub repository vtempest/svelte-starter-docs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vtempest/svelte-starter-docs
- Repository: https://github.com/vtempest/svelte-starter-docs

## Overview

##### Project Type and Purpose
- This is a hybrid full-stack project combining:
a) A SvelteKit-based dynamic web app (starter DOCS site) with built-in API routes, server logic, and database integration.
b) A static documentation generator (“create-api-docs” CLI + Docusaurus) to produce self-hosted API/function docs.
- Purpose: Provide a “Next.js-like” Svelte starter with OAuth/email auth, Drizzle ORM on Cloudflare Workers/D1, plus docs-driven development for your JS functions.

##### High-Level File Structure Analysis
- Top-level src/
- lib/server: auth.ts, email.ts, drizzle.config.ts, users.ts, validations.ts – business logic & DB layer.
- Database & Migrations
- drizzle.config.ts, migrations/ – Drizzle ORM config & D1 schema migrations.
- Static docs artifact
- create-api-docs/: CLI tool (Node/Bun script + Docusaurus site under api-docs-standard) → generates docs/
- docs-config/: Custom Docusaurus setup for hosting docs alongside functions.
- docs/: Output static files (HTML/CSS/JS) served by Pages.
- Deployment config
- wrangler.toml: Cloudflare Workers + Pages config
- Vite, Tailwind, SvelteKit configs (vite.config.ts, svelte.config.js, tailwind.config.js)

##### README Insights
- Key stacks: SvelteKit, Tailwind, shadcn-svelte, Drizzle ORM with D1, Better Auth (OAuth + Resend), Cloudflare Workers & Pages.
- Docs-Driven Development: generate docs from code (create-api-docs) alongside the live Svelte app.
- Commands: bun dev (local), bun serve (deploy worker), wrangler for Cloudflare.

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "Developer Workstation"
    CLI_SCR["create-api-docs.js"]:::tool
    PKG["package.json (create-api-docs/)"]:::tool
    API_STD["api-docs-standard/"]:::tool
    DocsConfigProj["docs-config/"]:::code
    DocusaurusCfg["docusaurus.config.ts"]:::code
    DocsConfigCfg["config/"]:::code
    SRC["src/"]:::code
    UIComp["src/lib/components/ui/"]:::frontend
    IconComp["src/lib/components/icons/"]:::frontend
    LayoutComp["src/lib/components/AppLayout/"]:::frontend
    HookServer["src/hooks.server.ts"]:::backend
    HookMobile["src/lib/hooks/is-mobile.svelte.ts"]:::backend
    Routes["src/routes/"]:::backend
    AuthLogic["src/lib/server/auth.ts"]:::backend
    EmailLogic["src/lib/server/email.ts"]:::backend
    DrizzleConf["src/lib/server/drizzle.config.ts"]:::backend
    UsersLogic["src/lib/server/users.ts"]:::backend
    Validations["src/lib/server/validations.ts"]:::backend
    RateLimits["src/lib/server/ratelimits.ts"]:::backend
    SchemaDef["src/lib/server/schema.ts"]:::backend
    TypesDef["src/lib/server/types.d.ts"]:::backend
    DrizzleRoot["drizzle.config.ts"]:::backend
    Migrations["migrations/"]:::backend
    ViteCfg["vite.config.ts"]:::tool
    SvelteCfg["svelte.config.js"]:::tool
    TailwindCfg["tailwind.config.js"]:::tool
    TSConfig["tsconfig.json"]:::tool
    TypedocCfg["typedoc.json"]:::tool
  end

  subgraph "Build System"
    DocsBuild["Docusaurus Build"]:::tool
    DocsOutput["Static Docs (create-api-docs/docs/)"]:::tool
    FinalDocs["Published Docs (docs/)"]:::tool
    AppBuild["Vite/SvelteKit Build"]:::tool
    WorkerBundle["Worker Bundle"]:::tool
    DBMigrate["drizzle-kit Migrations"]:::tool
  end

  subgraph "Cloudflare Infrastructure"
    Pages["Cloudflare Pages (Static Docs)"]:::infra
    WorkerSSR["Cloudflare Workers SSR"]:::backend
    D1DB["Cloudflare D1"]:::database
  end

  subgraph "Client Browser"
    BrowserUI["Client Browser UI"]:::frontend
  end

  subgraph "External Services"
    Google["Google OAuth"]:::external
    Resend["Resend Mail API"]:::external
  end

  %% Workflow connections
  CLI_SCR -->|generates| DocsBuild
  DocsConfigProj -->|configures| DocsBuild
  DocusaurusCfg -->|used by| DocsBuild
  DocsConfigCfg -->|sidebars| DocsBuild
  DocsBuild -->|outputs| DocsOutput
  DocsOutput -->|deployed to| Pages
  DocsOutput -->|published as| FinalDocs

  SRC -->|source for| AppBuild
  AppBuild -->|bundles| WorkerBundle
  WorkerBundle -->|deploy via wrangler.toml| WorkerSSR

  DrizzleRoot -->|configures| DBMigrate
  Migrations -->|provides| DBMigrate
  DBMigrate -->|runs on| D1DB

  BrowserUI -->|requests| WorkerSSR
  WorkerSSR -->|SSR & API| BrowserUI
  BrowserUI -->|API calls| WorkerSSR
  WorkerSSR -->|queries| D1DB
  WorkerSSR -->|auth redirect| Google
  Google -->|callback| WorkerSSR
  WorkerSSR -->|send email| Resend

  %% Click Events
  click SRC "https://github.com/vtempest/svelte-starter-docs/tree/master/src/"
  click UIComp "https://github.com/vtempest/svelte-starter-docs/tree/master/src/lib/components/ui/"
  click IconComp "https://github.com/vtempest/svelte-starter-docs/tree/master/src/lib/components/icons/"
  click LayoutComp "https://github.com/vtempest/svelte-starter-docs/tree/master/src/lib/components/AppLayout/"
  click HookServer "https://github.com/vtempest/svelte-starter-docs/blob/master/src/hooks.server.ts"
  click HookMobile "https://github.com/vtempest/svelte-starter-docs/blob/master/src/lib/hooks/is-mobile.svelte.ts"
  click Routes "https://github.com/vtempest/svelte-starter-docs/tree/master/src/routes/"
  click AuthLogic "https://github.com/vtempest/svelte-starter-docs/blob/master/src/lib/server/auth.ts"
  click EmailLogic "https://github.com/vtempest/svelte-starter-docs/blob/master/src/lib/server/email.ts"
  click DrizzleConf "https://github.com/vtempest/svelte-starter-docs/blob/master/src/lib/server/drizzle.config.ts"
  click UsersLogic "https://github.com/vtempest/svelte-starter-docs/blob/master/src/lib/server/users.ts"
  click Validations "https://github.com/vtempest/svelte-starter-docs/blob/master/src/lib/server/validations.ts"
  click RateLimits "https://github.com/vtempest/svelte-starter-docs/blob/master/src/lib/server/ratelimits.ts"
  click SchemaDef "https://github.com/vtempest/svelte-starter-docs/blob/master/src/lib/server/schema.ts"
  click TypesDef "https://github.com/vtempest/svelte-starter-docs/blob/master/src/lib/server/types.d.ts"
  click DrizzleRoot "https://github.com/vtempest/svelte-starter-docs/blob/master/drizzle.config.ts"
  click Migrations "https://github.com/vtempest/svelte-starter-docs/tree/master/migrations/"
  click CLI_SCR "https://github.com/vtempest/svelte-starter-docs/blob/master/create-api-docs/create-api-docs.js"
  click PKG "https://github.com/vtempest/svelte-starter-docs/blob/master/create-api-docs/package.json"
  click API_STD "https://github.com/vtempest/svelte-starter-docs/tree/master/create-api-docs/api-docs-standard/"
  click DocsConfigProj "https://github.com/vtempest/svelte-starter-docs/tree/master/docs-config/"
  click DocusaurusCfg "https://github.com/vtempest/svelte-starter-docs/blob/master/docs-config/docusaurus.config.ts"
  click DocsConfigCfg "https://github.com/vtempest/svelte-starter-docs/tree/master/docs-config/config/"
  click ViteCfg "https://github.com/vtempest/svelte-starter-docs/blob/master/vite.config.ts"
  click SvelteCfg "https://github.com/vtempest/svelte-starter-docs/blob/master/svelte.config.js"
  click TailwindCfg "https://github.com/vtempest/svelte-starter-docs/blob/master/tailwind.config.js"
  click TSConfig "https://github.com/vtempest/svelte-starter-docs/blob/master/tsconfig.json"
  click TypedocCfg "https://github.com/vtempest/svelte-starter-docs/blob/master/typedoc.json"

  %% Styles
  classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
  classDef backend fill:#D0FFD6,stroke:#28a745,color:#28a745
  classDef external fill:#FFE4B2,stroke:#d73a49,color:#d73a49
  classDef tool fill:#E0E0E0,stroke:#6a737d,color:#6a737d
  classDef code fill:#F0F0F0,stroke:#586069,color:#586069
  classDef infra fill:#DCDCDC,stroke:#444,color:#444
  classDef database fill:#FFF5BF,stroke:#dbab09,color:#735c0f
```
