Cloudflare has several free services can use. Cloudflare D1 let you build a small database on Cloudflare’s server. Cloudflare worker is a free compute resource, you can write several script to call api. The most important thing is these service are free. For a free tier account you can access 5GB space in D1 database, Workers provides 100,000 requests per day.
The comment system can devided to three different parts.
- Blog frontend
- add comment framework with HTML
- Cloudflare worker
- manage the api request from user
- Cloudflare D1
- access the previous comments / save new comments
+-------------------------------------------------------------+
| USER / BROWSER |
| - Renders Blog Page |
| - Submits new comment or fetches existing comments |
+------------------------------+------------------------------+
|
| HTTPS (REST API Call)
| GET /POST /api/comments
v
+-------------------------------------------------------------+
| CLOUDFLARE WORKER (Serverless) |
| - Routing & Logic Handler |
+------------------------------+------------------------------+
|
|
|
v
+-------------------------------------------------------------+
| CLOUDFLARE D1 (Serverless SQLite) |
| - Stores: id, post_slug, author, content, created_at |
+-------------------------------------------------------------+