# ztinglun/demo architecture

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

- Interactive diagram: https://gitdiagram.com/ztinglun/demo
- Repository: https://github.com/ztinglun/demo

## Overview

這是以 FastAPI、Jinja2 和 PostgreSQL 實作的投稿審查系統。作者建立並管理草稿、送審；編輯查看待審稿件並通過或退回，退回稿件可再修改送審。主要流程由 main.py 的路由處理，透過 db.py 取得資料庫連線，並以模板呈現頁面。README 說明了狀態轉換與 schema.sql 的初始化方式；模板內容未提供，因此未推斷其內部行為。

Main entry points: [`main.py`](https://github.com/ztinglun/demo/blob/main/main.py) (FastAPI 路由), [`db.py`](https://github.com/ztinglun/demo/blob/main/db.py) (資料庫連線), [`schema.sql`](https://github.com/ztinglun/demo/blob/main/schema.sql) (資料庫結構), [`templates/home.html`](https://github.com/ztinglun/demo/blob/main/templates/home.html) (首頁)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web 介面"]
  node_app_routes["FastAPI 路由<br/>[main.py]"]
  node_home_page["首頁<br/>[home.html]"]
end

subgraph group_author_flow["作者稿件流程"]
  node_author_page["作者頁面<br/>[author.html]"]
  node_author_listing["稿件清單與編輯<br/>[main.py]"]
  node_submission_create["新增稿件<br/>[main.py]"]
  node_author_actions["修改、送審與刪除<br/>[main.py]"]
end

subgraph group_editor_flow["編輯審查流程"]
  node_editor_page["編輯頁面<br/>[editor.html]"]
  node_pending_review["待審清單與內容<br/>[main.py]"]
  node_review_decision["通過或退回<br/>[main.py]"]
end

subgraph group_persistence["資料持久層"]
  node_db_access["資料庫連線<br/>[db.py]"]
  node_postgres[("PostgreSQL")]
  node_database_schema["資料庫結構<br/>[schema.sql]"]
end

node_author(("作者"))
node_editor(("編輯"))

node_author -->|"使用作者功能"| node_app_routes
node_editor -->|"使用編輯功能"| node_app_routes
node_app_routes -->|"呈現首頁"| node_home_page
node_app_routes -->|"呈現作者頁"| node_author_page
node_app_routes -->|"呈現編輯頁"| node_editor_page
node_author -->|"查看與修改"| node_author_listing
node_author -->|"新增稿件"| node_submission_create
node_author -->|"送審或刪除"| node_author_actions
node_editor -->|"查看待審"| node_pending_review
node_editor -->|"審查稿件"| node_review_decision
node_app_routes -->|"取得連線"| node_db_access
node_app_routes -->|"查詢與更新"| node_postgres
node_db_access -->|"建立連線"| node_postgres
node_database_schema -->|"初始化結構"| node_postgres

click node_app_routes "https://github.com/ztinglun/demo/blob/main/main.py"
click node_home_page "https://github.com/ztinglun/demo/blob/main/templates/home.html"
click node_author_page "https://github.com/ztinglun/demo/blob/main/templates/author.html"
click node_author_listing "https://github.com/ztinglun/demo/blob/main/main.py"
click node_submission_create "https://github.com/ztinglun/demo/blob/main/main.py"
click node_author_actions "https://github.com/ztinglun/demo/blob/main/main.py"
click node_editor_page "https://github.com/ztinglun/demo/blob/main/templates/editor.html"
click node_pending_review "https://github.com/ztinglun/demo/blob/main/main.py"
click node_review_decision "https://github.com/ztinglun/demo/blob/main/main.py"
click node_db_access "https://github.com/ztinglun/demo/blob/main/db.py"
click node_database_schema "https://github.com/ztinglun/demo/blob/main/schema.sql"

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_app_routes,node_home_page toneBlue
class node_author_page,node_author_listing,node_submission_create,node_author_actions toneAmber
class node_editor_page,node_pending_review,node_review_decision toneMint
class node_db_access,node_postgres,node_database_schema toneRose
class node_author,node_editor toneIndigo
```

## Components

### Web 介面

- [FastAPI 路由](https://github.com/ztinglun/demo/blob/main/main.py): `main.py`
- [首頁](https://github.com/ztinglun/demo/blob/main/templates/home.html): `templates/home.html`

### 作者稿件流程

- [作者頁面](https://github.com/ztinglun/demo/blob/main/templates/author.html): `templates/author.html`
- [稿件清單與編輯](https://github.com/ztinglun/demo/blob/main/main.py): `main.py`
- [新增稿件](https://github.com/ztinglun/demo/blob/main/main.py): `main.py`
- [修改、送審與刪除](https://github.com/ztinglun/demo/blob/main/main.py): `main.py`

### 編輯審查流程

- [編輯頁面](https://github.com/ztinglun/demo/blob/main/templates/editor.html): `templates/editor.html`
- [待審清單與內容](https://github.com/ztinglun/demo/blob/main/main.py): `main.py`
- [通過或退回](https://github.com/ztinglun/demo/blob/main/main.py): `main.py`

### 資料持久層

- [資料庫連線](https://github.com/ztinglun/demo/blob/main/db.py): `db.py`
- **PostgreSQL**
- [資料庫結構](https://github.com/ztinglun/demo/blob/main/schema.sql): `schema.sql`

### Other components

- **作者**
- **編輯**

## Connections

- 作者 → FastAPI 路由: 使用作者功能 (evidence: `README.md`)
- 編輯 → FastAPI 路由: 使用編輯功能 (evidence: `README.md`)
- FastAPI 路由 → 首頁: 呈現首頁 (evidence: `main.py`)
- FastAPI 路由 → 作者頁面: 呈現作者頁 (evidence: `main.py`)
- FastAPI 路由 → 編輯頁面: 呈現編輯頁 (evidence: `main.py`)
- 作者 → 稿件清單與編輯: 查看與修改 (evidence: `README.md`)
- 作者 → 新增稿件: 新增稿件 (evidence: `README.md`)
- 作者 → 修改、送審與刪除: 送審或刪除 (evidence: `README.md`)
- 編輯 → 待審清單與內容: 查看待審 (evidence: `README.md`)
- 編輯 → 通過或退回: 審查稿件 (evidence: `README.md`)
- FastAPI 路由 → 資料庫連線: 取得連線 (evidence: `main.py`)
- FastAPI 路由 → PostgreSQL: 查詢與更新 (evidence: `main.py`)
- 資料庫連線 → PostgreSQL: 建立連線 (evidence: `db.py`)
- 資料庫結構 → PostgreSQL: 初始化結構 (evidence: `README.md`)
