# 617-lyx/1151se_mid architecture

> Architecture diagram of the GitHub repository 617-lyx/1151se_mid, 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/617-lyx/1151se_mid
- Repository: https://github.com/617-lyx/1151se_mid

## Overview

投稿審查系統是以 FastAPI、Jinja2 和 PostgreSQL 建置的投稿管理網站。瀏覽器使用者先登入或註冊，作者可建立、編輯並送出稿件；編輯則檢視待審稿件、通過或退回，並查看審查紀錄。稿件狀態與審查紀錄由資料庫保存，角色檢查限制各流程的存取。README 說明了主要頁面與資料庫能力；箭頭依據已提供的程式碼或 README，未取樣的模板與靜態頁面只保留其文件化職責。

Main entry points: [`routes/author.py`](https://github.com/617-lyx/1151se_mid/blob/main/routes/author.py) (作者稿件流程), [`routes/editor.py`](https://github.com/617-lyx/1151se_mid/blob/main/routes/editor.py) (編輯審查流程), [`main.py`](https://github.com/617-lyx/1151se_mid/blob/main/main.py) (FastAPI入口), [`routes/login.py`](https://github.com/617-lyx/1151se_mid/blob/main/routes/login.py) (登入註冊)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web入口與身份"]
  node_app["FastAPI入口<br/>[main.py]"]
  node_login["登入註冊<br/>[login.py]"]
  node_auth["角色檢查<br/>[auth.py]"]
end

subgraph group_author["作者投稿"]
  node_author_routes["作者稿件流程<br/>[author.py]"]
end

subgraph group_review["編輯審查"]
  node_editor_routes["編輯審查流程<br/>[editor.py]"]
  node_review_history["審查紀錄查詢<br/>[editor.py]"]
end

subgraph group_shared["共用呈現"]
  node_common["共用呈現工具<br/>[common.py]"]
  node_templates["動態頁面模板"]
  node_static_pages["登入註冊頁"]
end

subgraph group_persistence["資料持久化"]
  node_pool["連線池<br/>[db.py]"]
  node_postgres[("PostgreSQL")]
  node_schema["資料表與初始資料<br/>[review.sql]"]
end

node_browser(("瀏覽器使用者"))

node_browser -->|"HTTP請求"| node_app
node_app -->|"掛載路由"| node_login
node_app -->|"掛載路由"| node_author_routes
node_app -->|"掛載路由"| node_editor_routes
node_app -->|"提供靜態頁"| node_static_pages
node_app -->|"檢查首頁登入"| node_auth
node_login -->|"取得資料連線"| node_pool
node_login -->|"查寫使用者"| node_postgres
node_author_routes -->|"限制作者角色"| node_auth
node_author_routes -->|"取得資料連線"| node_pool
node_author_routes -->|"讀寫稿件"| node_postgres
node_author_routes -->|"取得審查紀錄"| node_review_history
node_editor_routes -->|"限制編輯角色"| node_auth
node_editor_routes -->|"取得資料連線"| node_pool
node_editor_routes -->|"讀寫審查資料"| node_postgres
node_editor_routes -->|"查詢稿件紀錄"| node_review_history
node_author_routes -->|"使用共用工具"| node_common
node_editor_routes -->|"使用共用工具"| node_common
node_login -->|"註冊使用者"| node_postgres
node_schema -->|"建立資料表"| node_postgres
node_common -->|"設定模板目錄"| node_templates
node_author_routes -->|"呈現作者頁面"| node_templates
node_editor_routes -->|"呈現編輯頁面"| node_templates

click node_app "https://github.com/617-lyx/1151se_mid/blob/main/main.py"
click node_login "https://github.com/617-lyx/1151se_mid/blob/main/routes/login.py"
click node_auth "https://github.com/617-lyx/1151se_mid/blob/main/auth.py"
click node_author_routes "https://github.com/617-lyx/1151se_mid/blob/main/routes/author.py"
click node_editor_routes "https://github.com/617-lyx/1151se_mid/blob/main/routes/editor.py"
click node_review_history "https://github.com/617-lyx/1151se_mid/blob/main/routes/editor.py"
click node_common "https://github.com/617-lyx/1151se_mid/blob/main/common.py"
click node_templates "https://github.com/617-lyx/1151se_mid/tree/main/templates"
click node_static_pages "https://github.com/617-lyx/1151se_mid/tree/main/www"
click node_pool "https://github.com/617-lyx/1151se_mid/blob/main/db.py"
click node_schema "https://github.com/617-lyx/1151se_mid/blob/main/review.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,node_login,node_auth toneBlue
class node_author_routes toneAmber
class node_editor_routes,node_review_history toneMint
class node_common,node_templates,node_static_pages toneRose
class node_pool,node_postgres,node_schema,node_browser toneIndigo
```

## Components

### Web入口與身份

- [FastAPI入口](https://github.com/617-lyx/1151se_mid/blob/main/main.py): `main.py`
- [登入註冊](https://github.com/617-lyx/1151se_mid/blob/main/routes/login.py): `routes/login.py`
- [角色檢查](https://github.com/617-lyx/1151se_mid/blob/main/auth.py): `auth.py`

### 作者投稿

- [作者稿件流程](https://github.com/617-lyx/1151se_mid/blob/main/routes/author.py): `routes/author.py`

### 編輯審查

- [編輯審查流程](https://github.com/617-lyx/1151se_mid/blob/main/routes/editor.py): `routes/editor.py`
- [審查紀錄查詢](https://github.com/617-lyx/1151se_mid/blob/main/routes/editor.py): `routes/editor.py`

### 共用呈現

- [共用呈現工具](https://github.com/617-lyx/1151se_mid/blob/main/common.py): `common.py`
- [動態頁面模板](https://github.com/617-lyx/1151se_mid/tree/main/templates): `templates`
- [登入註冊頁](https://github.com/617-lyx/1151se_mid/tree/main/www): `www`

### 資料持久化

- [連線池](https://github.com/617-lyx/1151se_mid/blob/main/db.py): `db.py`
- **PostgreSQL**
- [資料表與初始資料](https://github.com/617-lyx/1151se_mid/blob/main/review.sql): `review.sql`

### Other components

- **瀏覽器使用者**

## Connections

- 瀏覽器使用者 → FastAPI入口: HTTP請求 (evidence: `README.md`)
- FastAPI入口 → 登入註冊: 掛載路由 (evidence: `main.py`)
- FastAPI入口 → 作者稿件流程: 掛載路由 (evidence: `main.py`)
- FastAPI入口 → 編輯審查流程: 掛載路由 (evidence: `main.py`)
- FastAPI入口 → 登入註冊頁: 提供靜態頁 (evidence: `main.py`)
- FastAPI入口 → 角色檢查: 檢查首頁登入 (evidence: `main.py`)
- 登入註冊 → 連線池: 取得資料連線 (evidence: `routes/login.py`)
- 登入註冊 → PostgreSQL: 查寫使用者 (evidence: `routes/login.py`)
- 作者稿件流程 → 角色檢查: 限制作者角色 (evidence: `routes/author.py`)
- 作者稿件流程 → 連線池: 取得資料連線 (evidence: `routes/author.py`)
- 作者稿件流程 → PostgreSQL: 讀寫稿件 (evidence: `routes/author.py`)
- 作者稿件流程 → 審查紀錄查詢: 取得審查紀錄 (evidence: `routes/author.py`)
- 編輯審查流程 → 角色檢查: 限制編輯角色 (evidence: `routes/editor.py`)
- 編輯審查流程 → 連線池: 取得資料連線 (evidence: `routes/editor.py`)
- 編輯審查流程 → PostgreSQL: 讀寫審查資料 (evidence: `routes/editor.py`)
- 編輯審查流程 → 審查紀錄查詢: 查詢稿件紀錄 (evidence: `routes/editor.py`)
- 作者稿件流程 → 共用呈現工具: 使用共用工具 (evidence: `routes/author.py`)
- 編輯審查流程 → 共用呈現工具: 使用共用工具 (evidence: `routes/editor.py`)
- 登入註冊 → PostgreSQL: 註冊使用者 (evidence: `routes/login.py`)
- 資料表與初始資料 → PostgreSQL: 建立資料表 (evidence: `README.md`)
- 共用呈現工具 → 動態頁面模板: 設定模板目錄 (evidence: `common.py`)
- 作者稿件流程 → 動態頁面模板: 呈現作者頁面 (evidence: `routes/author.py`)
- 編輯審查流程 → 動態頁面模板: 呈現編輯頁面 (evidence: `routes/editor.py`)
