Planning a Blog Application with AI: Data, the Request Path and a Master Prompt
Typing "build me a blog" lets the AI make every decision for you. Plan it first: model a post as data, trace one request through the app, pick a simple stack, then write a master prompt in role, context, task and format that asks for a plan before any code.
What you will learn
- List the parts a blog needs and model a post as plain Python data
- Trace a request from the browser through a controller, models and a template and back
- Choose a simple stack for a simple monolithic app
- Write a master prompt in role, context, task and format, and ask for a plan before any code
Before you start
- Python dataclasses
- Monolith vs microservices basics
Say you open an AI tool and type one line: build me a blog website. You'll get a blog, no doubt. But look at what you didn't say. Which database, how login works, how the folders are arranged.
The AI makes every one of those decisions for you, and you may not even know it made them. You also can't tell whether the code is well designed or ready for production. So in this lesson you won't build the app yet. You'll plan it, because a good plan is what makes the building go well.
What's a blog, really?
Put one page together in your head. At the top there's a navigation bar. In the middle there's the post, with its title and the author's name. On the side there's a sidebar with the tags, so readers can jump to a topic. Under the post come the comments. And there's login, because someone has to be allowed to write.
Those are the bare essentials. If your prompt leaves them out, you've left them up to the AI.
Here's an easy way to think about it: a blog is a newspaper. A publisher writes a story and publishes it, readers pick it up, and some write back, like a letter to the editor. One place makes the paper and everyone reads from it. That's why a single monolithic application is good enough here. Nothing about this needs lots of small services.
A post as data
Before you ask an AI for anything, see what a post is as data. In blog_model.py a dataclass saves you writing __init__ by hand:
from dataclasses import dataclass, field
@dataclass
class Post:
title: str
author: str
tags: list = field(default_factory=list)
comments: list = field(default_factory=list)
post = Post("Hello World", "Alice", ["intro"])
post.comments.append("Nice start!")
print(post)
print(post.title, "by", post.author)
print(len(post.comments), "comment")
Post(title='Hello World', author='Alice', tags=['intro'], comments=['Nice start!'])
Hello World by Alice
1 comment
Tags and comments use field(default_factory=list), so each post gets its own fresh list. Everything on that blog page is really just data like this, and that's worth knowing before you describe it to an AI.
A page is a list of posts
A lot of pages in a blog are just a list of posts. In blog_pages.py three posts sit in a list, and list_page takes an optional tag:
POSTS = [
Post("Hello World", "Alice", ["intro"]),
Post("Why I Write", "Bob", ["notes", "intro"]),
Post("Week One", "Alice", ["diary"]),
]
def list_page(posts, tag=None):
shown = [p for p in posts
if tag is None or tag in p.tags]
lines = ["== Home =="]
for number, post in enumerate(shown, start=1):
line = f"{number}. {post.title} - {post.author}"
lines.append(line)
return "\n".join(lines)
print(list_page(POSTS))
print()
print(list_page(POSTS, tag="intro"))
== Home ==
1. Hello World - Alice
2. Why I Write - Bob
3. Week One - Alice
== Home ==
1. Hello World - Alice
2. Why I Write - Bob
With no tag, every post passes the check. With tag="intro", Week One is tagged diary, so it drops out. That's what a tag page does: same function, same data, a shorter list.
When a reader opens a post
The browser sends a request to your application. Inside it, a controller picks up the request (Django calls it a view, but it's the same job). The controller asks the models for the post, and the models read it from the database. You'll use PostgreSQL for that. The post comes back, the controller hands it to a template, the template fills it into HTML, and the HTML goes back to the browser.
The path in code
request_path.py has no server. It's plain Python, so you can watch each step. handle takes a path the way a controller would:
POSTS = {1: "Hello World", 2: "Why I Write"}
def list_view():
return list(POSTS.values())
def post_view(post_id):
return POSTS[post_id]
def template(title, body):
return f"<h1>{title}</h1>\n<p>{body}</p>"
def handle(path):
print("browser asks for", path)
if path == "/":
data = list_view()
html = template("Home", ", ".join(data))
elif path.startswith("/post/"):
post_id = int(path.split("/")[2])
data = post_view(post_id)
html = template(data, f"Post number {post_id}")
else:
return "404 Not Found"
print("view read:", data)
return "200 OK\n" + html
print(handle("/"))
print()
print(handle("/post/2"))
print()
print(handle("/about"))
browser asks for /
view read: ['Hello World', 'Why I Write']
200 OK
<h1>Home</h1>
<p>Hello World, Why I Write</p>
browser asks for /post/2
view read: Why I Write
200 OK
<h1>Why I Write</h1>
<p>Post number 2</p>
browser asks for /about
404 Not Found
Slash is the home page, so list_view reads both titles. /post/2 is split, the number 2 comes out, and post_view finds Why I Write. /about matches no branch, so the data is never touched and you get 404. Those are the same status codes you met with REST.
Choosing a stack
Keep the stack as simple as the app. For the framework there are three good choices, Django, Flask and FastAPI, and any of them can do this. For the data, PostgreSQL. For the pages, server-side templates rather than a single-page app, so no Angular or React.
Then there's login, and an ORM, which lets you work with database rows as Python objects. Django ships with both. Flask and FastAPI stay smaller, so you add libraries for those, like SQLAlchemy. There's no payment gateway and nothing fancy in this app, so a simple stack is the right stack. One blog, three frameworks compares the three side by side.
A prompt is a client brief
Picture a client walking up to a developer and saying, make me a website. The developer has to guess everything, and the result probably isn't what the client had in mind. Now picture the same client with one clear page: who it's for, what it must do, what to use. Same developer, a much better result.
You're that client. People call this vibe coding, because the AI does the typing. But the decisions still belong to you.
The master prompt
Here's the brief, in master_prompt.txt. It has four parts: role, context, task and format.
ROLE
You are a senior Python web developer.
CONTEXT
I am building a simple blog as one monolithic
application. Readers browse posts and leave
comments. Pages are rendered on the server.
TASK
Cover the essentials: posts, authors, tags,
comments, navigation, a sidebar and login.
Feel free to add anything else a good blog
should have.
Before writing any code, share your plan and
ask me any questions you have.
FORMAT
Stack: Django with PostgreSQL (or Flask, or
FastAPI, with PostgreSQL).
Use the framework's built-in authentication.
No API gateway and no separate front end.
Render the UI with server-side templates.
Folders: well organised and conventional,
with controllers, templates, static assets
and tests each in their own folder.
Follow industry best practices.
Nothing in it is hard. It's just the decisions you've already made, written down.
Four moves worth copying
The role sets the level of the answer. The open-ended ask, "feel free to add anything else a good blog should have", leaves room for features you didn't think of; if you list only what you remembered, a forgotten feature never shows up. The strict rules (no API gateway, no separate front end, server-side templates) pin down what you've already decided. And the quality gate, "follow industry best practices", asks for clean work. AI tools usually manage that, but folders can still get messy as an app grows, so you ask, and then you check.
Be open about ideas, and strict about decisions.
The framework swap
Look at the stack line. It says Django with PostgreSQL, and the brackets name the other two. Change it to Flask or FastAPI and role, context and task stay exactly as they are, because the blog is still the same blog. One line needs care: Flask and FastAPI don't ship a full login system, so with those you'd ask for a well-known authentication library instead of built-in authentication.
Where things go
The brief asks for conventional folders. For a Django project you'd expect something like this: blog holds posts, tags and comments; users holds login and profiles; templates holds the server-rendered HTML; static has CSS, JavaScript and images; tests has the tests; manage.py is Django's entry point; requirements.txt lists the libraries; and .env.example shows the settings you need.
Always open the files and check them. Don't keep prompting and hope it all works. You're the developer, and the AI follows your lead.
Ask for a plan, invite questions
Look at the end of the task: "Before writing any code, share your plan and ask me any questions you have." There's also a follow-up, plan_request.txt:
Thanks. Before any code, please send:
1. Your plan, step by step.
2. The folder layout you propose.
3. The questions you need me to answer.
I will answer, then you can start.
What comes back is a plan, not code. The AI may also ask you things, like whether anyone can comment or only people who've logged in. Think twice, send your answers back, and only then let the code start. You're making the decisions before a single line gets written, and that small habit lifts the quality of the whole app.
Recap
- A blog is posts as data plus pages, and every request takes the same path: ask, read, fill in, send back.
- A simple app gets a simple stack: one framework, PostgreSQL, server-side templates.
- The master prompt is your brief in role, context, task and format.
- Ask for a plan and invite questions before any code.
Try it yourself: write a master prompt for an app of your own. The project's my_app_prompt.txt does it for a family recipe box on Flask with PostgreSQL, covering recipes, ingredients, tags and search. Then ask an AI tool for a plan, not code. If you want to compare your plans with other learners, the StudyEasy community on Skool is free to join.
StudyEasy AI Community
Learn AI engineering, share what you build, and connect with other learners.
Free resources: lesson files, notebooks and code
Ask questions and join engineering discussions
Meet real people learning and building with AI
Related course on Udemy
The Python Architect Masterclass: Full Stack to AI Engineer
Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)Related posts
Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed
When the main model goes down, the backup has to be allowed to take the data, able to read the whole request and tested before the bad day. A simulated four-model chain for an EU customer: a 6,000-token request lands on mid-eu, flagged degraded; a 10,000-token request is served by nobody, on purpose.
Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves
A bulk upload buries the chat. In a small simulation, one shared queue grows to 199 waiting and the middle chat answer takes 80.2 s. A bound plus a chat lane brings it to 0.35 s while 178 bulk jobs are told to retry in 10 s, and cancelling abandoned calls saves 21,000 wasted tokens.
Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys
Six GPU replicas, two at 95% and four at 30%: round robin counts requests, and requests aren't equal. In a small simulation, least outstanding requests cuts p95 from 6.52 s to 3.05 s, prefix affinity lifts cache hits to 95% but pushes p95 to 11.45 s, a real health check takes errors from 48 to 2, and draining cuts 0 answers instead of 4.
A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue
A queue doesn't lose a document, but it can hand one out twice. In a small simulation, a worker crash makes document two go from 3 to 6 chunks and the index holds 11 when the documents hold 8. An idempotent consumer brings it back to 8 with the same two deliveries, and a limit of three tries moves a poison file to a dead letter queue.
