Sign up Log in
n/program · 16d ago · 212 views
u/luobikangSilver
n/programu/luobikang · 16d ago

Reference for AI Programming a Blog Project

The original design intent came from the fact that many page-based site setups are complicated and hard to operate. Important site files get lost due to operator mistakes, and commercial hosts go under or become unstable. Common blog projects are also single-purpose and don't work for multiple users sharing one site. This project aims to solve all of that in one place: video storage, blogs, e-book sharing, personal business sites, file backups, email setup, page color and image customization, translation, member registration management, site bookmark syncing, and other common needs.

The project is basically developed, still being tweaked. If I open-source it, I'll add it to this post or announce it separately.
But I can talk about the design philosophy first — welcome to borrow from it or point out issues.

Continuing from last time, we worked out how to use AI prompts and troubleshoot more effectively.
Today I'll focus on the design philosophy.

First decide the deployment platform and applicable architecture. Of course, the more deployment methods and platforms supported, the easier it is to promote. But once the architecture is set, it's very hard to change or replace.

Language architecture:
This project prioritizes Cloudflare D1 and R2. D1 stores structured data like articles, comments, categories, tags, and file metadata; R2 stores large files like images, videos, audio, and attachments. KV is only used for caching and config, not as primary data storage. If D1 or R2 isn't configured, some upload, file management, and content publishing features won't work.

Login system
The admin password is the login variable — that's the most common password setup. Standard practice is no default production admin password, and unauthenticated front-end pages must not be able to modify admin credentials. Sure, if you insist on leaving a default password, the AI will do it, but it doesn't meet the security requirements for building a project. Due to security restrictions, Cloudflare Pages deployment environment variables must be modified in the Cloudflare deployment settings dashboard; the site's front-end pages can't write back to them directly.
The super admin account (e.g. fox) self-registers and is authenticated directly via environment variables; regular users can register openly. If anyone tries to register the reserved admin name (fox/admin), it's not allowed; when not logged in you're in regular user mode, and logging in as admin unlocks publish, edit, and delete article permissions.

Image storage notes
First you need to know how image characteristics affect the site environment. If they're thumbnails, that saves more traffic — turn on real-time traffic in your phone settings to check. If a site burns hundreds of KB per second when opened, and keeps wasting traffic continuously even after loading finishes, that's because syncing wasn't written properly or some other issue. Under 20KB per second is fairly normal. Common photos are jpg and png. Images in the file list after upload are compressed, saving more traffic — this design makes pages open faster. They're generally smaller than the actual dimensions.
Thumbnail format Use case Features
WebP First choice for web thumbnails 25%~35% smaller than JPG at the same quality, supports transparency, supported by all mainstream browsers
JPG/JPEG Photo thumbnails Best compatibility, small size, good for colorful images
PNG Thumbnails with transparent backgrounds or text Lossless compression, sharp edges, but larger size
AVIF For maximum compression About 30% smaller than WebP, but slow to encode and only partly supported by browsers.
Images are converted to local Base64 / Data URL format and saved in local storage so they can load and display at any time.

Sync area
This is cross-device cloud primary database (D1/Sync API) syncing. Cloud sync solves the problem of photos not displaying across devices. Enables online music and video playback. Adaptive video aspect ratio. Adds video download. Solves file upload issues.

Password area
Needs to be stated in the repo: the variable name is PASSWORD. Should the password be set by the admin themselves, or should it be a strengthened password?
It should explain that after adding the variable and deploying, you can log in with the variable's password.

Connection area
You can connect KV, database, and storage buckets to achieve syncing. D1 database and R2 storage bucket are preferred.
Decide on the mapping between these and files after you have some understanding, to avoid mismatches.

Translation area
Add a close button to the registration panel. Implement the ability to save external translation API config for normal in-site use, with a save button.

Upload area
The file list modes for blog, bookshelf, album, and media all support four view options: large image, medium image, small image, and details, plus the original layout mode. Blog, bookshelf, album, and media support batch upload, download, and delete. Blog adds a favorites area.
Fix uploads getting stuck and inaccurate progress bars.
Finally, check the whole project for unknown errors and fix them.

Private area
Make the backup area, backup area email hub, system settings, and site image hosting section visible only to admins.

Clear permissions
Uniqueness of the admin account — a project can't have multiple super admins. Designate the super admin name as fox.
Registered users can't delete or edit e-books, images, videos, or blogs. Registered users can only delete and publish blogs, and the publish page shows their name marked as a registered user.
Complete the registered user list feature in the settings area.

Site features area
Can save and delete any internet site as image hosting; sites display as posters with a jump link, and custom site descriptions can be saved under the address. Defaults to https://123456. The site features area is admin-only. Note in the bottom page area which sections are admin-only.

Guide area
Cloudflare D1 (database), R2 (image storage bucket), and KV integration specs, binding variable documentation, and extension guide.

