# chetanlal453/cms architecture

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

- Interactive diagram: https://gitdiagram.com/chetanlal453/cms
- Repository: https://github.com/chetanlal453/cms

## Overview

UAdmin is a multi-site CMS with a visual page builder and a separate generic public-site runtime. The main workflow is an administrator editing and saving a page, then a visitor requesting its published page for rendering. The graph also preserves site management, reusable content and media, revisions, shared block/theme contracts, and public rendering. Some connections reflect explicit README or source-index references; unsampled subsystems are represented at their documented directory paths, without asserting unverified internal calls.

Main entry points: [`apps/admin/src/app/api/pages`](https://github.com/chetanlal453/cms/tree/main/apps/admin/src/app/api/pages) (Page APIs), [`apps/site-runtime/src/components/public/PublicPage.tsx`](https://github.com/chetanlal453/cms/blob/main/apps/site-runtime/src/components/public/PublicPage.tsx) (Public Page Renderer), [`apps/admin/src/lib/services/page-editor-service.js`](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/services/page-editor-service.js) (Editor Service), [`apps/admin/src/app/api/page/[slug]/route.js`](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/app/api/page/%5Bslug%5D/route.js) (Public Page API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_admin["Admin CMS"]
  node_collections["Content Collections"]
  node_media["Media APIs"]
  node_sites["Site Management"]
  node_auth["Admin Authorization<br/>[require-admin.js]"]
  node_db[("MySQL Pool<br/>[db.js]")]
  node_cache["Public Page Cache"]
end

subgraph group_content["Page Authoring"]
  node_editor["Visual Page Editor"]
  node_pageui["Page Editor Route<br/>[page.tsx]"]
  node_pageapi["Page APIs"]
  node_sectionapi["Section APIs<br/>[route.js]"]
  node_editservice["Editor Service"]
  node_layout["Layout Sync<br/>[layout-sync.js]"]
  node_pagerepo["Page Repository<br/>[page-repository.js]"]
  node_revisionrepo["Revision Repository"]
end

subgraph group_shared["Shared Contracts"]
  node_sharedblocks["Block Contracts"]
  node_sharedpage["Page Contracts"]
  node_theme["Theme Contracts<br/>[index.ts]"]
  node_presets["Section Presets"]
end

subgraph group_runtime["Public Runtime"]
  node_publicapi["Public Page API<br/>[route.js]"]
  node_render["Page Render Service"]
  node_resolver["Site Resolver<br/>[site-resolver.js]"]
  node_publicpage["Public Page Renderer<br/>[PublicPage.tsx]"]
  node_boundary["CMS Boundary<br/>[cmsBoundary.ts]"]
  node_blocksui["Public Block Views"]
end

node_admin(("Administrator"))
node_visitor(("Site Visitor"))

node_admin -->|"edits pages"| node_pageui
node_pageui -.->|"hosts editor"| node_editor
node_editor -.->|"saves drafts"| node_pageapi
node_editor -.->|"updates sections"| node_sectionapi
node_pageapi -->|"checks access"| node_auth
node_pageapi -->|"saves drafts"| node_editservice
node_pageapi -->|"creates revisions"| node_revisionrepo
node_pageapi -->|"normalizes layout"| node_layout
node_sectionapi -->|"checks access"| node_auth
node_sectionapi -->|"delegates edits"| node_editservice
node_editservice -->|"loads and updates"| node_pagerepo
node_editservice -->|"writes revisions"| node_revisionrepo
node_editservice -->|"invalidates cache"| node_cache
node_layout -->|"uses repository"| node_pagerepo
node_layout -->|"uses revisions"| node_revisionrepo
node_collections -.->|"manages content"| node_admin
node_media -.->|"handles media"| node_admin
node_sites -->|"checks access"| node_auth
node_auth -->|"authorizes session"| node_admin
node_pageapi -->|"queries pages"| node_db
node_pagerepo -->|"queries pages"| node_db
node_revisionrepo -->|"stores revisions"| node_db
node_admin -.->|"publishes page"| node_publicapi
node_visitor -.->|"requests page"| node_publicapi
node_publicapi -->|"resolves site"| node_resolver
node_publicapi -->|"builds page bundle"| node_render
node_render -->|"loads page data"| node_pagerepo
node_publicapi -.->|"uses page cache"| node_cache
node_publicpage -->|"normalizes CMS data"| node_boundary
node_publicpage -->|"uses block contracts"| node_sharedblocks
node_publicpage -.->|"renders blocks"| node_blocksui
node_visitor -.->|"views site"| node_publicpage
node_pageui -->|"uses contracts"| node_sharedblocks
node_pageui -->|"uses contracts"| node_sharedpage
node_publicpage -->|"uses shared theme"| node_theme
node_editor -.->|"uses presets"| node_presets

click node_editor "https://github.com/chetanlal453/cms/tree/main/apps/admin/src/components/PageEditor"
click node_pageui "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/app/(admin)/page-editor/page.tsx"
click node_pageapi "https://github.com/chetanlal453/cms/tree/main/apps/admin/src/app/api/pages"
click node_sectionapi "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/app/api/page/%5Bslug%5D/sections/route.js"
click node_editservice "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/services/page-editor-service.js"
click node_layout "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/layout-sync.js"
click node_pagerepo "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/repositories/page-repository.js"
click node_revisionrepo "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/repositories/page-revision-repository.js"
click node_collections "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/components/admin/CollectionManagerPage.tsx"
click node_media "https://github.com/chetanlal453/cms/tree/main/apps/admin/src/app/api/media"
click node_sites "https://github.com/chetanlal453/cms/tree/main/apps/admin/src/app/api/sites"
click node_auth "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/require-admin.js"
click node_db "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/db.js"
click node_cache "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/public-page-cache.js"
click node_sharedblocks "https://github.com/chetanlal453/cms/tree/main/packages/shared/blocks"
click node_sharedpage "https://github.com/chetanlal453/cms/tree/main/packages/shared/page"
click node_theme "https://github.com/chetanlal453/cms/blob/main/packages/shared/theme/index.ts"
click node_presets "https://github.com/chetanlal453/cms/tree/main/packages/shared/presets"
click node_publicapi "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/app/api/page/%5Bslug%5D/route.js"
click node_render "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/services/page-render-service.js"
click node_resolver "https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/services/site-resolver.js"
click node_publicpage "https://github.com/chetanlal453/cms/blob/main/apps/site-runtime/src/components/public/PublicPage.tsx"
click node_boundary "https://github.com/chetanlal453/cms/blob/main/apps/site-runtime/src/lib/cmsBoundary.ts"
click node_blocksui "https://github.com/chetanlal453/cms/tree/main/apps/site-runtime/src/components/ui"

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_collections,node_media,node_sites,node_auth,node_db,node_cache toneBlue
class node_editor,node_pageui,node_pageapi,node_sectionapi,node_editservice,node_layout,node_pagerepo,node_revisionrepo toneAmber
class node_sharedblocks,node_sharedpage,node_theme,node_presets toneMint
class node_publicapi,node_render,node_resolver,node_publicpage,node_boundary,node_blocksui toneRose
class node_admin,node_visitor toneIndigo
```

## Components

### Admin CMS

- [Content Collections](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/components/admin/CollectionManagerPage.tsx): `apps/admin/src/components/admin/CollectionManagerPage.tsx`
- [Media APIs](https://github.com/chetanlal453/cms/tree/main/apps/admin/src/app/api/media): `apps/admin/src/app/api/media`
- [Site Management](https://github.com/chetanlal453/cms/tree/main/apps/admin/src/app/api/sites): `apps/admin/src/app/api/sites`
- [Admin Authorization](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/require-admin.js): `apps/admin/src/lib/require-admin.js`
- [MySQL Pool](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/db.js): `apps/admin/src/lib/db.js`
- [Public Page Cache](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/public-page-cache.js): `apps/admin/src/lib/public-page-cache.js`

### Page Authoring

- [Visual Page Editor](https://github.com/chetanlal453/cms/tree/main/apps/admin/src/components/PageEditor): `apps/admin/src/components/PageEditor`
- [Page Editor Route](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/app/(admin)/page-editor/page.tsx): `apps/admin/src/app/(admin)/page-editor/page.tsx`
- [Page APIs](https://github.com/chetanlal453/cms/tree/main/apps/admin/src/app/api/pages): `apps/admin/src/app/api/pages`
- [Section APIs](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/app/api/page/%5Bslug%5D/sections/route.js): `apps/admin/src/app/api/page/[slug]/sections/route.js`
- [Editor Service](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/services/page-editor-service.js): `apps/admin/src/lib/services/page-editor-service.js`
- [Layout Sync](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/layout-sync.js): `apps/admin/src/lib/layout-sync.js`
- [Page Repository](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/repositories/page-repository.js): `apps/admin/src/lib/repositories/page-repository.js`
- [Revision Repository](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/repositories/page-revision-repository.js): `apps/admin/src/lib/repositories/page-revision-repository.js`

### Shared Contracts

- [Block Contracts](https://github.com/chetanlal453/cms/tree/main/packages/shared/blocks): `packages/shared/blocks`
- [Page Contracts](https://github.com/chetanlal453/cms/tree/main/packages/shared/page): `packages/shared/page`
- [Theme Contracts](https://github.com/chetanlal453/cms/blob/main/packages/shared/theme/index.ts): `packages/shared/theme/index.ts`
- [Section Presets](https://github.com/chetanlal453/cms/tree/main/packages/shared/presets): `packages/shared/presets`

### Public Runtime

- [Public Page API](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/app/api/page/%5Bslug%5D/route.js): `apps/admin/src/app/api/page/[slug]/route.js`
- [Page Render Service](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/services/page-render-service.js): `apps/admin/src/lib/services/page-render-service.js`
- [Site Resolver](https://github.com/chetanlal453/cms/blob/main/apps/admin/src/lib/services/site-resolver.js): `apps/admin/src/lib/services/site-resolver.js`
- [Public Page Renderer](https://github.com/chetanlal453/cms/blob/main/apps/site-runtime/src/components/public/PublicPage.tsx): `apps/site-runtime/src/components/public/PublicPage.tsx`
- [CMS Boundary](https://github.com/chetanlal453/cms/blob/main/apps/site-runtime/src/lib/cmsBoundary.ts): `apps/site-runtime/src/lib/cmsBoundary.ts`
- [Public Block Views](https://github.com/chetanlal453/cms/tree/main/apps/site-runtime/src/components/ui): `apps/site-runtime/src/components/ui`

### Other components

- **Administrator**
- **Site Visitor**

## Connections

- Administrator → Page Editor Route: edits pages
- Page Editor Route → Visual Page Editor: hosts editor
- Visual Page Editor → Page APIs: saves drafts
- Visual Page Editor → Section APIs: updates sections
- Page APIs → Admin Authorization: checks access (evidence: `apps/admin/src/app/api/pages/route.js`)
- Page APIs → Editor Service: saves drafts (evidence: `apps/admin/src/app/api/pages/[page_id]/route.js`)
- Page APIs → Revision Repository: creates revisions (evidence: `apps/admin/src/app/api/pages/route.js`)
- Page APIs → Layout Sync: normalizes layout (evidence: `apps/admin/src/app/api/pages/[page_id]/route.js`)
- Section APIs → Admin Authorization: checks access (evidence: `apps/admin/src/app/api/page/[slug]/sections/route.js`)
- Section APIs → Editor Service: delegates edits (evidence: `apps/admin/src/app/api/page/[slug]/sections/route.js`)
- Editor Service → Page Repository: loads and updates (evidence: `apps/admin/src/lib/services/page-editor-service.js`)
- Editor Service → Revision Repository: writes revisions (evidence: `apps/admin/src/lib/services/page-editor-service.js`)
- Editor Service → Public Page Cache: invalidates cache (evidence: `apps/admin/src/lib/services/page-editor-service.js`)
- Layout Sync → Page Repository: uses repository (evidence: `apps/admin/src/lib/layout-sync.js`)
- Layout Sync → Revision Repository: uses revisions (evidence: `apps/admin/src/lib/layout-sync.js`)
- Content Collections → Administrator: manages content
- Media APIs → Administrator: handles media
- Site Management → Admin Authorization: checks access (evidence: `apps/admin/src/app/api/sites/route.js`)
- Admin Authorization → Administrator: authorizes session (evidence: `apps/admin/src/lib/require-admin.js`)
- Page APIs → MySQL Pool: queries pages (evidence: `apps/admin/src/app/api/pages/route.js`)
- Page Repository → MySQL Pool: queries pages (evidence: `apps/admin/src/lib/repositories/page-repository.js`)
- Revision Repository → MySQL Pool: stores revisions (evidence: `apps/admin/src/lib/repositories/page-revision-repository.js`)
- Administrator → Public Page API: publishes page
- Site Visitor → Public Page API: requests page
- Public Page API → Site Resolver: resolves site (evidence: `apps/admin/src/app/api/page/[slug]/route.js`)
- Public Page API → Page Render Service: builds page bundle (evidence: `apps/admin/src/app/api/page/[slug]/route.js`)
- Page Render Service → Page Repository: loads page data (evidence: `apps/admin/src/lib/services/page-render-service.js`)
- Public Page API → Public Page Cache: uses page cache
- Public Page Renderer → CMS Boundary: normalizes CMS data (evidence: `apps/site-runtime/src/components/public/PublicPage.tsx`)
- Public Page Renderer → Block Contracts: uses block contracts (evidence: `apps/site-runtime/src/components/public/PublicPage.tsx`)
- Public Page Renderer → Public Block Views: renders blocks
- Site Visitor → Public Page Renderer: views site
- Page Editor Route → Block Contracts: uses contracts
- Page Editor Route → Page Contracts: uses contracts
- Public Page Renderer → Theme Contracts: uses shared theme
- Visual Page Editor → Section Presets: uses presets
