Markdown Blog
A blogging platform with Markdown drafts, revision history, and a full-stack publishing workflow.
A Markdown writing workflow with a full application around it
I wanted to write posts as Markdown, keep a usable revision history, and still have accounts, comments, moderation, and administration. Markdown Blog is the full-stack platform I built around that workflow.
The frontend uses React and TypeScript; the backend uses Flask and SQLModel. The application keeps editable Markdown on the filesystem, records post data and rendered HTML in a relational database, and integrates with GitHub for draft revisions. Authentication, comments, notifications, and deployment to shared hosting add their own boundaries to that core publishing flow.
Why drafts and published posts use different stores
The editable draft is a Markdown file with YAML frontmatter. The database also holds post metadata, including author, title, slug, state, and timestamps. On publication, the application renders and sanitizes the Markdown and stores the resulting HTML with the post. Readers can retrieve that representation without rendering the source on every request.
Editor → Flask API → Markdown draft file → GitHub revision
↓
render and sanitize
↓
database post and HTML → public reader
The separation gives the author a portable source file and gives the public application a prepared representation. It also creates a consistency problem: the file, database, and GitHub are separate systems, so they cannot be treated as one atomic save.
The publication handler saves the database record before attempting the subsequent draft-frontmatter and GitHub updates. In the examined implementation, a database failure stops publication; a later file or GitHub synchronization failure can leave the published database state in place while the other representation is stale. That distinction matters during recovery. Repeating the whole operation is not necessarily the same thing as repairing the failed synchronization step.
Revision history that supports comparison and restore
Keeping old files is only the start of a revision feature. The author needs to know which version they are viewing, compare the intended pair, and understand what restoring a version will do.
The revision workflow records content alongside a commit identity, author, timestamp, and message. A timeline and diff view let the author inspect earlier work. The diff service normalizes line endings and marks additions, deletions, and context; displayed HTML is escaped so source text is not treated as page markup.
Restoring a revision writes its content to the current draft and records the restore as a new change. The intervening history remains available. Restoring the draft and publishing it are separate operations, so restoring an earlier draft should not be presented as automatically replacing the public post.
There is another failure boundary here: the examined revert handler writes the local draft before requesting the GitHub commit. If the later operation fails, the local write may already have happened. The history feature therefore has to communicate more than a simple success or failure label.
Authentication beyond a happy-path token
Clerk supplies authentication, and the backend applies role checks to protected operations. Production work revealed two different assumptions in that path.
First, the adapter constructed a hostname from a publishable key but tried to remove a sentinel character before decoding the value that contained it. The resulting hostname retained a trailing dollar sign, interfering with retrieval of the public keys used to verify tokens. The fix decoded first and removed the sentinel from the decoded hostname.
Later, a verified token could lack the email field the application expected. The middleware added a fallback lookup using the verified user ID, selecting the primary email from the provider response when available. That solves a different problem from signature verification: a valid identity does not imply that every application field is present in its token. The fallback also adds a dependency on a profile lookup when the field is missing.
The browser test setup evolved as well. Earlier tests could use controlled tokens and local signing keys, which were useful for testing backend behavior, but a fake login could bypass the provider context needed by real frontend components. The Playwright migration uses Clerk’s test integration for the browser flow while retaining mocks for appropriate unit tests. Each test boundary answers a different question.
Publishing, discussion, and operations
The platform includes comments, replies, moderation, notifications, and administrative views. The comment system uses server-sent events for updates. Email delivery and GitHub synchronization involve external services, so retries and error reporting are part of the application rather than details that can be ignored once the editor works.
Deployment brought a separate set of assumptions into view. The target host uses LiteSpeed and the CloudLinux Python Selector. A deployment script could finish transferring files and requesting a restart while the actual website remained broken. The revised deployment workflow installs dependencies in the selector-managed environment, deploys the built frontend and backend, requests a restart, and probes health endpoints. A health response gives evidence about that endpoint; it does not prove every reader or author workflow works.
Configuration can fail before the application reaches those checks. One production settings model expected CPANEL_-prefixed database variables while the launcher supplied DB_NAME, DB_USER, and DB_PASSWORD. Aligning the names required changing tests to represent the launcher’s actual environment. A settings test can confirm a constructed connection URL without establishing that a live database connection succeeds.
What the project demonstrates
Markdown Blog spans the work from editing and versioning a document to serving it to readers and operating the deployed application. It also shows where the boundaries are: a draft save is not a publish, a restore is not a database transaction across GitHub and the filesystem, a verified token may not contain a profile field, and a successful upload is not proof that the site is healthy.
The repository includes backend tests, frontend unit tests, and Playwright scenarios. Those tests document different parts of the system; the repository does not by itself establish a production traffic figure, user-adoption metric, or performance improvement.