summaryrefslogtreecommitdiff
path: root/Documentation/source/architecture/system-overview.rst
blob: c876096dcb509aa8d7243c7f248e8b70c5b3e298 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
System Overview
===============

Layered View
------------

.. list-table::
   :header-rows: 1
   :widths: 22 34 44

   * - Layer
     - Main Files
     - Responsibility
   * - Presentation
     - ``src/app/(main)``, ``src/components``
     - Render public pages, route handlers, shared UI, rich text, and layout.
   * - Content access
     - ``src/lib/payload-posts.ts``
     - Query Payload and normalize CMS documents into frontend-friendly types.
   * - CMS admin
     - ``payload.config.ts``, ``src/payload``, ``src/app/(payload)``
     - Define editorial collections and expose the admin experience.
   * - Auth and comments
     - ``src/server/auth``, ``src/server/comments``
     - Authenticate users and persist comment data.
   * - Data
     - ``src/server/db``, ``src/migrations``
     - Own Drizzle schema, connection setup, and application migrations.
   * - Content pipeline
     - ``content``, ``source.config.ts``
     - Build local MDX content through Fumadocs.

Request Flow: Reading a Post
----------------------------

1. A route under ``src/app/(main)/(home)/posts/[slug]`` receives a slug.
2. The server component calls ``getPostBySlug``.
3. ``src/lib/payload-posts.ts`` obtains a Payload client and queries
   ``posts`` where ``status`` is ``published``.
4. The raw Payload document is transformed into ``BlogPost``.
5. The page renders rich text content and mounts client-side interactions such
   as sharing and comments.

Request Flow: Writing a Comment
-------------------------------

1. The post detail page renders the Fuma Comments client component.
2. The client calls ``/api/comments/[...comment]``.
3. The route delegates to the Fuma Comments Next.js handler.
4. better-auth validates the session.
5. The Drizzle adapter writes comment, rate, and role data to application-owned
   tables.

Boundaries
----------

Payload owns editorial content and media metadata. The application owns auth,
comments, UI state, route behavior, and integration logic. Keep that boundary
clear when adding features: editorial fields belong in Payload collections;
reader interaction and account behavior belong in ``src/server`` and the app
routes.