# miaoyinjun/blog architecture

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

- Interactive diagram: https://gitdiagram.com/miaoyinjun/blog
- Repository: https://github.com/miaoyinjun/blog

## Overview

01mvp-blog-starter is a Cloudflare-native publishing system with two content surfaces: a database-backed blog and Git-managed Fumadocs documentation. The main author workflow is admin sign-in, post editing, publication, and reader-facing rendering; comments, assets, imports/exports, backups, and OpenAPI automation extend that workflow. D1 stores structured content and account data, R2 stores binary assets and archives, and KV supports cache metadata. The graph reflects README-documented capabilities and sampled auth behavior; several feature-specific route implementations were not sampled, so their internal call links are omitted.

Main entry points: [`apps/web/src/routeTree.gen.ts`](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routeTree.gen.ts) (Route registry), [`packages/db/src/schema/cms.sqlite.ts`](https://github.com/miaoyinjun/blog/blob/main/packages/db/src/schema/cms.sqlite.ts) (CMS schema), [`apps/web/src/components/admin/post-form.tsx`](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/components/admin/post-form.tsx) (Post editor), [`apps/web/src/components/docs-route.tsx`](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/components/docs-route.tsx) (Git-managed docs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web surfaces"]
  node_router["Route registry<br/>[routeTree.gen.ts]"]
  node_site["Public blog<br/>[index.tsx]"]
  node_post["Post pages<br/>[$slug.tsx]"]
  node_about["About page<br/>[about.tsx]"]
  node_docs["Git-managed docs<br/>[docs-route.tsx]"]
  node_openapi["OpenAPI publishing<br/>[openapi&#91;.&#93;json.ts]"]
  node_locale["Locale messages<br/>[_index.js]"]
  node_localezh["Chinese messages<br/>[zh.js]"]
  node_locale_runtime["Locale runtime<br/>[runtime.js]"]
  node_fumadocs["Fumadocs source<br/>[source.ts]"]
end

subgraph group_publishing["Publishing operations"]
  node_admin["Admin workspace<br/>[index.tsx]"]
  node_editor["Post editor<br/>[post-form.tsx]"]
  node_comments["Comment handling<br/>[comments.ts]"]
  node_content_types["Content model<br/>[types.ts]"]
  node_markdown["Markdown tools<br/>[markdown.ts]"]
  node_demo["Starter content<br/>[demo-data.ts]"]
  node_cms_schema[("CMS schema<br/>[cms.sqlite.ts]")]
end

subgraph group_identity["Identity and access"]
  node_auth_gate["Protected routes<br/>[route.tsx]"]
  node_guest_gate["Guest routes<br/>[route.tsx]"]
  node_auth_factory["Auth service<br/>[auth.ts]"]
  node_user_schema[("Account schema<br/>[auth.schema.ts]")]
end

subgraph group_platform["Cloudflare platform"]
  node_d1[("Cloudflare D1")]
  node_r2[("Cloudflare R2")]
  node_kv[("Cloudflare KV")]
end

node_reader(("Reader"))
node_author(("Author/admin"))
node_automation(("External automation"))

node_reader -->|"opens routes"| node_router
node_author -->|"opens routes"| node_router
node_automation -->|"uses publishing API"| node_openapi
node_router -->|"routes to"| node_site
node_router -->|"routes to"| node_post
node_router -->|"routes to"| node_about
node_router -->|"routes to"| node_openapi
node_router -.->|"routes to"| node_docs
node_reader -->|"reads documentation"| node_docs
node_reader -->|"reads published posts"| node_post
node_author -->|"signs in"| node_guest_gate
node_guest_gate -->|"redirects authenticated users"| node_auth_gate
node_auth_gate -->|"protects routes"| node_admin
node_admin -->|"opens authoring"| node_editor
node_editor -.->|"authors Markdown"| node_markdown
node_editor -->|"persists content"| node_cms_schema
node_comments -->|"stores comments"| node_cms_schema
node_cms_schema -->|"stores structured content"| node_d1
node_auth_factory -->|"uses account schema"| node_user_schema
node_user_schema -->|"stores accounts and sessions"| node_d1
node_markdown -->|"uses content types"| node_content_types
node_demo -->|"defines sample content"| node_content_types
node_docs -->|"renders documentation"| node_fumadocs
node_cms_schema -->|"archives binary files"| node_r2
node_cms_schema -->|"uses cache metadata"| node_kv
node_locale -->|"uses runtime"| node_locale_runtime
node_locale -->|"loads Chinese messages"| node_localezh

click node_router "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routeTree.gen.ts"
click node_site "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/index.tsx"
click node_post "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/blog/%24slug.tsx"
click node_about "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/about.tsx"
click node_docs "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/components/docs-route.tsx"
click node_openapi "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/openapi%5B.%5Djson.ts"
click node_locale "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/paraglide/messages/_index.js"
click node_localezh "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/paraglide/messages/zh.js"
click node_locale_runtime "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/paraglide/runtime.js"
click node_admin "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/_auth/admin/index.tsx"
click node_editor "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/components/admin/post-form.tsx"
click node_comments "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/api/comments.ts"
click node_content_types "https://github.com/miaoyinjun/blog/blob/main/packages/core/src/types.ts"
click node_markdown "https://github.com/miaoyinjun/blog/blob/main/packages/core/src/markdown.ts"
click node_demo "https://github.com/miaoyinjun/blog/blob/main/packages/core/src/demo-data.ts"
click node_auth_gate "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/_auth/route.tsx"
click node_guest_gate "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/_guest/route.tsx"
click node_auth_factory "https://github.com/miaoyinjun/blog/blob/main/packages/auth/src/auth.ts"
click node_user_schema "https://github.com/miaoyinjun/blog/blob/main/packages/db/src/schema/auth.schema.ts"
click node_cms_schema "https://github.com/miaoyinjun/blog/blob/main/packages/db/src/schema/cms.sqlite.ts"
click node_fumadocs "https://github.com/miaoyinjun/blog/blob/main/apps/web/src/lib/source.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_router,node_site,node_post,node_about,node_docs,node_openapi,node_locale,node_localezh,node_locale_runtime,node_fumadocs toneBlue
class node_admin,node_editor,node_comments,node_content_types,node_markdown,node_demo,node_cms_schema toneAmber
class node_auth_gate,node_guest_gate,node_auth_factory,node_user_schema toneMint
class node_d1,node_r2,node_kv toneRose
class node_reader,node_author,node_automation toneIndigo
```

## Components

### Web surfaces

- [Route registry](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routeTree.gen.ts): `apps/web/src/routeTree.gen.ts`
- [Public blog](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/index.tsx): `apps/web/src/routes/index.tsx`
- [Post pages](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/blog/%24slug.tsx): `apps/web/src/routes/blog/$slug.tsx`
- [About page](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/about.tsx): `apps/web/src/routes/about.tsx`
- [Git-managed docs](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/components/docs-route.tsx): `apps/web/src/components/docs-route.tsx`
- [OpenAPI publishing](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/openapi%5B.%5Djson.ts): `apps/web/src/routes/openapi[.]json.ts`
- [Locale messages](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/paraglide/messages/_index.js): `apps/web/src/paraglide/messages/_index.js`
- [Chinese messages](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/paraglide/messages/zh.js): `apps/web/src/paraglide/messages/zh.js`
- [Locale runtime](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/paraglide/runtime.js): `apps/web/src/paraglide/runtime.js`
- [Fumadocs source](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/lib/source.ts): `apps/web/src/lib/source.ts`

### Publishing operations

- [Admin workspace](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/_auth/admin/index.tsx): `apps/web/src/routes/_auth/admin/index.tsx`
- [Post editor](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/components/admin/post-form.tsx): `apps/web/src/components/admin/post-form.tsx`
- [Comment handling](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/api/comments.ts): `apps/web/src/routes/api/comments.ts`
- [Content model](https://github.com/miaoyinjun/blog/blob/main/packages/core/src/types.ts): `packages/core/src/types.ts`
- [Markdown tools](https://github.com/miaoyinjun/blog/blob/main/packages/core/src/markdown.ts): `packages/core/src/markdown.ts`
- [Starter content](https://github.com/miaoyinjun/blog/blob/main/packages/core/src/demo-data.ts): `packages/core/src/demo-data.ts`
- [CMS schema](https://github.com/miaoyinjun/blog/blob/main/packages/db/src/schema/cms.sqlite.ts): `packages/db/src/schema/cms.sqlite.ts`

### Identity and access

- [Protected routes](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/_auth/route.tsx): `apps/web/src/routes/_auth/route.tsx`
- [Guest routes](https://github.com/miaoyinjun/blog/blob/main/apps/web/src/routes/_guest/route.tsx): `apps/web/src/routes/_guest/route.tsx`
- [Auth service](https://github.com/miaoyinjun/blog/blob/main/packages/auth/src/auth.ts): `packages/auth/src/auth.ts`
- [Account schema](https://github.com/miaoyinjun/blog/blob/main/packages/db/src/schema/auth.schema.ts): `packages/db/src/schema/auth.schema.ts`

### Cloudflare platform

- **Cloudflare D1**
- **Cloudflare R2**
- **Cloudflare KV**

### Other components

- **Reader**
- **Author/admin**
- **External automation**

## Connections

- Reader → Route registry: opens routes (evidence: `apps/web/src/routeTree.gen.ts`)
- Author/admin → Route registry: opens routes (evidence: `apps/web/src/routeTree.gen.ts`)
- External automation → OpenAPI publishing: uses publishing API (evidence: `README.md`)
- Route registry → Public blog: routes to (evidence: `apps/web/src/routeTree.gen.ts`)
- Route registry → Post pages: routes to (evidence: `apps/web/src/routeTree.gen.ts`)
- Route registry → About page: routes to (evidence: `apps/web/src/routeTree.gen.ts`)
- Route registry → OpenAPI publishing: routes to (evidence: `apps/web/src/routeTree.gen.ts`)
- Route registry → Git-managed docs: routes to
- Reader → Git-managed docs: reads documentation (evidence: `README.md`)
- Reader → Post pages: reads published posts (evidence: `README.md`)
- Author/admin → Guest routes: signs in (evidence: `apps/web/src/routes/_guest/route.tsx`)
- Guest routes → Protected routes: redirects authenticated users (evidence: `apps/web/src/routes/_guest/route.tsx`)
- Protected routes → Admin workspace: protects routes (evidence: `apps/web/src/routes/_auth/route.tsx`)
- Admin workspace → Post editor: opens authoring (evidence: `README.md`)
- Post editor → Markdown tools: authors Markdown
- Post editor → CMS schema: persists content (evidence: `README.md`)
- Comment handling → CMS schema: stores comments (evidence: `README.md`)
- CMS schema → Cloudflare D1: stores structured content (evidence: `README.md`)
- Auth service → Account schema: uses account schema (evidence: `packages/auth/src/auth.ts`)
- Account schema → Cloudflare D1: stores accounts and sessions (evidence: `README.md`)
- Markdown tools → Content model: uses content types (evidence: `packages/core/src/markdown.ts`)
- Starter content → Content model: defines sample content (evidence: `packages/core/src/demo-data.ts`)
- Git-managed docs → Fumadocs source: renders documentation (evidence: `README.md`)
- CMS schema → Cloudflare R2: archives binary files (evidence: `README.md`)
- CMS schema → Cloudflare KV: uses cache metadata (evidence: `README.md`)
- Locale messages → Locale runtime: uses runtime (evidence: `apps/web/src/paraglide/messages/_index.js`)
- Locale messages → Chinese messages: loads Chinese messages (evidence: `apps/web/src/paraglide/messages/_index.js`)