Update the repo README to match the latest branch, in clearer, more precise, simpler, and easier-to-understand language. Include deployment guide variables and other info. Email area, API area.
Supports CF Pages pull deployment and upload deployment.
Can bind R2 and KV directly in the CF dashboard. Effective real-time sync. Add D1 database and R2 object storage usage instructions to the in-site deployment guide.
A blog project named fox3 — write the project intro, deployment guide, build instructions, and variables in the repo. Support deployment via various methods and platforms, including Tencent Cloud and Alibaba Cloud. CF one-click pull deployment is preferred; for Pages one-click file upload deployment, explain how to get the upload package. Beautiful interface.

Email area:
Implement sending with third-party email services that support saved API config.
Implement "register email/verification code" sending.
Implement auto-reply for verification codes.
Receiving via Cloudflare Email Routing or other. Reserve and display saved config; implement admin replying to user emails from within the site. Complete mail management area: admins can send, view, delete, reply, and batch manage mail in-site, with a mail recycle bin. Have send/receive limit switches, with a 3,000-email cap. Prioritize storing email info in the database; if unavailable, also support KV.

Homepage intro area:
After customizing images in the homepage intro area, implement the image background visually.

Backup area:
Add a Nutstore or other WebDAV file management area to the external backup management section. After connecting Nutstore or another cloud drive via WebDAV in settings, visually manage uploaded files and enable selective blog backup and restore to prevent server operational risks. Consider your own technical situation — if you don't have an environment for timely troubleshooting, don't add too many features.

Product area
Add a product area; the display area can upload and delete multiple images, manage multiple product display areas, set prices and product descriptions, and include reserved interfaces for various payment methods including PayPal, WorldFirst, WeChat, and Alipay. Settings and orders, and payment method interfaces are admin-only (and note this). Users can submit orders and choose quantities. Submitted orders must include contact address, phone, and email. Implement a chat window on the product showcase so admins can talk with users in the backend. Admins can view orders in the backend, split into paid and unpaid.

Other:
Upload and download progress bars appear during operations. E-book mobile interface supports fullscreen viewing without blocking the top of the phone display. Logout button and function work properly. Implement login and registration panels. Header can be opened and collapsed. Custom site-wide background photo and custom site-wide avatar; the photo homepage intro area photos all support setting local image uploads. System management area options are admin-only.

Settings area:

Add a login panel. Can edit articles, publish and delete articles. Articles can upload local images. Can favorite articles, change avatar and theme name. Date is real-time network time, timezone adjustable. Can set local images as background.
Theme color and global background customization section, from top to bottom includes these buttons: custom site name, theme color button (one-click quick color scheme), custom background color palette, custom avatar, site-wide background photo, homepage intro area photo.
All sections can be opened and collapsed. Add one-click toggle between mobile and desktop interface.
Registered user management list section.

Registration and privacy area notes:
Enable site-wide privacy protection (unregistered visitors can only see blogs), email-only registration, and open registration policy.
Site-wide privacy switch (unregistered visitors only see blogs)
When enabled, external visitors who aren't logged in can only browse blog articles; sections like cloud drive, bookshelf, media, album, and AI programming will be strictly hidden from visitors.
Email-only registration (forced email identity verification)
When enabled, new users must provide a valid email and verify it, preventing fake bots from mass-registering.

Repo README:
"Brief description"
In-site deployment guide, repo deployment guide, must match the latest situation. Supports CF Pages pull deployment and upload deployment.
Can bind R2 and KV directly in the CF dashboard. Effective real-time sync. Add D1 database and R2 object storage usage instructions to the in-site deployment guide.
A blog project named fox3 — write the project intro, deployment guide, build instructions, and variables in the repo. Support deployment via various methods and platforms, including Tencent Cloud and Alibaba Cloud. CF one-click pull deployment is preferred; for Pages one-click file upload deployment, explain how to get the upload package.
Multiple themes, beautiful interface.

Global fix prompt
Please check the global project and find issues. Or find issues in a specific area.
(Syncing works, file display works, file upload and download work, file saving works, database/KV/storage bucket usage works, connections work, settings info works, status lights work, email send/receive works, product area works)

Translated by AI from 简体中文

3
4
Log into join the discussion.

4 replies

Sort order
  1. yealo Gold 3 YEARS 16d ago

    Lately I've been milking Cloudflare D1 for all it's worth, and honestly my experience hasn't been great. I used some forum guy's blog setup, bound my own Cloudflare domain to it, and within a few days the emails started coming — telling me my usage was about to run out, 50%, 80%, 90%, basically pushing me to upgrade to a paid plan. It stressed me out and I had no idea what to do, so I just shut the blog down. Peace and quiet now :xhj001:

    Translated by AI from 简体中文

    1
  2. Cavalier Silver 11d ago

    Really hardcore all-in-one setup — they've turned all the pitfalls of AI coding and the auth details into a proper spec. Super useful reference!

    Translated by AI from 简体中文

    1
  3. hakd Master 2 YEARS 11d ago

    I've used quite a few blog systems, but in the end I decided to just write my own — strip out all the middleware, pure articles and comments.
    Then I moved all the existing posts over to MongoDB, and after that change it got blazing fast.

    Translated by AI from 简体中文

    1
  4. aiwentisika Gold 11d ago

    Powerful master

    Translated by AI from 简体中文

    0