1. Trend Ingestion
Pull trending topics from market/news feeds and normalize topic candidates.
Build Guide
This page documents the exact architecture and implementation flow used on this website. You can follow it to build the same automated MDX blog engine in your own project.
Pull trending topics from market/news feeds and normalize topic candidates.
Remove recently used topics and choose the highest novelty + relevance topic.
Generate structured MDX content with consistent sections and SEO-friendly formatting.
Store slug, topic, excerpt, MDX body, timestamps, and source topics in PostgreSQL.
Expose posts through HTML pages, metadata, sitemap, RSS, robots, and llms.txt.
Run generation endpoint 3x daily via cron for steady content freshness.
1. cron -> /api/automation/generate-post
2. fetchTrendingTopics() -> [topics]
3. selectTopic(topics, recentTopics)
4. generateBlogDraftWithGemini(topic) -> title/excerpt/contentMdx
5. ensureUniqueSlug(title)
6. insertBlogPost(...) -> PostgreSQL
7. /blogs and /blogs/[slug] instantly reflect new post
The core storage model is intentionally simple to keep publishing fast and query-friendly.
CREATE TABLE blog_posts ( id BIGSERIAL PRIMARY KEY, slug TEXT UNIQUE NOT NULL, title TEXT NOT NULL, excerpt TEXT NOT NULL, content_markdown TEXT NOT NULL, topic TEXT NOT NULL, source_topics JSONB NOT NULL DEFAULT '[]'::jsonb, published_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() );
Environment
Set `GEMINI_API_KEY`, `DATABASE_URL`, `CRON_SECRET`, and `GEMINI_MODEL`.
Scheduling
Configure Vercel cron jobs for three daily publish windows.
SEO
Keep sitemap, feed.xml, llms.txt, and article schema continuously updated.
Quality
Run periodic prompt tuning for better topic relevance and structure quality.
Want to extend this architecture with moderation, search, or multilingual publishing?
Contact the Team