# 1eakkkk/my-blog architecture

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

- Interactive diagram: https://gitdiagram.com/1eakkkk/my-blog
- Repository: https://github.com/1eakkkk/my-blog

## Overview

1eak.cool is a lightweight private forum built as a browser SPA and Cloudflare Pages Functions API. Visitors register or sign in, browse and search posts, open discussions, comment or react, and manage their profiles; authors can publish posts with uploaded media, while administrators maintain content and site settings. The README documents additional features such as Markdown rendering, nested comments, and a management console. The sampled handlers show API-to-D1 and upload-to-R2 behavior; other subsystem links rely on README descriptions, so uncertain internal wiring is omitted.

Main entry points: [`script.js`](https://github.com/1eakkkk/my-blog/blob/main/script.js) (Forum SPA), [`functions/api/_lib.js`](https://github.com/1eakkkk/my-blog/blob/main/functions/api/_lib.js) (Session identity), [`functions/api/auth`](https://github.com/1eakkkk/my-blog/tree/main/functions/api/auth) (Register and login), [`functions/api/posts.js`](https://github.com/1eakkkk/my-blog/blob/main/functions/api/posts.js) (Post service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser app"]
  node_spa["Forum SPA<br/>[script.js]"]
  node_main_page["Forum shell<br/>[index.html]"]
  node_login_page["Login page<br/>[login.html]"]
end

subgraph group_identity["Identity and security"]
  node_auth["Register and login"]
  node_session["Session identity<br/>[_lib.js]"]
  node_middleware["Rate limiting<br/>[_middleware.js]"]
end

subgraph group_community["Forum features"]
  node_posts["Post service<br/>[posts.js]"]
  node_comments["Comment service<br/>[comments.js]"]
  node_likes["Like service<br/>[like.js]"]
  node_upload["Media upload<br/>[upload.js]"]
  node_profiles["Profile service<br/>[profile.js]"]
  node_public_users["Public user lookup<br/>[user-public.js]"]
end

subgraph group_operations["Site operations"]
  node_admin["Admin console API<br/>[admin.js]"]
  node_heartbeat["Presence heartbeat<br/>[heartbeat.js]"]
  node_config["Public configuration<br/>[config.js]"]
  node_avatar["Avatar generation<br/>[random_avatar.js]"]
end

subgraph group_platform["Cloudflare services"]
  node_d1[("D1 database")]
  node_r2[("R2 object storage")]
  node_kv[("KV rate-limit store")]
  node_turnstile["Turnstile verification"]
end

node_visitor(("Visitor"))
node_admin_actor(("Administrator"))

node_visitor -->|"opens forum"| node_main_page
node_visitor -->|"opens account"| node_login_page
node_admin_actor -->|"opens console"| node_main_page
node_main_page -->|"loads app"| node_spa
node_login_page -->|"registers or signs in"| node_auth
node_spa -->|"requests posts"| node_posts
node_spa -->|"requests comments"| node_comments
node_spa -->|"toggles likes"| node_likes
node_spa -->|"uploads media"| node_upload
node_spa -->|"updates profile"| node_profiles
node_spa -->|"looks up profiles"| node_public_users
node_spa -->|"requests admin actions"| node_admin
node_spa -->|"reports presence"| node_heartbeat
node_spa -->|"loads settings"| node_config
node_spa -->|"requests avatar"| node_avatar
node_auth -->|"reads and writes"| node_d1
node_auth -.->|"verifies challenge"| node_turnstile
node_auth -->|"creates session"| node_session
node_session -->|"checks sessions"| node_d1
node_posts -->|"checks identity"| node_session
node_posts -->|"reads and writes"| node_d1
node_comments -->|"checks identity"| node_session
node_comments -->|"reads and writes"| node_d1
node_likes -->|"checks identity"| node_session
node_likes -->|"updates likes"| node_d1
node_upload -->|"checks identity"| node_session
node_upload -->|"stores media"| node_r2
node_profiles -->|"checks identity"| node_session
node_profiles -->|"updates user"| node_d1
node_public_users -->|"reads users"| node_d1
node_admin -->|"checks identity"| node_session
node_admin -->|"reads and writes"| node_d1
node_heartbeat -->|"updates presence"| node_d1
node_config -->|"reads settings"| node_d1
node_avatar -.->|"reads user data"| node_d1
node_middleware -->|"tracks request limits"| node_kv

click node_spa "https://github.com/1eakkkk/my-blog/blob/main/script.js"
click node_main_page "https://github.com/1eakkkk/my-blog/blob/main/index.html"
click node_login_page "https://github.com/1eakkkk/my-blog/blob/main/login.html"
click node_auth "https://github.com/1eakkkk/my-blog/tree/main/functions/api/auth"
click node_session "https://github.com/1eakkkk/my-blog/blob/main/functions/api/_lib.js"
click node_middleware "https://github.com/1eakkkk/my-blog/blob/main/functions/api/_middleware.js"
click node_posts "https://github.com/1eakkkk/my-blog/blob/main/functions/api/posts.js"
click node_comments "https://github.com/1eakkkk/my-blog/blob/main/functions/api/comments.js"
click node_likes "https://github.com/1eakkkk/my-blog/blob/main/functions/api/like.js"
click node_upload "https://github.com/1eakkkk/my-blog/blob/main/functions/api/upload.js"
click node_profiles "https://github.com/1eakkkk/my-blog/blob/main/functions/api/profile.js"
click node_public_users "https://github.com/1eakkkk/my-blog/blob/main/functions/api/user-public.js"
click node_admin "https://github.com/1eakkkk/my-blog/blob/main/functions/api/admin.js"
click node_heartbeat "https://github.com/1eakkkk/my-blog/blob/main/functions/api/heartbeat.js"
click node_config "https://github.com/1eakkkk/my-blog/blob/main/functions/api/config.js"
click node_avatar "https://github.com/1eakkkk/my-blog/blob/main/functions/api/random_avatar.js"

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_spa,node_main_page,node_login_page toneBlue
class node_auth,node_session,node_middleware toneAmber
class node_posts,node_comments,node_likes,node_upload,node_profiles,node_public_users toneMint
class node_admin,node_heartbeat,node_config,node_avatar toneRose
class node_d1,node_r2,node_kv,node_turnstile,node_visitor,node_admin_actor toneIndigo
```

## Components

### Browser app

- [Forum SPA](https://github.com/1eakkkk/my-blog/blob/main/script.js): `script.js`
- [Forum shell](https://github.com/1eakkkk/my-blog/blob/main/index.html): `index.html`
- [Login page](https://github.com/1eakkkk/my-blog/blob/main/login.html): `login.html`

### Identity and security

- [Register and login](https://github.com/1eakkkk/my-blog/tree/main/functions/api/auth): `functions/api/auth`
- [Session identity](https://github.com/1eakkkk/my-blog/blob/main/functions/api/_lib.js): `functions/api/_lib.js`
- [Rate limiting](https://github.com/1eakkkk/my-blog/blob/main/functions/api/_middleware.js): `functions/api/_middleware.js`

### Forum features

- [Post service](https://github.com/1eakkkk/my-blog/blob/main/functions/api/posts.js): `functions/api/posts.js`
- [Comment service](https://github.com/1eakkkk/my-blog/blob/main/functions/api/comments.js): `functions/api/comments.js`
- [Like service](https://github.com/1eakkkk/my-blog/blob/main/functions/api/like.js): `functions/api/like.js`
- [Media upload](https://github.com/1eakkkk/my-blog/blob/main/functions/api/upload.js): `functions/api/upload.js`
- [Profile service](https://github.com/1eakkkk/my-blog/blob/main/functions/api/profile.js): `functions/api/profile.js`
- [Public user lookup](https://github.com/1eakkkk/my-blog/blob/main/functions/api/user-public.js): `functions/api/user-public.js`

### Site operations

- [Admin console API](https://github.com/1eakkkk/my-blog/blob/main/functions/api/admin.js): `functions/api/admin.js`
- [Presence heartbeat](https://github.com/1eakkkk/my-blog/blob/main/functions/api/heartbeat.js): `functions/api/heartbeat.js`
- [Public configuration](https://github.com/1eakkkk/my-blog/blob/main/functions/api/config.js): `functions/api/config.js`
- [Avatar generation](https://github.com/1eakkkk/my-blog/blob/main/functions/api/random_avatar.js): `functions/api/random_avatar.js`

### Cloudflare services

- **D1 database**
- **R2 object storage**
- **KV rate-limit store**
- **Turnstile verification**

### Other components

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

## Connections

- Visitor → Forum shell: opens forum
- Visitor → Login page: opens account
- Administrator → Forum shell: opens console
- Forum shell → Forum SPA: loads app
- Login page → Register and login: registers or signs in
- Forum SPA → Post service: requests posts
- Forum SPA → Comment service: requests comments
- Forum SPA → Like service: toggles likes
- Forum SPA → Media upload: uploads media
- Forum SPA → Profile service: updates profile
- Forum SPA → Public user lookup: looks up profiles
- Forum SPA → Admin console API: requests admin actions
- Forum SPA → Presence heartbeat: reports presence
- Forum SPA → Public configuration: loads settings
- Forum SPA → Avatar generation: requests avatar
- Register and login → D1 database: reads and writes
- Register and login → Turnstile verification: verifies challenge
- Register and login → Session identity: creates session
- Session identity → D1 database: checks sessions
- Post service → Session identity: checks identity
- Post service → D1 database: reads and writes
- Comment service → Session identity: checks identity
- Comment service → D1 database: reads and writes
- Like service → Session identity: checks identity
- Like service → D1 database: updates likes
- Media upload → Session identity: checks identity
- Media upload → R2 object storage: stores media
- Profile service → Session identity: checks identity
- Profile service → D1 database: updates user
- Public user lookup → D1 database: reads users
- Admin console API → Session identity: checks identity
- Admin console API → D1 database: reads and writes
- Presence heartbeat → D1 database: updates presence
- Public configuration → D1 database: reads settings
- Avatar generation → D1 database: reads user data
- Rate limiting → KV rate-limit store: tracks request limits
